5 Random Forest - Jupyter Notebook
5 Random Forest - Jupyter Notebook
...
...
In [7]: # Dividing the input and output variable for Training Dataset
X_train = iris_train.iloc[:,0:4]
X_train
y_train = iris_train.iloc[:,4]
y_train
...
...
In [10]: # X_train and X_test are the dataset for training and Testing
#y_train ,y_test are target predictor for Training and Testing Dataset
In [ ]: X_train,y_train,X_test,y_test
In [11]: # Fitting Random Forest Classification to the Training set
# 1 : Import required libraries and Method for RF
from sklearn.ensemble import RandomForestClassifier
# 2 : create an alogrithm using imported method name
classifier = RandomForestClassifier(n_estimators = 10, criterion = 'entropy')
# Train the model - Training Data (xtrain, ytrain)
classifier.fit(X_train, y_train)
...
In [12]: # Predicting the Test set results - only on input varabiles of dataset
y_pred = classifier.predict(X_test)
In [14]: print(classifier.feature_importances_)
...
In [16]: cm
...
In [18]: Accuracy_Score
...
In [ ]: