-
Notifications
You must be signed in to change notification settings - Fork 0
SelectModelStock
This time, you should classify a stock based on its own time series. A second time series may also be added; eg compare INTL & QQQ
- (previous min) percent change open
- (previous min) percent change high
- (previous min) percent change low
- (previous min) percent change close
- (previous min) percent change volume
- (previous min) percent change open-low
- (previous min) percent change open-close
- (previous min) percent change open-high
- (previous min) percent change low-close
- (previous min) percent change low-high
- (previous min) percent change close-high
- (current min) percent change open-low
- (current min) percent change open-close
- (current min) percent change open-high
- (current min) percent change low-close
- (current min) percent change low-high
- (current min) percent change close-high
- data set
- k range
- primary stock
- secondary stock (optional)
- iterations
- number of days
eg select_model_stock.py -d train_2012_12...h5 -k 5,10 -i 10 -d 20 -p INTL -s QQQ
Note:
- primary stock: INTL
- secondary stock (optional), eg QQQ
- number of days: select N days randomly from data set
- iterations: find average after N random trials
Using a simulated annealing cost function, calculate the scaling weights for all dimensions.
See Collective Intelligence, pg. 181 - 182 for details.
Weights should range from 0 - 1.0.
eg select_model.py -d train_2012_12...h5 -k 5,10 -i 10 -d 20
data set: train_2012_12...h5 k range: 5,10 iterations: 10 days: 20 scale: QQQ %open 1.0, INTL %open-low 0.9, ... INTL %volume 0. std dev error: 3.4% avg error: 12.5%
Please apply the traing data generated in PrepareData to the kNN algorithm outlined in Programming Collective Intelligence, ch. 8 .
I've uploaded the source code for the book, including the kNN code you'll need to work with.
You might find scikit-learn a useful library. You can use the book examples, a standard library or roll your own.
In this case we'll be classifying instead of predicting a value.