Untitled
import pandas as pd from sklearn.metrics import mean_squared_error from sklearn.ensemble import RandomForestRegressor from sklearn.model_selection import train_test_split from sklearn.tree import DecisionTreeRegressor from sklearn.linear_model import LinearRegression # import model you picked from its module df = pd.read_csv('/datasets/train_data_us.csv') # initialize variables: features = df.drop(['last_price'],axis=1) target = df['last_price']/100000 final_model = RandomForestRegressor(random_state=54321,n_estimator=40,max_depth=40) # initialize constructor for model that had the best RMSE value final_model.fit(features,target) # train model on training set print("\nRMSE of the final model on the training set:", mean_squared_error(target, final_model.predict(features), squared=False))
Leave a Comment