#C12351. California Housing Price Prediction
California Housing Price Prediction
California Housing Price Prediction
Given the California Housing dataset, your task is to perform data preprocessing, train a linear regression model, and evaluate its performance.
The steps are as follows:
- Load the California Housing dataset.
- Split the data into training and testing sets using an 80:20 ratio with random_state = 42.
- Apply feature scaling to both training and testing data.
- Train a linear regression model on the scaled training set.
- Predict the target values on the test set and compute the evaluation metrics.
You will need to compute the following metrics:
- Mean Absolute Error (MAE): \(\frac{1}{n}\sum_{i=1}^{n}\left|y_i - \hat{y}_i\right|\)
- Mean Squared Error (MSE): \(\frac{1}{n}\sum_{i=1}^{n}(y_i - \hat{y}_i)^2\)
- R-squared Score (\(R^2\)): a measure of how well future samples are likely to be predicted
The program must read from standard input (stdin) even if the input is not used, and it should output the three computed metrics to standard output (stdout), each on its own line, formatted to six decimal places.
inputFormat
The input will be provided via standard input (stdin). The input can be empty or contain arbitrary data, but it is not used in the computation.
outputFormat
The output should consist of three lines. Each line must contain a floating point number formatted to six decimal places in the following order:
- Mean Absolute Error (MAE)
- Mean Squared Error (MSE)
- R-squared Score (\(R^2\))
0.529076
0.373450
0.650460
</p>