Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2022-211
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2022-211
2022-211
Commits
5f333fcb
Commit
5f333fcb
authored
May 13, 2022
by
Sivananthan Sivanujan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
20688fc1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
0 deletions
+47
-0
Paddy_Waste.py
Paddy_Waste.py
+47
-0
No files found.
Paddy_Waste.py
0 → 100644
View file @
5f333fcb
import
pandas
as
pd
from
sklearn
import
metrics
from
sklearn.model_selection
import
train_test_split
from
sklearn.tree
import
export_graphviz
from
six
import
StringIO
import
pydotplus
from
sklearn.tree
import
DecisionTreeClassifier
dataset
=
pd
.
read_csv
(
'FarmingData/DataCollected.csv'
)
dataset
.
shape
dataset
[
'chemicalsType'
]
.
replace
({
'organic'
:
1
},
inplace
=
True
)
tableData
=
dataset
[(
dataset
[
"SeedType"
]
==
'Nadu'
)]
dataset
[
'WasteAmount'
]
=
(
dataset
[
'wastage'
]
/
100
)
*
dataset
[
'production'
]
tableData
=
dataset
.
head
()
print
(
tableData
)
# Preparing the Data
feature_cols
=
[
'Seeds'
,
'DailyWater'
,
'chemicalsType'
]
X
=
dataset
[[
'Seeds'
,
'DailyWater'
,
'chemicalsType'
]]
y
=
dataset
[
'WasteAmount'
]
# Training and Making Predictions 0.80 tranning
X_train
,
X_test
,
y_train
,
y_test
=
train_test_split
(
X
,
y
,
test_size
=
0.20
)
# set DecisionTreeClassifier algorithm
classifier
=
DecisionTreeClassifier
()
classifier
.
fit
(
X_train
,
y_train
)
y_pred
=
classifier
.
predict
(
X_test
)
dot_data
=
StringIO
()
export_graphviz
(
classifier
,
out_file
=
dot_data
,
filled
=
True
,
rounded
=
True
,
special_characters
=
True
,
feature_names
=
feature_cols
,
class_names
=
[
'0'
,
'1'
])
graph
=
pydotplus
.
graph_from_dot_data
(
dot_data
.
getvalue
())
# used Seeds Kg , DailyWater , chemicalsType Used
new_input
=
[[
18000
,
1000
,
2
]]
pred
=
classifier
.
predict
(
new_input
)
print
(
pred
)
# measure Accuracy
print
(
"Accuracy:"
,
metrics
.
accuracy_score
(
y_test
,
y_pred
)
*
100
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment