
************************
Score Pre-trained Models
************************

.. _installing-docdir:
Pre-trained Models
-------------------
Import the required modules for the regression::

    from sklearn.ensemble import RandomForestRegressor
    from sklearn.linear_model import LinearRegression
    from sklearn.metrics import mean_squared_error
    from sklearn.tree import DecisionTreeRegressor

Load the training dataset to train the models and test dataset to
score the pre-trained models. Write algorithms of pre-trained models 
fitted using the training datasets. Then use the test dataset to predict
values using the pre-trained model. Calculate the RSE score of each models
by analysing the predicted values and the actual values. 

linear regression::

    lin_reg = LinearRegression()
    lin_reg.fit(x_train, y_train)
    housing_predictions = lin_reg.predict(x_test)
    lin_mse = mean_squared_error(y_test, housing_predictions)


Decision Tree Regression::

    tree_reg = DecisionTreeRegressor()
    tree_reg.fit(x_train, y_train)
    housing_predictions = tree_reg.predict(x_test)
    tree_mse = mean_squared_error(y_test, housing_predictions)


Random Forest Regression::

    forest_reg = RandomForestRegressor()
    forest_reg.fit(x_train, y_train)
    forest_predictions = forest_reg.predict(x_test)
    forest_mse = mean_squared_error(y_test, forest_predictions)
