Created
August 7, 2018 10:37
-
-
Save sam-thecoder/2e22e0d9b6aa87ee10317e2c724cb2dc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import pandas as pd | |
import numpy as np | |
from sklearn.model_selection import train_test_split | |
from sklearn.ensemble import RandomForestClassifier | |
df = pd.read_csv('data/BCHAIN.csv') | |
df_copy = df.copy() | |
#Not needed for prediction | |
df_copy.drop('Date', axis=1, inplace=True) | |
y = df_copy['Predict'].values | |
X = df_copy[['Value USD', 'Drop 7', 'Up 7', 'Mean Change 7', 'Change', 'Min 7', 'Max 7', 'Mean 7']].values | |
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.20, random_state=42) | |
clf = RandomForestClassifier(max_depth=2, random_state=0) | |
clf.fit(X_train, y_train) | |
clf.score(X_test, y_test) | |
#Results | |
#0.7915869980879541 | |
y = df_copy['Predict'].values | |
X = df_copy[['Value USD', 'Drop 7', 'Up 7', 'Mean Change 7', 'Change']].values | |
clf = RandomForestClassifier(max_depth=2, random_state=0) | |
clf.fit(X_train, y_train) | |
clf.score(X_test, y_test) | |
#Results | |
#0.9770554493307839 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment