从我显示的负面结果来看,ridge.score()我猜我做错了什么。也许有人可以指出我正确的方向?
# Create a practice data set for exploring Ridge Regression
data_2 = np.array([[1, 2, 0], [3, 4, 1], [5, 6, 0], [1, 3, 1],
[3, 5, 1], [1, 7, 0], [1, 8, 1]], dtype=np.float64)
# Separate X and Y
x_2 = data_2[:, [0, 1]]
y_2 = data_2[:, 2]
# Train Test Split
x_2_train, x_2_test, y_2_train, y_2_test = train_test_split(x_2, y_2, random_state=0)
# Scale the training data
scaler_2 = StandardScaler()
scaler_2.fit(x_2_train)
x_2_transformed = scaler_2.transform(x_2_train)
# Ridge Regression
ridge_2 = Ridge().fit(x_2_transformed, y_2_train)
x_2_test_scaled = scaler_2.transform(x_2_test)
ridge_2.score(x_2_test_scaled, y_2_test)
输出为:-4.47
编辑:从阅读 scikit learn docs 这个值是 R价值。我想问题是,我们如何解释这个?