Professional Documents
Culture Documents
Random Forest - Py
Random Forest - Py
df = pd.read_excel("project.xlsx")
df.head()
X= df.iloc[:,0:3]
Yy1= df.iloc[:,3:5]
rand_clf=RandomForestRegressor(n_estimators = 1000,max_features='auto')
rand_clf.fit(X_train,Yy1_train)
yrand_pred=rand_clf.predict(X_test)
print('mean absolute error=',mean_absolute_error(Yy1_test,yrand_pred))
print('mean squared error=',mean_squared_error(Yy1_test,yrand_pred))
print('regression2_score=',r2_score(Yy1_test,yrand_pred))
print(rand_clf.predict([[19.661,123.26,344.97]]))