我试图创建一个循环来找出装有 Ridge 回归模型的波士顿住房数据集的训练集和测试集的准确度分数的变化。
这是 for 循环:
for i in range(1,20):
Ridge(alpha = 1/(10**i)).fit(X_train,y_train)
它显示从 i=13 开始的警告。
警告是:
LinAlgWarning: Ill-conditioned matrix (rcond=6.45912e-17): result may not be accurate.
overwrite_a=True).T
这个警告的含义是什么?有可能摆脱它吗?
我检查了没有循环单独执行它,仍然没有帮助。
#importing libraries and packages
import mglearn
from sklearn.model_selection import train_test_split
from sklearn.linear_model import Ridge
#importing boston housing dataset from mglearn
X,y = mglearn.datasets.load_extended_boston()
#Splitting the dataset
X_train,X_test,y_train,y_test = train_test_split(X,y,random_state=0)
#Fitting the training data using Ridge model with alpha = 1/(10**13)
rd = Ridge(alpha = 1/(10**13)).fit(X_train,y_train)
对于 i 的任何值,不应显示上述警告。