📜  最佳 alpha jupyter - Python 代码示例

📅  最后修改于: 2022-03-11 14:47:00.028000             🧑  作者: Mango

代码示例1
ridge2 = Ridge(alpha = 4, normalize = True)
ridge2.fit(X_train, y_train)             # Fit a ridge regression on the training data
pred2 = ridge2.predict(X_test)           # Use this model to predict the test data
print(pd.Series(ridge2.coef_, index = X.columns)) # Print coefficients
print(mean_squared_error(y_test, pred2))          # Calculate the test MSE