1from sklearn.ensemble import RandomForestRegressor
2
3
4clf = RandomForestRegressor(max_depth=2, random_state=0)
5
6clf.fit(X, y)
7
8print(clf.predict([[0, 0, 0, 0]]))
1from sklearn.model_selection import train_test_split
2
3X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=0)
4
1from sklearn.ensemble import RandomForestClassifier
2from sklearn.datasets import make_classification
3
4
5X, y = make_classification(n_samples=1000, n_features=4,
6 n_informative=2, n_redundant=0,
7 random_state=0, shuffle=False)
8clf = RandomForestClassifier(max_depth=2, random_state=0)
9
10clf.fit(X, y)
11
12print(clf.predict([[0, 0, 0, 0]]))