End-to-End ML Project - California Housing

14 / 17

End to End ML Project - Train a Random Forest model

Now let's train a Random Forest model the same way we trained the Decision Tree model and see how it performs.

INSTRUCTIONS
  • Import the RandomForestRegressor class from Scikit-learn

    from sklearn.ensemble import <<your code goes here>>
    
    • Now let's train the model with our training data

      forest_reg = RandomForestRegressor(n_estimators=30, random_state=42)
      forest_reg.<<your code goes here>>(housing_prepared, housing_labels)
      
    • Now we will predict using out model

      housing_predictions = forest_reg.<<your code goes here>>(housing_prepared)
      
    • Finally, we will evaluate our model

      forest_mse = mean_squared_error(housing_labels, housing_predictions)
      forest_rmse = np.sqrt(forest_mse)
      forest_rmse
      
See Answer

No hints are availble for this assesment


Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...