#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
import joblib | |
from sklearn.datasets import fetch_california_housing | |
from sklearn.ensemble import AdaBoostRegressor | |
from sklearn.model_selection import train_test_split | |
# 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_train, _, y_train, _ = train_test_split(X, y, test_size=0.25, random_state=random_seed) | |
# Create and train the model | |
model = AdaBoostRegressor(n_estimators=100, random_state=random_seed) | |
model.fit(X_train, y_train) | |
# Save the trained model to disk | |
joblib.dump(model, 'adaboost_regressor.joblib') | |