Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from itertools import product
- X_Reduced, X_Test_Reduced, Y_Reduced, Y_Test_Reduced = train_test_split(X_pca, Y,
- test_size = 0.30,
- random_state = 101)
- trainedforest = RandomForestClassifier(n_estimators=700).fit(X_Reduced,Y_Reduced)
- x_min, x_max = X_Reduced[:, 0].min() - 1, X_Reduced[:, 0].max() + 1
- y_min, y_max = X_Reduced[:, 1].min() - 1, X_Reduced[:, 1].max() + 1
- xx, yy = np.meshgrid(np.arange(x_min, x_max, 0.1), np.arange(y_min, y_max, 0.1))
- Z = trainedforest.predict(np.c_[xx.ravel(), yy.ravel()])
- Z = Z.reshape(xx.shape)
- plt.contourf(xx, yy, Z,cmap=plt.cm.coolwarm, alpha=0.4)
- plt.scatter(X_Reduced[:, 0], X_Reduced[:, 1], c=Y_Reduced, s=20, edgecolor='k')
- plt.xlabel('Principal Component 1', fontsize = 12)
- plt.ylabel('Principal Component 2', fontsize = 12)
- plt.title('Random Forest', fontsize = 15)
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement