Created
July 23, 2020 02:28
-
-
Save a-mitani/6d8f27381bd48004d2462cf98a6c6a12 to your computer and use it in GitHub Desktop.
用意したトイデータを学習&予測
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2) | |
lr = LinearRegression().fit(X_train, y_train) | |
y_pred_lr = lr.predict(X_test) | |
rf = RandomForestRegressor().fit(X_train, y_train) | |
y_pred_rf = rf.predict(X_test) | |
# 精度評価 | |
fig, ax = plt.subplots() | |
ax.plot([-6, 6], [-6, 6]) | |
ax.set_xlim([-6, 6]) | |
ax.scatter(y_test, y_pred_lr, alpha=0.5, label='Linear Regression') | |
ax.scatter(y_test, y_pred_rf, alpha=0.5, label='Random Forest') | |
ax.legend() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment