Class08 Answer:

Learn from the features

Generate predictions

Report effectiveness of predictions

I did this lab and it required some knowledge.

I wrote a script:


"""
f13.py

This script should learn and test.
Demo:
~/anaconda3/bin/python f13.py
"""

import numpy  as np
import pandas as pd

train_start_i = 50
train_end_i   = 5050
test_start_i  = 5052
test_end_i    = 6156
f13_df        = pd.read_csv('fx3/feat.csv')
data_a        = np.array(f13_df)[:,3:]
xtrain_a      = data_a[train_start_i:train_end_i]
xtest_a       = data_a[test_start_i:test_end_i  ]
ytrain_sr     = f13_df.piplead[train_start_i:train_end_i]
ytest_sr      = f13_df.piplead[test_start_i:test_end_i]
class_train_a = (ytrain_sr > 0.0)

# I should learn
from sklearn import linear_model
logr_model    = linear_model.LogisticRegression()
logr_model.fit(xtrain_a, class_train_a)

# I should predict
predictions_a = logr_model.predict_proba(xtest_a)[:,1]

# I should report
rpt_df = pd.DataFrame({'piplead':ytest_sr, 'prediction':predictions_a.tolist()})
rpt_df['eff'] = np.sign(rpt_df.prediction - 0.5) * rpt_df.piplead
print('Gain (in "pips") is:')
print(np.sum(rpt_df.eff))

'bye'

I ran it and saw this:


fx1@e80:~/Downloads$ 
fx1@e80:~/Downloads$ python f13.py 
Gain (in "pips") is:
233.18860000000004
fx1@e80:~/Downloads$ 
fx1@e80:~/Downloads$ 

I consider the above output to be strong evidence that I can generate predictive features from Forex data and then issue effective predictions.

Class08 Lab


learn4.us About Blog Contact Class01 Class02 Class03 Class04 Class05 Class06 Class07 Class08 Class09 Class10 dan101 Forum Google Hangout Vboxen