Answers for "import random forest model in python?"

0

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)
Posted by: Guest on August-04-2021

Code answers related to "import random forest model in python?"

Python Answers by Framework

Browse Popular Code Answers by Language