Download scikit-learn/catboost_regressor/predict.py from activeeon/models-repository: direct link, hf CLI and curl.
- Browser
- Download file 879 Bytes
-
https://huggingface.co/activeeon/models-repository/resolve/main/scikit-learn/catboost_regressor/predict.py
- Command line
-
hf download hf://activeeon/models-repository/scikit-learn/catboost_regressor/predict.py
-
curl -L -o predict.py https://huggingface.co/activeeon/models-repository/resolve/main/scikit-learn/catboost_regressor/predict.py
879 Bytes
| #!/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('catboost_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}') | |