Answers for "sklearn random forest classification"

8

sklearn random forest

from sklearn.ensemble import RandomForestClassifier


clf = RandomForestClassifier(max_depth=2, random_state=0)

clf.fit(X, y)

print(clf.predict([[0, 0, 0, 0]]))
Posted by: Guest on November-26-2020
0

sklearn random forest feature importance

from sklearn.datasets import make_classification
from sklearn.model_selection import train_test_split

X, y = make_classification(
    n_samples=1000, n_features=10, n_informative=3, n_redundant=0,
    n_repeated=0, n_classes=2, random_state=0, shuffle=False)
X_train, X_test, y_train, y_test = train_test_split(
    X, y, stratify=y, random_state=42)
Posted by: Guest on May-09-2021

Code answers related to "sklearn random forest classification"

Python Answers by Framework

Browse Popular Code Answers by Language