#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
import joblib | |
from sklearn.datasets import fetch_california_housing | |
from sklearn.model_selection import train_test_split | |
from sklearn.metrics import mean_squared_error | |
# Load the model from disk | |
loaded_model = joblib.load('bayesian_ridge.joblib') | |
# Set the random seed | |
random_seed = 0 | |
# Load the dataset | |
dataset = fetch_california_housing() | |
X, y = dataset.data, dataset.target | |
# Split the dataset into training and testing sets | |
_, X_test, _, y_test = train_test_split(X, y, test_size=0.25, random_state=random_seed) | |
print(f'X_test:\n{X_test[0]}') | |
print(f'y_test:\n{y_test[0]}') | |
# Use the model to make predictions on the test data | |
y_pred = loaded_model.predict(X_test) | |
print(f'y_pred:\n{y_pred[0]}') | |
# Score the model using mean squared error | |
mse = mean_squared_error(y_test, y_pred) | |
print(f'Mean Squared Error: {mse}') | |