“Random Forest Python” Code-Antworten

Sklearn Random Forest Regressor

from sklearn.ensemble import RandomForestRegressor


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

clf.fit(X, y)

print(clf.predict([[0, 0, 0, 0]]))
vcwild

Sklearn zufälliger Wald

from sklearn.ensemble import RandomForestClassifier


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

clf.fit(X, y)

print(clf.predict([[0, 0, 0, 0]]))
vcwild

Random Forest Python

from sklearn.ensemble import RandomForestClassifier

y = train_data["Survived"]

features = ["Pclass", "Sex", "SibSp", "Parch","Fare","Age"]
X = pd.get_dummies(train_data[features])
X_test = pd.get_dummies(test_data[features])

model = RandomForestClassifier(n_estimators=100, max_depth=5, random_state=1)
model.fit(X, y)
predictions = model.predict(X_test)
Misty Marten

Wie man zufälliger Baum in Python verwendet

from sklearn.ensemble import RandomForestRegressor

regressor = RandomForestRegressor(n_estimators=20, random_state=0)
regressor.fit(X_train, y_train)
y_pred = regressor.predict(X_test)
Wide-eyed Whale

Wie man zufälliger Baum in Python verwendet

from sklearn.model_selection import train_test_split

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=0)
Wide-eyed Whale

Ähnliche Antworten wie “Random Forest Python”

Fragen ähnlich wie “Random Forest Python”

Weitere verwandte Antworten zu “Random Forest Python” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen