예제 #1
0
regr = MLPRegressor(random_state=0).fit(X_train, y_train)
y_pred = abs(regr.predict(X_test))

#Write out the prediction
pd.DataFrame(y_pred).to_csv("predicteddETest.csv", index=False)

# print results and make simple plot:
print('reg score: ', regr.score(X_test, y_test))
print('Mean Absolute Error:', metrics.mean_absolute_error(y_test, y_pred))
print('Mean Squared Error:', metrics.mean_squared_error(y_test, y_pred))
print('Root Mean Squared Error:',
      np.sqrt(metrics.mean_squared_error(y_test, y_pred)))
print('r2', np.sqrt(metrics.r2_score(y_test, y_pred)))

fig, ax = plt.subplots()
ax.scatter(y_test, y_pred)

lims = [
    np.min([ax.get_xlim(), ax.get_ylim()]),  # min of both axes
    np.max([ax.get_xlim(), ax.get_ylim()]),  # max of both axes
]

ax.plot(lims, lims, 'k-', alpha=0.75, zorder=0)
ax.set_aspect('equal')
ax.set_xlim(lims)
ax.set_ylim(lims)
plt.xlabel("Actual dE")
plt.ylabel("Predicted dE")
fig.show()
regr.plot_importance(regr, grid=False)