clf = MLPClassifier(solver='lbfgs', alpha=1e-5, hidden_layer_sizes=(10, 10, 10), random_state=1) clf_trtr.fit(X_train, y_train) clftrtr_trainpred=clf_trtr.predict(X_train) clftrtr_testpred=clf_trtr.predict(X_test) clftrtr_trainR2=r2_score(y_train, clftrtr_trainpred) clftrtr_testpredtrtr_testR2=r2_score(y_test, clftrt_testpred) print('Train R-Squared for trtr is: ',clftrtr_trainR2) print('Test R-Squared for trtr is: ',clftrtr_testR2) clftrtr_trainR=pearsonr(y_train, clftrtr_trainpred) clftrtr_testR=pearsonr(y_test,clftrtr_testpred print('Train R for trtr is: ',clftrtr_trainR) print('Test R for trtr is: ',clftrtr_testR) clftrtr_trainRMSE=np.sqrt(mean_squared_error(y_train, clftrtr_trainpred)) clftrtr_testRMSE=np.sqrt(mean_squared_error(y_testclftrt_testpred) print('Train RMSE for trtr is: ',clftrtr_trainRMSE) print('Test RMSE for trtr is: ',clftrtr_testRMSE) clftrtr_trainMAE=mean_absolute_error(y_train, clftrtr_trainpred) clftrtr_testMAE=mean_absolute_error(y_test,clftrt_testpred print('Train MAE for trtr is: ',clftrtr_trainMAE) print('Test MAE for trtr is: ',clftrtr_testMAE) print('Aplpha20 train is: ', alpha(y_train, clftrtr_trainpred)) print('Aplpha20 test is: ', alpha(y_test,clftrt_testpred) print('MAPE train is: ', MAPE(y_train, clftrtr_trainpred)) print('MAPE test is: ', MAPE(y_test,clftrt_testpred)检查一下代码错误
时间: 2023-08-16 22:54:50 浏览: 100
gui-show.zip_GUI界面_gui 曲线_matlab gui-example_show
在你的代码中,有一些语法错误和拼写错误。这是一个修正后的版本:
```python
clf = MLPClassifier(solver='lbfgs', alpha=1e-5, hidden_layer_sizes=(10, 10, 10), random_state=1)
clf.fit(X_train, y_train)
clf_train_pred = clf.predict(X_train)
clf_test_pred = clf.predict(X_test)
clf_train_R2 = r2_score(y_train, clf_train_pred)
clf_test_R2 = r2_score(y_test, clf_test_pred)
print('Train R-Squared for clf is:', clf_train_R2)
print('Test R-Squared for clf is:', clf_test_R2)
clf_train_R = pearsonr(y_train, clf_train_pred)
clf_test_R = pearsonr(y_test, clf_test_pred)
print('Train R for clf is:', clf_train_R)
print('Test R for clf is:', clf_test_R)
clf_train_RMSE = np.sqrt(mean_squared_error(y_train, clf_train_pred))
clf_test_RMSE = np.sqrt(mean_squared_error(y_test, clf_test_pred))
print('Train RMSE for clf is:', clf_train_RMSE)
print('Test RMSE for clf is:', clf_test_RMSE)
clf_train_MAE = mean_absolute_error(y_train, clf_train_pred)
clf_test_MAE = mean_absolute_error(y_test, clf_test_pred)
print('Train MAE for clf is:', clf_train_MAE)
print('Test MAE for clf is:', clf_test_MAE)
print('Alpha 20 train is:', alpha(y_train, clf_train_pred))
print('Alpha 20 test is:', alpha(y_test, clf_test_pred))
print('MAPE train is:', MAPE(y_train, clf_train_pred))
print('MAPE test is:', MAPE(y_test, clf_test_pred))
```
请注意,你需要定义和实现 `alpha` 和 `MAPE` 函数来计算 `alpha 20` 和 `MAPE` 的值。
阅读全文