from sklearn.ensemble import RandomForestClassifier from sklearn.datasets import make_classification X, y = make_classification(n_features=4, random_state=0) clf = RandomForestClassifier(max_depth=2, random_state=0) clf.fit(X, y)
clf.predict([[0, 0, 0, 0]])
from sklearn.metrics import accuracy_score y_pred = clf.predict(X) accuracy = accuracy_score(y, y_pred)In summary, the RandomForestClassifier is a powerful machine learning algorithm that can be used for classification tasks. It is part of the sklearn.ensemble library in Python, which provides a suite of tools for building ensemble models.