LogisticRegression逻辑斯特回归性能分析_学习曲线
LogisticRegression逻辑斯特回归性能分析_学习曲线 L2正则化 # 我们在乳腺癌数据集上详细分析 LogisticRegression from sklearn . datasets import load_breast_cancer cancer = load_breast_cancer ( ) X_train , X_test , y_train , y_test = train_test_split ( cancer . data , cancer . target , stratify = cancer . target , random_state = 42 ) logreg = LogisticRegression ( ) . fit ( X_train , y_train ) print ( "Training set score: {:.3f}" . format ( logreg . score ( X_train , y_train ) ) ) print ( "Test set score: {:.3f}" . format ( logreg . score ( X_test , y_test ) ) ) # C=1 的默认值给出了相当好的性能,在训练集和测试集上都达到 95% 的精度。但由于训练 # 集和测试集的性能非常接近