机器学习sklearn库安装:
pip install numpy
pip install matplotlib
pip install scipy
pip install sklearn
注:直接利用anaconda软件,它是直接安装好了除sklearn库的其他库。
回归数据集
from sklearn.datasets import fetch_california_housing
X, y = fetch_california_housing(return_X_y=True)
分类数据集
from sklearn.datasets import load_iris
X, y = load_iris(return_X_y=True)
数据集切分
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, train_size=0.2)
模型保存与加载
pip install joblib
保存:
joblib.dump(value=model, filename="model_knn")
加载:
model = joblib.load(filename="model_knn")
|