You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I try your scripts and get 50% AUC. If I try it with reversed dataframe,it will works as expected as your results. Did I do something false in my codes?
import pandas as pd
import numpy as np
from Score import auc
from sklearn.ensemble import RandomForestClassifier,AdaBoostClassifier,VotingClassifier
from sklearn.metrics import accuracy_score,classification_report
def MakeDataframe(csv,reverse):
df = pd.read_csv(csv)
if reverse:
df = df[::-1]
df = df[['open','close']]
#print df.head(12)
return df.values
def Window(dataset):
dataX,dataY = [],[]
for i in range(len(dataset) - 9):
item = dataset[i:(i+10),0:2]
item = item.ravel()
if item[19] >= item[18]:
target = 1
else:
target = 0
dataY.append(target)
item = item[:19]
item = item / item[0]
dataX.append(item)
return np.array(dataX), np.array(dataY)
reverse = True
train = MakeDataframe('./CSV/EURUSD-2016-10-1W_1M.csv',reverse)
test = MakeDataframe('./CSV/EURUSD-2016-10-2W_1M.csv',reverse)
X,Y = Window(train)
X_test,Y_test = Window(test)
Y = Y.astype('int')
Y_test = Y_test.astype('int')
model = RandomForestClassifier(n_jobs=-1,n_estimators=100,oob_score=True,verbose=False)
#model2 = AdaBoostClassifier()
#model = VotingClassifier([('RF',model1),('Ada',model2)],n_jobs=-1,voting='soft')
model.fit(X,Y)
Y_pred = model.predict_proba(X_test)[:,1]
predicted = model.predict(X_test)
score = accuracy_score(Y_test,predicted)
report = classification_report(Y_test,predicted)
print score
print auc(Y_test,Y_pred)
print report
print model.oob_score_
Hi, I try your scripts and get 50% AUC. If I try it with reversed dataframe,it will works as expected as your results. Did I do something false in my codes?
I also attach two CSV files I used in the script.
Thank you so much and best regards
CSV.zip
The text was updated successfully, but these errors were encountered: