Random Forest
What is Random Forest?
Random forest is an ensemble learning method/technique for classification and regression tasks that operates by constructing a multitude of decision trees at training time.
For classification tasks, the output of the random forest is the class selected by most trees. For regression tasks, the mean or average prediction of the individual trees is returned.
Random Forest Classifier
Importing:
from sklearn.ensemble import RandomForestClassifier
Training the module:
clf = RandomForestClassifier(random_state=42)
# Creating a Random Forest classifier object
clf.fit(X_train, y_train)
# Training the classifier on the training data
Making predictions:
y_pred = clf.predict(X_test)
Last updated