0% found this document useful (0 votes)
92 views4 pages

Untitled2.ipynb - Colaboratory

This document describes using a random forest classifier on a dataset to predict movements. It loads data from an Excel file, splits it into training and test sets, trains a random forest classifier with 3500 estimators, predicts the test set results, and calculates the testing and training accuracy as well as the confusion matrix. The testing accuracy is around 0.84 and the training accuracy is 1.0.

Uploaded by

uday
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
92 views4 pages

Untitled2.ipynb - Colaboratory

This document describes using a random forest classifier on a dataset to predict movements. It loads data from an Excel file, splits it into training and test sets, trains a random forest classifier with 3500 estimators, predicts the test set results, and calculates the testing and training accuracy as well as the confusion matrix. The testing accuracy is around 0.84 and the training accuracy is 1.0.

Uploaded by

uday
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

4/9/2020 Untitled2.

ipynb - Colaboratory

Revision
import history
pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
fromRaw
sklearn.metrics
source import
Inline diff confusion_matrix Only show named versions
df=pd.read_excel("/content/S11 FINAL.xlsx") 11classifier = RandomForestClassifier(n_estimators = 3500
df = df.dropna() 12classifier.fit(X_train, y_train)
X=df.drop(columns="MOVEMENTS",axis=1) 13y_pred = classifier.predict(X_test)#
Unsaved changesPredicting the Tes
Y=df['MOVEMENTS'] 14cm = confusion_matrix(y_test, y_pred)# Making the Confu
X_train, X_test, y_train, y_test = train_test_split(X,Y, test_size = 0.2) 15print("Testing Accuracy: ", classifier.score(X_test, y_
16print("Training Accuracy: Apr", classifier.score(X_train,
9, 2020 6:13 PM
classifier = RandomForestClassifier(n_estimators = 3500, random_state = 1000,bootstrap=True,max_features=None,
17print(cm) Uday Ashish criterion='entropy')
classifier.fit(X_train, y_train) Execution output from Apr 9, 2020 6:16 PM
y_pred = classifier.predict(X_test)# Predicting the Test set results  Stream
cm = confusion_matrix(y_test, y_pred)# Making the Confusion Matrix  Testing Accuracy: 1.0
print("Testing Accuracy: ", classifier.score(X_test, y_test))  Training Accuracy: 1.0
print("Training Accuracy: ", classifier.score(X_train, y_train))  [[191 0 0 0 0]
print(cm)  [ 0 190 0 0 0]
 [ 0 0 183 0 0]
Testing Accuracy: 0.84375  [ 0 0 0 168 0]
Training Accuracy: 1.0  [ 0 0 0 0 169]]
[[124 11 3 14 4]

[ 6 143 4 3 6]
Code cell <ivTaMoK2BdfQ>
[ 5 6 141 7 3]
[ 15 8 9 128 3] #%% [code]
[ 4 2 3 9 139]] 1import pandas as pd
2from sklearn.model_selection import train_test_split
3from sklearn.ensemble import RandomForestClassifier
import pandas as pd
4from sklearn.metrics import confusion_matrix
from sklearn.model_selection import train_test_split
5df=pd.read_excel("/content/5 S21 xy.xlsx")
from sklearn.ensemble import RandomForestClassifier
6df = df.dropna()
from sklearn.metrics import confusion_matrix
7X=df.drop(columns="MOVEMENTS",axis=1)
df=pd.read_excel("/content/3 S21 final.xlsx")
8Y=df['MOVEMENTS']
df = df.dropna()
9X_train, X_test, y_train, y_test = train_test_split(X,Y
X=df.drop(columns="MOVEMENTS",axis=1)
10
Y=df['MOVEMENTS']
11classifier = RandomForestClassifier(n_estimators = 3500
X_train, X_test, y_train, y_test = train_test_split(X,Y, test_size = 0.2)
12select
This le was updated remotely or in another tab. To force a save, overwriting the last update, classifier.fit(X_train,
Save from the File y_train)
menu 13y pred = classifier.predict(X test)# Predicting the Tes
classifier = RandomForestClassifier(n estimators = 3500, random state = 1000,bootstrap=True,max features=None, criterion='entropy')
https://colab.research.google.com/drive/1y4n-z14XqrYcF5R8WKOHKeWFvUULnPW-#scrollTo=LR3V6qW-CUHZ 1/4
4/9/2020 Untitled2.ipynb - Colaboratory
classifier RandomForestClassifier(n_estimators 3500, random_state 1000,bootstrap True,max_features None, criterion entropy )
classifier.fit(X_train, y_train)
Revision
y_pred history
= classifier.predict(X_test)# Predicting the Test set results
cm = confusion_matrix(y_test, y_pred)# Making the Confusion Matrix
print("Testing Accuracy: ", classifier.score(X_test, y_test))
print("Training
Raw source Accuracy: ", classifier.score(X_train, y_train))
Inline diff Only show named versions
print(cm) 11classifier = RandomForestClassifier(n_estimators = 3500
12classifier.fit(X_train, y_train)
Testing Accuracy: 0.9966703662597114 13y_pred = classifier.predict(X_test)#
Unsaved changesPredicting the Tes
Training Accuracy: 0.9994450610432852
14cm = confusion_matrix(y_test, y_pred)# Making the Confu
[[311 0 0]
15print("Testing Accuracy: ", classifier.score(X_test, y_
[ 2 297 0]
[ 1 0 290]] 16print("Training Accuracy:
Apr", classifier.score(X_train,
9, 2020 6:13 PM
17print(cm) Uday Ashish
Execution output from Apr 9, 2020 6:16 PM
import pandas as pd Stream

from sklearn.model_selection import train_test_split Testing Accuracy: 1.0

from sklearn.ensemble import RandomForestClassifier Training Accuracy: 1.0

from sklearn.metrics import confusion_matrix [[191 0 0 0 0]

df=pd.read_excel("/content/5 S21 UPDATED.xlsx") [ 0 190 0 0 0]

df = df.dropna() [ 0 0 183 0 0]

X=df.drop(columns="MOVEMENTS",axis=1) [ 0 0 0 168 0]

Y=df['MOVEMENTS'] [ 0 0 0 0 169]]

X_train, X_test, y_train, y_test = train_test_split(X,Y, test_size = 0.2)

Code cell <ivTaMoK2BdfQ>
classifier = RandomForestClassifier(n_estimators = 3500, random_state = 1000,bootstrap=True,max_features=None, criterion='entropy')
#%% [code]
classifier.fit(X_train, y_train) 1import pandas as pd
y_pred = classifier.predict(X_test)# Predicting the Test set results 2from sklearn.model_selection import train_test_split
cm = confusion_matrix(y_test, y_pred)# Making the Confusion Matrix 3from sklearn.ensemble import RandomForestClassifier
print("Testing Accuracy: ", classifier.score(X_test, y_test)) 4from sklearn.metrics import confusion_matrix
print("Training Accuracy: ", classifier.score(X_train, y_train)) 5df=pd.read_excel("/content/5 S21 xy.xlsx")
print(cm) 6df = df.dropna()
7X=df.drop(columns="MOVEMENTS",axis=1)
8Y=df['MOVEMENTS']
9X_train, X_test, y_train, y_test = train_test_split(X,Y
10
11classifier = RandomForestClassifier(n_estimators = 3500
12select
This le was updated remotely or in another tab. To force a save, overwriting the last update, classifier.fit(X_train,
Save from the File y_train)
menu 13y pred = classifier.predict(X test)# Predicting the Tes
https://colab.research.google.com/drive/1y4n-z14XqrYcF5R8WKOHKeWFvUULnPW-#scrollTo=LR3V6qW-CUHZ 2/4
4/9/2020 Untitled2.ipynb - Colaboratory

Testing Accuracy: 1.0


Revision
import pandas as
Training history
pd
Accuracy: 1.0
from sklearn.model_selection
[[191 0 0 0 0] import train_test_split
[ 0 190 0
from sklearn.ensemble 0import
0] RandomForestClassifier
[ 0 0 183 0
from sklearn.metrics import 0] confusion_matrix
Raw[ source
0 0 0 Inline diff
168 0] S21 xy.xlsx") Only show named versions
df=pd.read_excel("/content/5
[ 0 0 0 0 169]] 11classifier = RandomForestClassifier(n_estimators = 3500
df = df.dropna()
12classifier.fit(X_train, y_train)
X=df.drop(columns="MOVEMENTS",axis=1)
13y_pred = classifier.predict(X_test)#
Unsaved changesPredicting the Tes
Y=df['MOVEMENTS']
14cm = confusion_matrix(y_test, y_pred)# Making the Confu
X_train, X_test, y_train, y_test = train_test_split(X,Y, test_size = 0.2)
15print("Testing Accuracy: ", classifier.score(X_test, y_
16print("Training Accuracy: Apr", classifier.score(X_train,
9, 2020 6:13 PM
classifier = RandomForestClassifier(n_estimators = 3500, random_state = 1000,bootstrap=True,max_features=None, criterion='entropy')
17print(cm) Uday Ashish
classifier.fit(X_train, y_train)
Execution output from Apr 9, 2020 6:16 PM
y_pred = classifier.predict(X_test)# Predicting the Test set results
 Stream
cm = confusion_matrix(y_test, y_pred)# Making the Confusion Matrix
 Testing Accuracy: 1.0
print("Testing Accuracy: ", classifier.score(X_test, y_test))
 Training Accuracy: 1.0
print("Training Accuracy: ", classifier.score(X_train, y_train))
 [[191 0 0 0 0]
print(cm)
 [ 0 190 0 0 0]
 [ 0 0 183 0 0]
Testing Accuracy: 0.9977802441731409
Training Accuracy: 1.0  [ 0 0 0 168 0]
[[176 0 0 0 0]  [ 0 0 0 0 169]]
[ 0 187 0 0 0] 
[ 0 0 156 0 0] Code cell <ivTaMoK2BdfQ>
[ 0 0 2 180 0] #%% [code]
[ 0 0 0 0 200]] 1import pandas as pd
2from sklearn.model_selection import train_test_split
import pandas as pd 3from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split 4from sklearn.metrics import confusion_matrix
from sklearn.ensemble import RandomForestClassifier 5df=pd.read_excel("/content/5 S21 xy.xlsx")
from sklearn.metrics import confusion_matrix 6df = df.dropna()
df=pd.read_excel("/content/5 S21 z.xlsx") 7X=df.drop(columns="MOVEMENTS",axis=1)
df = df.dropna() 8Y=df['MOVEMENTS']
X=df.drop(columns="MOVEMENTS",axis=1) 9X_train, X_test, y_train, y_test = train_test_split(X,Y
Y=df['MOVEMENTS'] 10
X_train, X_test, y_train, y_test = train_test_split(X,Y, test_size = 0.2) 11classifier = RandomForestClassifier(n_estimators = 3500
12select
This le was updated remotely or in another tab. To force a save, overwriting the last update, classifier.fit(X_train,
Save from the File y_train)
menu 13y pred = classifier.predict(X test)#
classifier = RandomForestClassifier(n_estimators = 3500, random_state = 1000,bootstrap=True,max_features=None, Predicting the Tes
criterion='entropy')
https://colab.research.google.com/drive/1y4n-z14XqrYcF5R8WKOHKeWFvUULnPW-#scrollTo=LR3V6qW-CUHZ 3/4
4/9/2020 Untitled2.ipynb - Colaboratory

classifier.fit(X_train, y_train)
Revision
y_pred history
= classifier.predict(X_test)# Predicting the Test set results
cm = confusion_matrix(y_test, y_pred)# Making the Confusion Matrix
print("Testing Accuracy: ", classifier.score(X_test, y_test))
print("Training Accuracy: ", classifier.score(X_train, y_train))
Raw source
print(cm) Inline diff Only show named versions
11classifier = RandomForestClassifier(n_estimators = 3500
Testing Accuracy: 0.9988901220865705 12classifier.fit(X_train, y_train)
Training Accuracy: 1.0 13y_pred = classifier.predict(X_test)#
Unsaved changesPredicting the Tes
[[160 0 0 0 0] 14cm = confusion_matrix(y_test, y_pred)# Making the Confu
[ 0 181 0 0 0] 15print("Testing Accuracy: ", classifier.score(X_test, y_
[ 0 0 189 0 0] 16print("Training Accuracy:
Apr", classifier.score(X_train,
9, 2020 6:13 PM
[ 0 0 0 178 0] 17print(cm) Uday Ashish
[ 1 0 0 0 192]] Execution output from Apr 9, 2020 6:16 PM
 Stream
 Testing Accuracy: 1.0
 Training Accuracy: 1.0
 [[191 0 0 0 0]
 [ 0 190 0 0 0]
 [ 0 0 183 0 0]
 [ 0 0 0 168 0]
 [ 0 0 0 0 169]]

Code
cell <ivTaMoK2BdfQ>
[code]#%%
1import pandas as pd
2from sklearn.model_selection import train_test_split
3from sklearn.ensemble import RandomForestClassifier
4from sklearn.metrics import confusion_matrix
5df=pd.read_excel("/content/5 S21 xy.xlsx")
6df = df.dropna()
7X=df.drop(columns="MOVEMENTS",axis=1)
8Y=df['MOVEMENTS']
9X_train, X_test, y_train, y_test = train_test_split(X,Y
10
11classifier = RandomForestClassifier(n_estimators = 3500
12select
This le was updated remotely or in another tab. To force a save, overwriting the last update, classifier.fit(X_train,
Save from the File y_train)
menu 13y pred = classifier.predict(X test)# Predicting the Tes
https://colab.research.google.com/drive/1y4n-z14XqrYcF5R8WKOHKeWFvUULnPW-#scrollTo=LR3V6qW-CUHZ 4/4

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy