-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforest_dataset.py
More file actions
47 lines (30 loc) · 1005 Bytes
/
Copy pathforest_dataset.py
File metadata and controls
47 lines (30 loc) · 1005 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# -*- coding: utf-8 -*-
"""
Created on Wed Oct 11 14:12:59 2023
@author: LENOVO
"""
#random forest regressor
import pandas as pd
d=pd.read_csv(r"C:\Users\LENOVO\Desktop\aiml\fires.csv")
d.head()
d.columns
d.shape
d.drop([124,122,123,168],axis=0,inplace=True)
d.shape
x=d.iloc[ : , :-1].values
y=d.iloc[: ,-1].values
from sklearn.model_selection import train_test_split
xtrain,xtest,ytrain,ytest=train_test_split(x,y,test_size=0.2,random_state=0)
from sklearn.tree import DecisionTreeClassifier
model=DecisionTreeClassifier(criterion='entropy')
model.fit(xtrain,ytrain)
ypred=model.predict(xtest)
from sklearn.metrics import accuracy_score
print(accuracy_score(ytest,ypred))
print(model.predict([[2, 6, 2012, 29, 61, 13, 1.3, 64.4, 4.1, 7.6, 1, 3.9, 0.4]]))
sample = pd.read_csv(r"C:\Users\LENOVO\Desktop\aiml\fires2.csv")
sample.shape
p=model.predict(sample)
p
sample['status']=p
sample.to_csv(r'C:\Users\LENOVO\Desktop\aiml\predicted.csv')