File size: 879 Bytes
b34166e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b32b0ba
 
b34166e
 
 
b32b0ba
b34166e
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/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('adaboost_regressor.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}')