003《Python数据分析、挖掘与可视化(第2版)》/岭回归分类.py
from sklearn.datasets import load_breast_cancer
from sklearn.linear_model import RidgeClassifier
from sklearn.model_selection import train_test_split

# 加载乳腺癌数据,共569个样本,每个样本有30个特征
X, y = load_breast_cancer(return_X_y=True)
# 使用默认参数创建岭回归分类器对象
clf = RidgeClassifier()
# 划分训练集与测试集
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)
# 使用训练集拟合模型
clf.fit(X_train, y_train)
# 使用测试集,评估模型得分
print(clf.score(X_test, y_test))