Created
August 24, 2018 12:48
-
-
Save sam-thecoder/02d2d2f2954ce0aa1bdebe4502e8f7f7 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
from sklearn.ensemble import RandomForestClassifier | |
X = df[['Open', 'Max 7', 'Min 7', 'Change', 'Mean Change 7', 'Drop 7', 'Up 7']].values | |
y = df['Actual'].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) | |
# RandomForestClassifier(bootstrap=True, class_weight=None, criterion='gini', | |
# max_depth=2, max_features='auto', max_leaf_nodes=None, | |
# min_impurity_decrease=0.0, min_impurity_split=None, | |
# min_samples_leaf=1, min_samples_split=2, | |
# min_weight_fraction_leaf=0.0, n_estimators=10, n_jobs=1, | |
# oob_score=False, random_state=0, verbose=0, warm_start=False) | |
clf.score(X_test, y_test) | |
#0.9390862944162437 | |
df2 = pd.read_csv('data/AAPL-edited2.csv') | |
X2 = df2[['Open', 'Max 7', 'Min 7', 'Change', 'Mean Change 7', 'Drop 7', 'Up 7']].values | |
y2 = df2['Actual'].values | |
clf.score(X2, y2) | |
#0.4176334106728538 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment