示例#1
0
import sys
from data.stock import Stock
from predictor import Predictor
from score import auc
from preprocess import Preprocess

submission_number = sys.argv[1]
print submission_number 

def submission(ids, preds):
    name = "submissions/submission{0}.csv".format(submission_number)
    f = open(name, 'w')
    if len(ids) != len(preds):
        raise Exception("The number of IDs and the number of predictions are different")
    string = 'id,prediction\n'
    for index,i in enumerate(ids):
        string += str(i) + ',' + str(preds[index]) + "\n"
    f.write(str(string))
    f.close()

data, targets, _ = Stock.train()
holdout_data, ids = Stock.test()
assert len(data) == len(targets)

Predictor.train(data, targets)
preds = Predictor.multi_predict(holdout_data)
print preds[0:50]
submission(ids, preds)
示例#2
0
from data.stock import Stock
from predictor import Predictor
from score import auc
from preprocess import Preprocess

data, targets, cv_targets = Stock.train()

#data = Preprocess.scale(data)
#cv_targets = Preprocess.scale(cv_targets)
#data = Preprocess.polynomial(data, 5)
half = len(data)/2
tr_data, holdout_data = data[:half], data[half:]
train_targets, holdout_targets = targets[:half], targets[half:]

Predictor.train(tr_data, train_targets)
preds = Predictor.multi_predict(holdout_data)
print 'AUC ', auc(preds, cv_targets)
print Predictor.multi_predict([[0.]])
print Predictor.multi_predict([[0.1]])
print Predictor.multi_predict([[-0.1]])
print Predictor.multi_predict([[0.01]])
print Predictor.multi_predict([[-0.01]])