在用逻辑回归进行训练的时候,打算训练十次,求评价指标的平均值,但是,我用下面的代码电脑内存直接炸了,怎么更改下面的代码能让我们电脑运行起来
mse_LogisticRegression = []
mae_LogisticRegression = []
r_LogisticRegression = []
for _ in range(10):
X_train, X_test, y_train, y_test = train_test_split(X, y, train_size=0.7)
modelLR = LogisticRegression()
modelLR.fit(X_train, y_train)
y_pred1 = modelLR.predict(X_test)
mse1 = mean_squared_error(y_test, y_pred1)
mae1 = mean_absolute_error(y_test, y_pred1)
r1 = r2_score(y_test, y_pred1)
mse_LogisticRegression.append(mse1)
mae_LogisticRegression.append(mae1)
r_LogisticRegression.append(r1)
print(np.mean(mse_LogisticRegression), np.mean(
mae_LogisticRegression), np.mean(r_LogisticRegression))