程序代写代做代考 compiler python stock-predict

stock-predict

In [22]:

import pandas as pd
import numpy as np
import pandas as pd
import numpy as np
from scipy import interp
import matplotlib.pyplot as plt
from sklearn.cross_validation import StratifiedKFold, KFold
from sklearn import linear_model
from sklearn import svm
from sklearn.metrics import roc_curve, auc

In [5]:

train = pd.read_csv(‘TrainingData.csv’)

/Users/vagrant/anaconda42/anaconda/lib/python2.7/site-packages/IPython/core/interactiveshell.py:2717: DtypeWarning: Columns (1,2,3,4) have mixed types. Specify dtype option on import or set low_memory=False.
interactivity=interactivity, compiler=compiler, result=result)

In [6]:

train

Out[6]:

Timestamp Variable142OPEN Variable142HIGH Variable142LOW Variable142LAST Variable143OPEN Variable143HIGH Variable143LOW Variable143LAST Variable144OPEN … Variable137LOW Variable137LAST_PRICE Variable139OPEN Variable139HIGH Variable139LOW Variable139LAST_PRICE Variable141OPEN Variable141HIGH Variable141LOW Variable141LAST_PRICE
0 40182.395833 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 21.061874 21.206487 41.041731 42.338085 41.041731 42.108253 2.133044 2.174362 2.117550 2.117550
1 40182.399306 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 21.206487 21.258134 42.108253 42.108253 41.881004 42.033364 2.117550 2.122715 2.117550 2.117550
2 40182.402778 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 21.268464 21.268464 42.033364 42.260614 41.803533 41.881004 2.122715 2.122715 2.112385 2.112385
3 40182.406250 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 21.268464 21.309782 42.033364 42.185725 42.033364 42.108253 2.122715 2.122715 2.099473 2.099473
4 40182.409722 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 21.278794 21.309782 42.108253 42.185725 42.033364 42.108253 2.099473 2.099473 2.094308 2.099473
5 40182.413194 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 21.309782 21.309782 42.033364 42.033364 41.881004 41.881004 2.099473 2.099473 2.089144 2.099473
6 40182.416667 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 21.278794 21.278794 41.803533 41.881004 41.728644 41.728644 2.089144 2.089144 2.083979 2.083979
7 40182.420139 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 21.309782 21.351100 41.728644 41.728644 41.651172 41.728644 2.083979 2.089144 2.083979 2.083979
8 40182.423611 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 21.351100 21.392418 41.728644 41.728644 41.651172 41.651172 2.083979 2.104638 2.083979 2.099473
9 40182.427083 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 21.330441 21.340771 41.651172 41.728644 41.498812 41.576283 2.099473 2.104638 2.099473 2.104638
10 40182.430556 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 21.340771 21.351100 41.576283 41.576283 41.423923 41.498812 2.104638 2.104638 2.099473 2.099473
11 40182.434028 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 21.351100 21.382089 41.423923 41.498812 41.423923 41.498812 2.099473 2.104638 2.099473 2.104638
12 40182.437500 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 21.382089 21.382089 41.423923 41.498812 41.423923 41.498812 2.107220 2.117550 2.107220 2.112385
13 40182.440972 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 21.382089 21.382089 41.498812 41.576283 41.498812 41.498812 2.112385 2.122715 2.112385 2.117550
14 40182.444444 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 21.371759 21.382089 41.498812 41.576283 41.498812 41.576283 2.117550 2.138209 2.117550 2.138209
15 40182.447917 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 21.371759 21.371759 41.576283 41.576283 41.498812 41.576283 2.143374 2.143374 2.133044 2.133044
16 40182.451389 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 21.361430 21.361430 41.576283 41.576283 41.576283 41.576283 2.133044 2.148538 2.133044 2.148538
17 40182.454861 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 21.361430 21.371759 41.576283 41.576283 41.498812 41.498812 2.148538 2.164033 2.143374 2.148538
18 40182.458333 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 21.340771 21.340771 41.498812 41.576283 41.498812 41.576283 2.148538 2.148538 2.148538 2.148538
19 40182.461806 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 21.320112 21.320112 41.576283 41.576283 41.576283 41.576283 2.148538 2.164033 2.148538 2.164033
20 40182.465278 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 21.299453 21.299453 41.576283 41.576283 41.498812 41.576283 2.164033 2.169197 2.164033 2.169197
21 40182.468750 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 21.268464 21.268464 41.498812 41.576283 41.498812 41.576283 2.169197 2.169197 2.169197 2.169197
22 40182.472222 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 21.268464 21.268464 41.423923 41.423923 41.346452 41.423923 2.169197 2.169197 2.164033 2.169197
23 40182.475694 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 21.185828 21.196157 41.423923 41.423923 41.346452 41.423923 2.169197 2.169197 2.169197 2.169197
24 40182.479167 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 21.185828 21.196157 41.423923 41.423923 41.271563 41.271563 2.169197 2.169197 2.169197 2.169197
25 40182.482639 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 21.165169 21.165169 41.271563 41.271563 41.194092 41.194092 2.169197 2.169197 2.164033 2.164033
26 40182.486111 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 21.165169 21.175498 41.194092 41.271563 41.194092 41.271563 2.164033 2.169197 2.164033 2.169197
27 40182.489583 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 21.154839 21.154839 41.271563 41.271563 41.271563 41.271563 2.169197 2.169197 2.169197 2.169197
28 40182.493056 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 21.154839 21.154839 41.271563 41.271563 41.194092 41.271563 2.169197 2.169197 2.169197 2.169197
29 40182.496528 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 21.134180 21.134180 41.271563 41.271563 41.194092 41.271563 2.169197 2.174362 2.169197 2.174362
… … … … … … … … … … … … … … … … … … … … … …
5892 40289.555556 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 23.662328 23.662328 47.363392 47.363392 47.285921 47.363392 3.767689 3.778019 3.762525 3.762525
5893 40289.559028 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 23.662328 23.693317 47.363392 47.363392 47.285921 47.363392 3.762525 3.772854 3.762525 3.772854
5894 40289.562500 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 23.713976 23.765623 47.363392 47.363392 47.285921 47.363392 3.772854 3.783184 3.772854 3.783184
5895 40289.565972 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 23.734635 23.734635 47.363392 47.515753 47.363392 47.515753 3.783184 3.783184 3.772854 3.778019
5896 40289.569444 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 23.734635 23.755294 47.515753 47.515753 47.438281 47.515753 3.778019 3.783184 3.772854 3.778019
5897 40289.572917 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 23.755294 23.817271 47.515753 47.668113 47.363392 47.668113 3.778019 3.793513 3.778019 3.783184
5898 40289.576389 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 23.817271 23.848259 47.668113 47.668113 47.590641 47.668113 3.783184 3.788348 3.783184 3.788348
5899 40289.579861 0 0 0 0 0.0 0.0 0.0 0.0 0.0 … 23.837930 23.848259 47.668113 47.743002 47.590641 47.743002 3.788348 3.793513 3.788348 3.793513
5900 40289.583333 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 23.817271 23.817271 47.743002 47.743002 47.668113 47.668113 3.793513 3.793513 3.783184 3.783184
5901 40289.586806 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 23.817271 23.817271 47.668113 47.743002 47.668113 47.668113 3.783184 3.783184 3.772854 3.772854
5902 40289.590278 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 23.796612 23.848259 47.668113 47.743002 47.668113 47.743002 3.772854 3.778019 3.767689 3.767689
5903 40289.593750 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 23.786282 23.806941 47.743002 47.743002 47.590641 47.590641 3.767689 3.772854 3.747030 3.747030
5904 40289.597222 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 23.744964 23.755294 47.668113 47.668113 47.438281 47.438281 3.747030 3.747030 3.736701 3.736701
5905 40289.600694 NaN NaN NaN NaN 0.0 0.0 0.0 0.0 NaN … 23.682987 23.682987 47.438281 47.438281 47.363392 47.363392 3.736701 3.736701 3.726371 3.731536
5906 40289.604167 0 0 0 0 0.0 0.0 0.0 0.0 NaN … 23.651999 23.662328 47.363392 47.363392 47.211032 47.285921 3.731536 3.741866 3.726371 3.741866
5907 40289.607639 NaN NaN NaN NaN NaN NaN NaN NaN 0.0 … 23.610681 23.641669 47.211032 47.285921 47.211032 47.211032 3.731536 3.731536 3.721206 3.726371
5908 40289.611111 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 23.641669 23.672658 47.211032 47.211032 47.133561 47.133561 3.726371 3.741866 3.726371 3.736701
5909 40289.614583 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 23.631340 23.713976 47.058672 47.133561 46.981200 46.981200 3.736701 3.741866 3.731536 3.741866
5910 40289.618056 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 23.713976 23.713976 46.981200 46.981200 46.906311 46.906311 3.741866 3.762525 3.741866 3.762525
5911 40289.621528 0 0 0 0 0.0 0.0 0.0 0.0 0.0 … 23.713976 23.786282 46.906311 46.906311 46.906311 46.906311 3.762525 3.767689 3.757360 3.767689
5912 40289.625000 NaN NaN NaN NaN 0.0 0.0 0.0 0.0 NaN … 23.755294 23.755294 47.133561 47.438281 47.133561 47.285921 3.767689 3.778019 3.757360 3.757360
5913 40289.628472 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 23.744964 23.765623 47.285921 47.438281 47.285921 47.438281 3.762525 3.767689 3.762525 3.767689
5914 40289.631944 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 23.662328 23.682987 47.438281 47.438281 47.363392 47.363392 3.767689 3.767689 3.762525 3.767689
5915 40289.635417 0 0 0 0 NaN NaN NaN NaN NaN … 23.682987 23.703646 47.438281 47.438281 47.363392 47.438281 3.767689 3.788348 3.767689 3.783184
5916 40289.638889 0 0 0 0 NaN NaN NaN NaN 0.0 … 23.693317 23.703646 47.438281 47.438281 47.363392 47.363392 3.783184 3.783184 3.762525 3.767689
5917 40289.642361 NaN NaN NaN NaN NaN NaN NaN NaN 0.0 … 23.682987 23.693317 47.363392 47.438281 47.285921 47.363392 3.767689 3.778019 3.767689 3.778019
5918 40289.645833 0 0 0 0 0.0 0.0 0.0 0.0 0.0 … 23.693317 23.744964 47.363392 47.515753 47.363392 47.438281 3.778019 3.783184 3.772854 3.783184
5919 40289.649306 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 23.755294 23.796612 47.515753 47.590641 47.363392 47.363392 3.788348 3.788348 3.783184 3.788348
5920 40289.652778 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 23.775953 23.920566 47.363392 47.438281 47.363392 47.438281 3.788348 3.793513 3.788348 3.793513
5921 40289.656250 NaN NaN NaN NaN NaN NaN NaN NaN NaN … 23.941225 23.941225 47.438281 47.438281 47.363392 47.363392 3.793513 3.793513 3.783184 3.783184

5922 rows × 610 columns

In [7]:

print train.columns

Index([u’Timestamp’, u’Variable142OPEN’, u’Variable142HIGH’, u’Variable142LOW’,
u’Variable142LAST’, u’Variable143OPEN’, u’Variable143HIGH’,
u’Variable143LOW’, u’Variable143LAST’, u’Variable144OPEN’,

u’Variable137LOW’, u’Variable137LAST_PRICE’, u’Variable139OPEN’,
u’Variable139HIGH’, u’Variable139LOW’, u’Variable139LAST_PRICE’,
u’Variable141OPEN’, u’Variable141HIGH’, u’Variable141LOW’,
u’Variable141LAST_PRICE’],
dtype=’object’, length=610)

In [8]:

np.array(train.columns)

Out[8]:

array([‘Timestamp’, ‘Variable142OPEN’, ‘Variable142HIGH’, ‘Variable142LOW’,
‘Variable142LAST’, ‘Variable143OPEN’, ‘Variable143HIGH’,
‘Variable143LOW’, ‘Variable143LAST’, ‘Variable144OPEN’,
‘Variable144HIGH’, ‘Variable144LOW’, ‘Variable144LAST’,
‘Variable145OPEN’, ‘Variable145HIGH’, ‘Variable145LOW’,
‘Variable145LAST’, ‘Variable146OPEN’, ‘Variable146HIGH’,
‘Variable146LOW’, ‘Variable146LAST’, ‘Variable147OPEN’,
‘Variable147HIGH’, ‘Variable147LOW’, ‘Variable147LAST’,
‘Variable148OPEN’, ‘Variable148HIGH’, ‘Variable148LOW’,
‘Variable148LAST’, ‘Variable149OPEN’, ‘Variable149HIGH’,
‘Variable149LOW’, ‘Variable149LAST’, ‘Variable150OPEN’,
‘Variable150HIGH’, ‘Variable150LOW’, ‘Variable150LAST’,
‘Variable151OPEN’, ‘Variable151HIGH’, ‘Variable151LOW’,
‘Variable151LAST’, ‘Variable152OPEN’, ‘Variable152HIGH’,
‘Variable152LOW’, ‘Variable152LAST’, ‘Variable153OPEN’,
‘Variable153HIGH’, ‘Variable153LOW’, ‘Variable153LAST’,
‘Variable154OPEN’, ‘Variable154HIGH’, ‘Variable154LOW’,
‘Variable154LAST’, ‘Variable155OPEN’, ‘Variable155HIGH’,
‘Variable155LOW’, ‘Variable155LAST’, ‘Variable156OPEN’,
‘Variable156HIGH’, ‘Variable156LOW’, ‘Variable156LAST’,
‘Variable157OPEN’, ‘Variable157HIGH’, ‘Variable157LOW’,
‘Variable157LAST’, ‘Variable158OPEN’, ‘Variable158HIGH’,
‘Variable158LOW’, ‘Variable158LAST’, ‘Variable159OPEN’,
‘Variable159HIGH’, ‘Variable159LOW’, ‘Variable159LAST’,
‘Variable160OPEN’, ‘Variable160HIGH’, ‘Variable160LOW’,
‘Variable160LAST’, ‘Variable161OPEN’, ‘Variable161HIGH’,
‘Variable161LOW’, ‘Variable161LAST’, ‘Variable162OPEN’,
‘Variable162HIGH’, ‘Variable162LOW’, ‘Variable162LAST’,
‘Variable163OPEN’, ‘Variable163HIGH’, ‘Variable163LOW’,
‘Variable163LAST’, ‘Variable164OPEN’, ‘Variable164HIGH’,
‘Variable164LOW’, ‘Variable164LAST’, ‘Variable165OPEN’,
‘Variable165HIGH’, ‘Variable165LOW’, ‘Variable165LAST’,
‘TargetVariable’, ‘Variable167OPEN’, ‘Variable167HIGH’,
‘Variable167LOW’, ‘Variable167LAST’, ‘Variable168OPEN’,
‘Variable168HIGH’, ‘Variable168LOW’, ‘Variable168LAST’,
‘Variable169OPEN’, ‘Variable169HIGH’, ‘Variable169LOW’,
‘Variable169LAST’, ‘Variable170OPEN’, ‘Variable170HIGH’,
‘Variable170LOW’, ‘Variable170LAST’, ‘Variable171OPEN’,
‘Variable171HIGH’, ‘Variable171LOW’, ‘Variable171LAST’,
‘Variable172OPEN’, ‘Variable172HIGH’, ‘Variable172LOW’,
‘Variable172LAST’, ‘Variable173OPEN’, ‘Variable173HIGH’,
‘Variable173LOW’, ‘Variable173LAST’, ‘Variable174OPEN’,
‘Variable174HIGH’, ‘Variable174LOW’, ‘Variable174LAST’,
‘Variable175OPEN’, ‘Variable175HIGH’, ‘Variable175LOW’,
‘Variable175LAST’, ‘Variable176OPEN’, ‘Variable176HIGH’,
‘Variable176LOW’, ‘Variable176LAST’, ‘Variable177OPEN’,
‘Variable177HIGH’, ‘Variable177LOW’, ‘Variable177LAST’,
‘Variable178OPEN’, ‘Variable178HIGH’, ‘Variable178LOW’,
‘Variable178LAST’, ‘Variable179OPEN’, ‘Variable179HIGH’,
‘Variable179LOW’, ‘Variable179LAST’, ‘Variable180OPEN’,
‘Variable180HIGH’, ‘Variable180LOW’, ‘Variable180LAST’,
‘Variable8OPEN’, ‘Variable8HIGH’, ‘Variable8LOW’,
‘Variable8LAST_PRICE’, ‘Variable9OPEN’, ‘Variable9HIGH’,
‘Variable9LOW’, ‘Variable9LAST_PRICE’, ‘Variable10OPEN’,
‘Variable10HIGH’, ‘Variable10LOW’, ‘Variable10LAST_PRICE’,
‘Variable11OPEN’, ‘Variable11HIGH’, ‘Variable11LOW’,
‘Variable11LAST_PRICE’, ‘Variable12OPEN’, ‘Variable12HIGH’,
‘Variable12LOW’, ‘Variable12LAST_PRICE’, ‘Variable13OPEN’,
‘Variable13HIGH’, ‘Variable13LOW’, ‘Variable13LAST_PRICE’,
‘Variable14OPEN’, ‘Variable14HIGH’, ‘Variable14LOW’,
‘Variable14LAST_PRICE’, ‘Variable15OPEN’, ‘Variable15HIGH’,
‘Variable15LOW’, ‘Variable15LAST_PRICE’, ‘Variable17OPEN’,
‘Variable17HIGH’, ‘Variable17LOW’, ‘Variable17LAST_PRICE’,
‘Variable18OPEN’, ‘Variable18HIGH’, ‘Variable18LOW’,
‘Variable18LAST_PRICE’, ‘Variable19OPEN’, ‘Variable19HIGH’,
‘Variable19LOW’, ‘Variable19LAST_PRICE’, ‘Variable20OPEN’,
‘Variable20HIGH’, ‘Variable20LOW’, ‘Variable20LAST_PRICE’,
‘Variable21OPEN’, ‘Variable21HIGH’, ‘Variable21LOW’,
‘Variable21LAST_PRICE’, ‘Variable22OPEN’, ‘Variable22HIGH’,
‘Variable22LOW’, ‘Variable22LAST_PRICE’, ‘Variable23OPEN’,
‘Variable23HIGH’, ‘Variable23LOW’, ‘Variable23LAST_PRICE’,
‘Variable24OPEN’, ‘Variable24HIGH’, ‘Variable24LOW’,
‘Variable24LAST_PRICE’, ‘Variable25OPEN’, ‘Variable25HIGH’,
‘Variable25LOW’, ‘Variable25LAST_PRICE’, ‘Variable26OPEN’,
‘Variable26HIGH’, ‘Variable26LOW’, ‘Variable26LAST_PRICE’,
‘Variable27OPEN’, ‘Variable27HIGH’, ‘Variable27LOW’,
‘Variable27LAST_PRICE’, ‘Variable28OPEN’, ‘Variable28HIGH’,
‘Variable28LOW’, ‘Variable28LAST_PRICE’, ‘Variable29OPEN’,
‘Variable29HIGH’, ‘Variable29LOW’, ‘Variable29LAST_PRICE’,
‘Variable30OPEN’, ‘Variable30HIGH’, ‘Variable30LOW’,
‘Variable30LAST_PRICE’, ‘Variable31OPEN’, ‘Variable31HIGH’,
‘Variable31LOW’, ‘Variable31LAST_PRICE’, ‘Variable32OPEN’,
‘Variable32HIGH’, ‘Variable32LOW’, ‘Variable32LAST_PRICE’,
‘Variable33OPEN’, ‘Variable33HIGH’, ‘Variable33LOW’,
‘Variable33LAST_PRICE’, ‘Variable34OPEN’, ‘Variable34HIGH’,
‘Variable34LOW’, ‘Variable34LAST_PRICE’, ‘Variable35OPEN’,
‘Variable35HIGH’, ‘Variable35LOW’, ‘Variable35LAST_PRICE’,
‘Variable36OPEN’, ‘Variable36HIGH’, ‘Variable36LOW’,
‘Variable36LAST_PRICE’, ‘Variable37OPEN’, ‘Variable37HIGH’,
‘Variable37LOW’, ‘Variable37LAST_PRICE’, ‘Variable38OPEN’,
‘Variable38HIGH’, ‘Variable38LOW’, ‘Variable38LAST_PRICE’,
‘Variable40OPEN’, ‘Variable40HIGH’, ‘Variable40LOW’,
‘Variable40LAST_PRICE’, ‘Variable41OPEN’, ‘Variable41HIGH’,
‘Variable41LOW’, ‘Variable41LAST_PRICE’, ‘Variable42OPEN’,
‘Variable42HIGH’, ‘Variable42LOW’, ‘Variable42LAST_PRICE’,
‘Variable43OPEN’, ‘Variable43HIGH’, ‘Variable43LOW’,
‘Variable43LAST_PRICE’, ‘Variable44OPEN’, ‘Variable44HIGH’,
‘Variable44LOW’, ‘Variable44LAST_PRICE’, ‘Variable45OPEN’,
‘Variable45HIGH’, ‘Variable45LOW’, ‘Variable45LAST_PRICE’,
‘Variable46OPEN’, ‘Variable46HIGH’, ‘Variable46LOW’,
‘Variable46LAST_PRICE’, ‘Variable47OPEN’, ‘Variable47HIGH’,
‘Variable47LOW’, ‘Variable47LAST_PRICE’, ‘Variable48OPEN’,
‘Variable48HIGH’, ‘Variable48LOW’, ‘Variable48LAST_PRICE’,
‘Variable49OPEN’, ‘Variable49HIGH’, ‘Variable49LOW’,
‘Variable49LAST_PRICE’, ‘Variable50OPEN’, ‘Variable50HIGH’,
‘Variable50LOW’, ‘Variable50LAST_PRICE’, ‘Variable51OPEN’,
‘Variable51HIGH’, ‘Variable51LOW’, ‘Variable51LAST_PRICE’,
‘Variable52OPEN’, ‘Variable52HIGH’, ‘Variable52LOW’,
‘Variable52LAST_PRICE’, ‘Variable53OPEN’, ‘Variable53HIGH’,
‘Variable53LOW’, ‘Variable53LAST_PRICE’, ‘Variable54OPEN’,
‘Variable54HIGH’, ‘Variable54LOW’, ‘Variable54LAST_PRICE’,
‘Variable55OPEN’, ‘Variable55HIGH’, ‘Variable55LOW’,
‘Variable55LAST_PRICE’, ‘Variable56OPEN’, ‘Variable56HIGH’,
‘Variable56LOW’, ‘Variable56LAST_PRICE’, ‘Variable57OPEN’,
‘Variable57HIGH’, ‘Variable57LOW’, ‘Variable57LAST_PRICE’,
‘Variable58OPEN’, ‘Variable58HIGH’, ‘Variable58LOW’,
‘Variable58LAST_PRICE’, ‘Variable59OPEN’, ‘Variable59HIGH’,
‘Variable59LOW’, ‘Variable59LAST_PRICE’, ‘Variable60OPEN’,
‘Variable60HIGH’, ‘Variable60LOW’, ‘Variable60LAST_PRICE’,
‘Variable61OPEN’, ‘Variable61HIGH’, ‘Variable61LOW’,
‘Variable61LAST_PRICE’, ‘Variable62OPEN’, ‘Variable62HIGH’,
‘Variable62LOW’, ‘Variable62LAST_PRICE’, ‘Variable63OPEN’,
‘Variable63HIGH’, ‘Variable63LOW’, ‘Variable63LAST_PRICE’,
‘Variable64OPEN’, ‘Variable64HIGH’, ‘Variable64LOW’,
‘Variable64LAST_PRICE’, ‘Variable65OPEN’, ‘Variable65HIGH’,
‘Variable65LOW’, ‘Variable65LAST_PRICE’, ‘Variable68OPEN’,
‘Variable68HIGH’, ‘Variable68LOW’, ‘Variable68LAST_PRICE’,
‘Variable69OPEN’, ‘Variable69HIGH’, ‘Variable69LOW’,
‘Variable69LAST_PRICE’, ‘Variable70OPEN’, ‘Variable70HIGH’,
‘Variable70LOW’, ‘Variable70LAST_PRICE’, ‘Variable71OPEN’,
‘Variable71HIGH’, ‘Variable71LOW’, ‘Variable71LAST_PRICE’,
‘Variable72OPEN’, ‘Variable72HIGH’, ‘Variable72LOW’,
‘Variable72LAST_PRICE’, ‘Variable73OPEN’, ‘Variable73HIGH’,
‘Variable73LOW’, ‘Variable73LAST_PRICE’, ‘Variable74OPEN’,
‘Variable74HIGH’, ‘Variable74LOW’, ‘Variable74LAST_PRICE’,
‘Variable76OPEN’, ‘Variable76HIGH’, ‘Variable76LOW’,
‘Variable76LAST_PRICE’, ‘Variable77OPEN’, ‘Variable77HIGH’,
‘Variable77LOW’, ‘Variable77LAST_PRICE’, ‘Variable78OPEN’,
‘Variable78HIGH’, ‘Variable78LOW’, ‘Variable78LAST_PRICE’,
‘Variable79OPEN’, ‘Variable79HIGH’, ‘Variable79LOW’,
‘Variable79LAST_PRICE’, ‘Variable80OPEN’, ‘Variable80HIGH’,
‘Variable80LOW’, ‘Variable80LAST_PRICE’, ‘Variable81OPEN’,
‘Variable81HIGH’, ‘Variable81LOW’, ‘Variable81LAST_PRICE’,
‘Variable82OPEN’, ‘Variable82HIGH’, ‘Variable82LOW’,
‘Variable82LAST_PRICE’, ‘Variable83OPEN’, ‘Variable83HIGH’,
‘Variable83LOW’, ‘Variable83LAST_PRICE’, ‘Variable85OPEN’,
‘Variable85HIGH’, ‘Variable85LOW’, ‘Variable85LAST_PRICE’,
‘Variable86OPEN’, ‘Variable86HIGH’, ‘Variable86LOW’,
‘Variable86LAST_PRICE’, ‘Variable87OPEN’, ‘Variable87HIGH’,
‘Variable87LOW’, ‘Variable87LAST_PRICE’, ‘Variable88OPEN’,
‘Variable88HIGH’, ‘Variable88LOW’, ‘Variable88LAST_PRICE’,
‘Variable89OPEN’, ‘Variable89HIGH’, ‘Variable89LOW’,
‘Variable89LAST_PRICE’, ‘Variable90OPEN’, ‘Variable90HIGH’,
‘Variable90LOW’, ‘Variable90LAST_PRICE’, ‘Variable91OPEN’,
‘Variable91HIGH’, ‘Variable91LOW’, ‘Variable91LAST_PRICE’,
‘Variable92OPEN’, ‘Variable92HIGH’, ‘Variable92LOW’,
‘Variable92LAST_PRICE’, ‘Variable93OPEN’, ‘Variable93HIGH’,
‘Variable93LOW’, ‘Variable93LAST_PRICE’, ‘Variable94OPEN’,
‘Variable94HIGH’, ‘Variable94LOW’, ‘Variable94LAST_PRICE’,
‘Variable95OPEN’, ‘Variable95HIGH’, ‘Variable95LOW’,
‘Variable95LAST_PRICE’, ‘Variable97OPEN’, ‘Variable97HIGH’,
‘Variable97LOW’, ‘Variable97LAST_PRICE’, ‘Variable98OPEN’,
‘Variable98HIGH’, ‘Variable98LOW’, ‘Variable98LAST_PRICE’,
‘Variable99OPEN’, ‘Variable99HIGH’, ‘Variable99LOW’,
‘Variable99LAST_PRICE’, ‘Variable100OPEN’, ‘Variable100HIGH’,
‘Variable100LOW’, ‘Variable100LAST_PRICE’, ‘Variable101OPEN’,
‘Variable101HIGH’, ‘Variable101LOW’, ‘Variable101LAST_PRICE’,
‘Variable102OPEN’, ‘Variable102HIGH’, ‘Variable102LOW’,
‘Variable102LAST_PRICE’, ‘Variable103OPEN’, ‘Variable103HIGH’,
‘Variable103LOW’, ‘Variable103LAST_PRICE’, ‘Variable105OPEN’,
‘Variable105HIGH’, ‘Variable105LOW’, ‘Variable105LAST_PRICE’,
‘Variable107OPEN’, ‘Variable107HIGH’, ‘Variable107LOW’,
‘Variable107LAST_PRICE’, ‘Variable108OPEN’, ‘Variable108HIGH’,
‘Variable108LOW’, ‘Variable108LAST_PRICE’, ‘Variable109OPEN’,
‘Variable109HIGH’, ‘Variable109LOW’, ‘Variable109LAST_PRICE’,
‘Variable111OPEN’, ‘Variable111HIGH’, ‘Variable111LOW’,
‘Variable111LAST_PRICE’, ‘Variable112OPEN’, ‘Variable112HIGH’,
‘Variable112LOW’, ‘Variable112LAST_PRICE’, ‘Variable113OPEN’,
‘Variable113HIGH’, ‘Variable113LOW’, ‘Variable113LAST_PRICE’,
‘Variable114OPEN’, ‘Variable114HIGH’, ‘Variable114LOW’,
‘Variable114LAST_PRICE’, ‘Variable115OPEN’, ‘Variable115HIGH’,
‘Variable115LOW’, ‘Variable115LAST_PRICE’, ‘Variable116OPEN’,
‘Variable116HIGH’, ‘Variable116LOW’, ‘Variable116LAST_PRICE’,
‘Variable117OPEN’, ‘Variable117HIGH’, ‘Variable117LOW’,
‘Variable117LAST_PRICE’, ‘Variable120OPEN’, ‘Variable120HIGH’,
‘Variable120LOW’, ‘Variable120LAST_PRICE’, ‘Variable121OPEN’,
‘Variable121HIGH’, ‘Variable121LOW’, ‘Variable121LAST_PRICE’,
‘Variable123OPEN’, ‘Variable123HIGH’, ‘Variable123LOW’,
‘Variable123LAST_PRICE’, ‘Variable124OPEN’, ‘Variable124HIGH’,
‘Variable124LOW’, ‘Variable124LAST_PRICE’, ‘Variable125OPEN’,
‘Variable125HIGH’, ‘Variable125LOW’, ‘Variable125LAST_PRICE’,
‘Variable126OPEN’, ‘Variable126HIGH’, ‘Variable126LOW’,
‘Variable126LAST_PRICE’, ‘Variable127OPEN’, ‘Variable127HIGH’,
‘Variable127LOW’, ‘Variable127LAST_PRICE’, ‘Variable129OPEN’,
‘Variable129HIGH’, ‘Variable129LOW’, ‘Variable129LAST_PRICE’,
‘Variable130OPEN’, ‘Variable130HIGH’, ‘Variable130LOW’,
‘Variable130LAST_PRICE’, ‘Variable133OPEN’, ‘Variable133HIGH’,
‘Variable133LOW’, ‘Variable133LAST_PRICE’, ‘Variable136OPEN’,
‘Variable136HIGH’, ‘Variable136LOW’, ‘Variable136LAST_PRICE’,
‘Variable137OPEN’, ‘Variable137HIGH’, ‘Variable137LOW’,
‘Variable137LAST_PRICE’, ‘Variable139OPEN’, ‘Variable139HIGH’,
‘Variable139LOW’, ‘Variable139LAST_PRICE’, ‘Variable141OPEN’,
‘Variable141HIGH’, ‘Variable141LOW’, ‘Variable141LAST_PRICE’], dtype=object)

In [9]:

train[‘TargetVariable’]

Out[9]:

0 1
1 1
2 1
3 1
4 0
5 1
6 0
7 0
8 0
9 0
10 0
11 1
12 1
13 1
14 1
15 1
16 1
17 1
18 1
19 1
20 1
21 1
22 1
23 1
24 1
25 1
26 1
27 0
28 1
29 1
..
5892 1
5893 1
5894 1
5895 1
5896 1
5897 1
5898 1
5899 1
5900 1
5901 1
5902 1
5903 1
5904 0
5905 0
5906 0
5907 0
5908 0
5909 0
5910 0
5911 0
5912 1
5913 1
5914 1
5915 1
5916 1
5917 1
5918 1
5919 1
5920 1
5921 1
Name: TargetVariable, dtype: int64

In [10]:

test = pd.read_csv(‘ResultData.csv’)

In [11]:

allExist = ~(train.isnull().any())

In [12]:

test.columns.shape

Out[12]:

(609,)

In [13]:

train.columns.shape

Out[13]:

(610,)

In [14]:

testAllExist = ~(test.isnull().any())

In [15]:

cols = []

for colname in test.columns:
if allExist[colname] and testAllExist[colname]:
cols.append(colname)

cols

Out[15]:

[‘Timestamp’,
‘Variable159OPEN’,
‘Variable159HIGH’,
‘Variable159LOW’,
‘Variable159LAST’,
‘Variable164OPEN’,
‘Variable164HIGH’,
‘Variable164LOW’,
‘Variable164LAST’,
‘Variable8OPEN’,
‘Variable8HIGH’,
‘Variable8LOW’,
‘Variable8LAST_PRICE’,
‘Variable9OPEN’,
‘Variable9HIGH’,
‘Variable9LOW’,
‘Variable9LAST_PRICE’,
‘Variable10OPEN’,
‘Variable10HIGH’,
‘Variable10LOW’,
‘Variable10LAST_PRICE’,
‘Variable11OPEN’,
‘Variable11HIGH’,
‘Variable11LOW’,
‘Variable11LAST_PRICE’,
‘Variable12OPEN’,
‘Variable12HIGH’,
‘Variable12LOW’,
‘Variable12LAST_PRICE’,
‘Variable13OPEN’,
‘Variable13HIGH’,
‘Variable13LOW’,
‘Variable13LAST_PRICE’,
‘Variable14OPEN’,
‘Variable14HIGH’,
‘Variable14LOW’,
‘Variable14LAST_PRICE’,
‘Variable15OPEN’,
‘Variable15HIGH’,
‘Variable15LOW’,
‘Variable15LAST_PRICE’,
‘Variable17OPEN’,
‘Variable17HIGH’,
‘Variable17LOW’,
‘Variable17LAST_PRICE’,
‘Variable18OPEN’,
‘Variable18HIGH’,
‘Variable18LOW’,
‘Variable18LAST_PRICE’,
‘Variable19OPEN’,
‘Variable19HIGH’,
‘Variable19LOW’,
‘Variable19LAST_PRICE’,
‘Variable20OPEN’,
‘Variable20HIGH’,
‘Variable20LOW’,
‘Variable20LAST_PRICE’,
‘Variable21OPEN’,
‘Variable21HIGH’,
‘Variable21LOW’,
‘Variable21LAST_PRICE’,
‘Variable22OPEN’,
‘Variable22HIGH’,
‘Variable22LOW’,
‘Variable22LAST_PRICE’,
‘Variable23OPEN’,
‘Variable23HIGH’,
‘Variable23LOW’,
‘Variable23LAST_PRICE’,
‘Variable24OPEN’,
‘Variable24HIGH’,
‘Variable24LOW’,
‘Variable24LAST_PRICE’,
‘Variable25OPEN’,
‘Variable25HIGH’,
‘Variable25LOW’,
‘Variable25LAST_PRICE’,
‘Variable26OPEN’,
‘Variable26HIGH’,
‘Variable26LOW’,
‘Variable26LAST_PRICE’,
‘Variable27OPEN’,
‘Variable27HIGH’,
‘Variable27LOW’,
‘Variable27LAST_PRICE’,
‘Variable28OPEN’,
‘Variable28HIGH’,
‘Variable28LOW’,
‘Variable28LAST_PRICE’,
‘Variable29OPEN’,
‘Variable29HIGH’,
‘Variable29LOW’,
‘Variable29LAST_PRICE’,
‘Variable30OPEN’,
‘Variable30HIGH’,
‘Variable30LOW’,
‘Variable30LAST_PRICE’,
‘Variable31OPEN’,
‘Variable31HIGH’,
‘Variable31LOW’,
‘Variable31LAST_PRICE’,
‘Variable32OPEN’,
‘Variable32HIGH’,
‘Variable32LOW’,
‘Variable32LAST_PRICE’,
‘Variable33OPEN’,
‘Variable33HIGH’,
‘Variable33LOW’,
‘Variable33LAST_PRICE’,
‘Variable34OPEN’,
‘Variable34HIGH’,
‘Variable34LOW’,
‘Variable34LAST_PRICE’,
‘Variable35OPEN’,
‘Variable35HIGH’,
‘Variable35LOW’,
‘Variable35LAST_PRICE’,
‘Variable36OPEN’,
‘Variable36HIGH’,
‘Variable36LOW’,
‘Variable36LAST_PRICE’,
‘Variable37OPEN’,
‘Variable37HIGH’,
‘Variable37LOW’,
‘Variable37LAST_PRICE’,
‘Variable38OPEN’,
‘Variable38HIGH’,
‘Variable38LOW’,
‘Variable38LAST_PRICE’,
‘Variable40OPEN’,
‘Variable40HIGH’,
‘Variable40LOW’,
‘Variable40LAST_PRICE’,
‘Variable41OPEN’,
‘Variable41HIGH’,
‘Variable41LOW’,
‘Variable41LAST_PRICE’,
‘Variable42OPEN’,
‘Variable42HIGH’,
‘Variable42LOW’,
‘Variable42LAST_PRICE’,
‘Variable43OPEN’,
‘Variable43HIGH’,
‘Variable43LOW’,
‘Variable43LAST_PRICE’,
‘Variable44OPEN’,
‘Variable44HIGH’,
‘Variable44LOW’,
‘Variable44LAST_PRICE’,
‘Variable45OPEN’,
‘Variable45HIGH’,
‘Variable45LOW’,
‘Variable45LAST_PRICE’,
‘Variable46OPEN’,
‘Variable46HIGH’,
‘Variable46LOW’,
‘Variable46LAST_PRICE’,
‘Variable47OPEN’,
‘Variable47HIGH’,
‘Variable47LOW’,
‘Variable47LAST_PRICE’,
‘Variable48OPEN’,
‘Variable48HIGH’,
‘Variable48LOW’,
‘Variable48LAST_PRICE’,
‘Variable49OPEN’,
‘Variable49HIGH’,
‘Variable49LOW’,
‘Variable49LAST_PRICE’,
‘Variable50OPEN’,
‘Variable50HIGH’,
‘Variable50LOW’,
‘Variable50LAST_PRICE’,
‘Variable51OPEN’,
‘Variable51HIGH’,
‘Variable51LOW’,
‘Variable51LAST_PRICE’,
‘Variable52OPEN’,
‘Variable52HIGH’,
‘Variable52LOW’,
‘Variable52LAST_PRICE’,
‘Variable53OPEN’,
‘Variable53HIGH’,
‘Variable53LOW’,
‘Variable53LAST_PRICE’,
‘Variable54OPEN’,
‘Variable54HIGH’,
‘Variable54LOW’,
‘Variable54LAST_PRICE’,
‘Variable55OPEN’,
‘Variable55HIGH’,
‘Variable55LOW’,
‘Variable55LAST_PRICE’,
‘Variable56OPEN’,
‘Variable56HIGH’,
‘Variable56LOW’,
‘Variable56LAST_PRICE’,
‘Variable57OPEN’,
‘Variable57HIGH’,
‘Variable57LOW’,
‘Variable57LAST_PRICE’,
‘Variable58OPEN’,
‘Variable58HIGH’,
‘Variable58LOW’,
‘Variable58LAST_PRICE’,
‘Variable59OPEN’,
‘Variable59HIGH’,
‘Variable59LOW’,
‘Variable59LAST_PRICE’,
‘Variable60OPEN’,
‘Variable60HIGH’,
‘Variable60LOW’,
‘Variable60LAST_PRICE’,
‘Variable61OPEN’,
‘Variable61HIGH’,
‘Variable61LOW’,
‘Variable61LAST_PRICE’,
‘Variable62OPEN’,
‘Variable62HIGH’,
‘Variable62LOW’,
‘Variable62LAST_PRICE’,
‘Variable63OPEN’,
‘Variable63HIGH’,
‘Variable63LOW’,
‘Variable63LAST_PRICE’,
‘Variable64OPEN’,
‘Variable64HIGH’,
‘Variable64LOW’,
‘Variable64LAST_PRICE’,
‘Variable65OPEN’,
‘Variable65HIGH’,
‘Variable65LOW’,
‘Variable65LAST_PRICE’,
‘Variable68OPEN’,
‘Variable68HIGH’,
‘Variable68LOW’,
‘Variable68LAST_PRICE’,
‘Variable69OPEN’,
‘Variable69HIGH’,
‘Variable69LOW’,
‘Variable69LAST_PRICE’,
‘Variable70OPEN’,
‘Variable70HIGH’,
‘Variable70LOW’,
‘Variable70LAST_PRICE’,
‘Variable71OPEN’,
‘Variable71HIGH’,
‘Variable71LOW’,
‘Variable71LAST_PRICE’,
‘Variable72OPEN’,
‘Variable72HIGH’,
‘Variable72LOW’,
‘Variable72LAST_PRICE’,
‘Variable73OPEN’,
‘Variable73HIGH’,
‘Variable73LOW’,
‘Variable73LAST_PRICE’,
‘Variable74OPEN’,
‘Variable74HIGH’,
‘Variable74LOW’,
‘Variable74LAST_PRICE’,
‘Variable76OPEN’,
‘Variable76HIGH’,
‘Variable76LOW’,
‘Variable76LAST_PRICE’,
‘Variable77OPEN’,
‘Variable77HIGH’,
‘Variable77LOW’,
‘Variable77LAST_PRICE’,
‘Variable78OPEN’,
‘Variable78HIGH’,
‘Variable78LOW’,
‘Variable78LAST_PRICE’,
‘Variable79OPEN’,
‘Variable79HIGH’,
‘Variable79LOW’,
‘Variable79LAST_PRICE’,
‘Variable80OPEN’,
‘Variable80HIGH’,
‘Variable80LOW’,
‘Variable80LAST_PRICE’,
‘Variable81OPEN’,
‘Variable81HIGH’,
‘Variable81LOW’,
‘Variable81LAST_PRICE’,
‘Variable82OPEN’,
‘Variable82HIGH’,
‘Variable82LOW’,
‘Variable82LAST_PRICE’,
‘Variable83OPEN’,
‘Variable83HIGH’,
‘Variable83LOW’,
‘Variable83LAST_PRICE’,
‘Variable85OPEN’,
‘Variable85HIGH’,
‘Variable85LOW’,
‘Variable85LAST_PRICE’,
‘Variable86OPEN’,
‘Variable86HIGH’,
‘Variable86LOW’,
‘Variable86LAST_PRICE’,
‘Variable87OPEN’,
‘Variable87HIGH’,
‘Variable87LOW’,
‘Variable87LAST_PRICE’,
‘Variable88OPEN’,
‘Variable88HIGH’,
‘Variable88LOW’,
‘Variable88LAST_PRICE’,
‘Variable89OPEN’,
‘Variable89HIGH’,
‘Variable89LOW’,
‘Variable89LAST_PRICE’,
‘Variable90OPEN’,
‘Variable90HIGH’,
‘Variable90LOW’,
‘Variable90LAST_PRICE’,
‘Variable91OPEN’,
‘Variable91HIGH’,
‘Variable91LOW’,
‘Variable91LAST_PRICE’,
‘Variable92OPEN’,
‘Variable92HIGH’,
‘Variable92LOW’,
‘Variable92LAST_PRICE’,
‘Variable93OPEN’,
‘Variable93HIGH’,
‘Variable93LOW’,
‘Variable93LAST_PRICE’,
‘Variable94OPEN’,
‘Variable94HIGH’,
‘Variable94LOW’,
‘Variable94LAST_PRICE’,
‘Variable95OPEN’,
‘Variable95HIGH’,
‘Variable95LOW’,
‘Variable95LAST_PRICE’,
‘Variable97OPEN’,
‘Variable97HIGH’,
‘Variable97LOW’,
‘Variable97LAST_PRICE’,
‘Variable98OPEN’,
‘Variable98HIGH’,
‘Variable98LOW’,
‘Variable98LAST_PRICE’,
‘Variable99OPEN’,
‘Variable99HIGH’,
‘Variable99LOW’,
‘Variable99LAST_PRICE’,
‘Variable100OPEN’,
‘Variable100HIGH’,
‘Variable100LOW’,
‘Variable100LAST_PRICE’,
‘Variable101OPEN’,
‘Variable101HIGH’,
‘Variable101LOW’,
‘Variable101LAST_PRICE’,
‘Variable102OPEN’,
‘Variable102HIGH’,
‘Variable102LOW’,
‘Variable102LAST_PRICE’,
‘Variable103OPEN’,
‘Variable103HIGH’,
‘Variable103LOW’,
‘Variable103LAST_PRICE’,
‘Variable105OPEN’,
‘Variable105HIGH’,
‘Variable105LOW’,
‘Variable105LAST_PRICE’,
‘Variable107OPEN’,
‘Variable107HIGH’,
‘Variable107LOW’,
‘Variable107LAST_PRICE’,
‘Variable108OPEN’,
‘Variable108HIGH’,
‘Variable108LOW’,
‘Variable108LAST_PRICE’,
‘Variable109OPEN’,
‘Variable109HIGH’,
‘Variable109LOW’,
‘Variable109LAST_PRICE’,
‘Variable111OPEN’,
‘Variable111HIGH’,
‘Variable111LOW’,
‘Variable111LAST_PRICE’,
‘Variable112OPEN’,
‘Variable112HIGH’,
‘Variable112LOW’,
‘Variable112LAST_PRICE’,
‘Variable113OPEN’,
‘Variable113HIGH’,
‘Variable113LOW’,
‘Variable113LAST_PRICE’,
‘Variable114OPEN’,
‘Variable114HIGH’,
‘Variable114LOW’,
‘Variable114LAST_PRICE’,
‘Variable115OPEN’,
‘Variable115HIGH’,
‘Variable115LOW’,
‘Variable115LAST_PRICE’,
‘Variable116OPEN’,
‘Variable116HIGH’,
‘Variable116LOW’,
‘Variable116LAST_PRICE’,
‘Variable117OPEN’,
‘Variable117HIGH’,
‘Variable117LOW’,
‘Variable117LAST_PRICE’,
‘Variable120OPEN’,
‘Variable120HIGH’,
‘Variable120LOW’,
‘Variable120LAST_PRICE’,
‘Variable121OPEN’,
‘Variable121HIGH’,
‘Variable121LOW’,
‘Variable121LAST_PRICE’,
‘Variable123OPEN’,
‘Variable123HIGH’,
‘Variable123LOW’,
‘Variable123LAST_PRICE’,
‘Variable124OPEN’,
‘Variable124HIGH’,
‘Variable124LOW’,
‘Variable124LAST_PRICE’,
‘Variable125OPEN’,
‘Variable125HIGH’,
‘Variable125LOW’,
‘Variable125LAST_PRICE’,
‘Variable126OPEN’,
‘Variable126HIGH’,
‘Variable126LOW’,
‘Variable126LAST_PRICE’,
‘Variable127OPEN’,
‘Variable127HIGH’,
‘Variable127LOW’,
‘Variable127LAST_PRICE’,
‘Variable129OPEN’,
‘Variable129HIGH’,
‘Variable129LOW’,
‘Variable129LAST_PRICE’,
‘Variable130OPEN’,
‘Variable130HIGH’,
‘Variable130LOW’,
‘Variable130LAST_PRICE’,
‘Variable133OPEN’,
‘Variable133HIGH’,
‘Variable133LOW’,
‘Variable133LAST_PRICE’,
‘Variable136OPEN’,
‘Variable136HIGH’,
‘Variable136LOW’,
‘Variable136LAST_PRICE’,
‘Variable137OPEN’,
‘Variable137HIGH’,
‘Variable137LOW’,
‘Variable137LAST_PRICE’,
‘Variable139OPEN’,
‘Variable139HIGH’,
‘Variable139LOW’,
‘Variable139LAST_PRICE’,
‘Variable141OPEN’,
‘Variable141HIGH’,
‘Variable141LOW’,
‘Variable141LAST_PRICE’]

In [16]:

len(cols)

Out[16]:

465

In [17]:

trainX = train[cols]

In [18]:

trainY = train[‘TargetVariable’]

In [19]:

testX = test[cols]

In [20]:

testX

Out[20]:

Timestamp Variable159OPEN Variable159HIGH Variable159LOW Variable159LAST Variable164OPEN Variable164HIGH Variable164LOW Variable164LAST Variable8OPEN … Variable137LOW Variable137LAST_PRICE Variable139OPEN Variable139HIGH Variable139LOW Variable139LAST_PRICE Variable141OPEN Variable141HIGH Variable141LOW Variable141LAST_PRICE
0 40289.659722 296.327859 296.340771 296.250387 296.327859 9.268154 9.268154 9.262989 9.268154 109.640017 … 23.879248 23.930896 47.363392 47.363392 47.363392 47.363392 3.778019 3.788348 3.772854 3.788348
1 40289.663194 296.327859 296.353682 296.276211 296.276211 9.268154 9.268154 9.252660 9.257825 109.606446 … 23.889578 23.889578 47.438281 47.438281 47.363392 47.363392 3.788348 3.788348 3.783184 3.788348
2 40289.666667 296.276211 296.302035 296.237476 296.237476 9.262989 9.262989 9.262989 9.262989 109.611610 … 23.889578 23.889578 47.363392 47.363392 47.285921 47.285921 3.788348 3.793513 3.788348 3.793513
3 40290.395833 294.935957 294.946287 293.074063 293.358124 9.221671 9.242330 9.211342 9.234583 109.647764 … 23.889578 24.354406 47.285921 47.285921 46.219399 46.219399 3.793513 3.793513 3.710877 3.721206
4 40290.399306 293.358124 293.448507 292.764177 293.022415 9.237166 9.239748 9.219089 9.229418 108.658713 … 24.323417 24.323417 46.219399 46.449230 46.219399 46.449230 3.721206 3.731536 3.716042 3.721206
5 40290.402778 293.022415 293.216093 292.583411 293.004338 9.229418 9.229418 9.190683 9.201012 108.542506 … 24.333747 24.519678 46.371759 46.449230 46.371759 46.449230 3.710877 3.710877 3.690218 3.710877
6 40290.406250 293.004338 293.190270 292.699618 292.973350 9.201012 9.208759 9.195848 9.208759 108.323004 … 24.509348 24.695279 46.371759 46.449230 46.296870 46.371759 3.695383 3.716042 3.695383 3.716042
7 40290.409722 292.981097 293.203181 292.805495 293.035327 9.208759 9.221645 9.195848 9.221645 108.560583 … 24.684950 24.757256 46.296870 46.524119 46.296870 46.524119 3.716042 3.726371 3.716042 3.726371
8 40290.413194 293.035327 293.185105 292.944944 292.983679 9.219089 9.260407 9.216507 9.250077 108.607065 … 24.757256 24.860552 46.524119 46.828840 46.524119 46.828840 3.726371 3.747030 3.726371 3.747030
9 40290.416667 292.978515 293.009503 292.307096 292.699618 9.247495 9.255242 9.229418 9.242330 108.679372 … 24.715938 24.767586 46.828840 46.906311 46.828840 46.828840 3.752195 3.767689 3.747030 3.757360
10 40290.420139 292.699618 292.970767 292.666047 292.823572 9.244913 9.262989 9.229418 9.229418 108.635472 … 24.695279 24.695279 46.828840 46.828840 46.601591 46.601591 3.757360 3.778019 3.752195 3.752195
11 40290.423611 292.831319 292.919120 292.707365 292.854560 9.229418 9.237166 9.213924 9.213924 108.457288 … 24.674620 24.726268 46.601591 46.753951 46.601591 46.753951 3.757360 3.762525 3.752195 3.752195
12 40290.427083 292.862308 293.048239 292.751265 292.888131 9.216507 9.234583 9.216507 9.232001 108.439211 … 24.746927 24.757256 46.753951 46.828840 46.753951 46.828840 3.757360 3.762525 3.747030 3.752195
13 40290.430556 292.890714 293.368454 292.771924 293.368454 9.232001 9.232001 9.219089 9.224254 108.542506 … 24.757256 24.767586 46.828840 46.981200 46.828840 46.981200 3.752195 3.752195 3.741866 3.741866
14 40290.434028 293.360706 293.696416 293.203181 293.440760 9.226836 9.260407 9.226578 9.252660 108.689701 … 24.767586 24.788245 46.981200 47.211032 46.981200 47.058672 3.747030 3.793513 3.747030 3.772854
15 40290.437500 293.440760 293.624109 292.493028 293.288400 9.252660 9.265572 9.234583 9.265572 108.669043 … 24.674620 24.808904 47.058672 47.133561 46.981200 47.133561 3.772854 3.793513 3.757360 3.793513
16 40290.440972 293.262576 293.484661 293.133457 293.177358 9.268154 9.288813 9.262989 9.281066 108.764590 … 24.767586 24.767586 47.363392 47.363392 47.211032 47.285921 3.801260 3.806425 3.796095 3.796095
17 40290.444444 293.177358 293.513067 292.952691 293.513067 9.281066 9.283648 9.268154 9.268154 108.534759 … 24.757256 24.788245 47.285921 47.363392 47.211032 47.363392 3.796095 3.801260 3.783184 3.788348
18 40290.447917 293.513067 293.848776 293.340048 293.525979 9.270736 9.277192 9.260407 9.265572 108.596736 … 24.777915 24.777915 47.363392 47.515753 47.363392 47.515753 3.796095 3.796095 3.788348 3.793513
19 40290.451389 293.525979 293.696416 293.249664 293.306477 9.265572 9.266863 9.244887 9.247495 108.669043 … 24.757256 24.777915 47.515753 47.515753 47.285921 47.285921 3.793513 3.793513 3.772854 3.778019
20 40290.454861 293.314224 293.624109 293.290982 293.507902 9.248786 9.257825 9.244913 9.244913 108.658713 … 24.777915 24.788245 47.285921 47.285921 47.285921 47.285921 3.778019 3.778019 3.741866 3.741866
21 40290.458333 293.507902 293.590538 293.252247 293.378783 9.244913 9.255242 9.244913 9.252918 108.511517 … 24.777915 24.808904 47.363392 47.363392 47.285921 47.363392 3.741866 3.762525 3.741866 3.757360
22 40290.461806 293.378783 293.564714 293.340048 293.487243 9.253951 9.262989 9.252660 9.262989 108.565747 … 24.757256 24.777915 47.363392 47.438281 47.285921 47.438281 3.757360 3.778019 3.752195 3.778019
23 40290.465278 293.494990 293.616362 293.332300 293.358124 9.262989 9.262989 9.250077 9.253951 108.622560 … 24.777915 24.777915 47.438281 47.438281 47.438281 47.438281 3.783184 3.783184 3.767689 3.767689
24 40290.468750 293.365871 293.616362 293.086974 293.590538 9.252660 9.253951 9.232001 9.237166 108.436628 … 24.705609 24.736597 47.438281 47.438281 47.363392 47.363392 3.767689 3.767689 3.762525 3.762525
25 40290.472222 293.590538 293.613780 293.360706 293.479496 9.237166 9.239748 9.234583 9.234583 108.413387 … 24.726268 24.736597 47.363392 47.363392 47.285921 47.285921 3.762525 3.762525 3.741866 3.741866
26 40290.475694 293.479496 293.900423 293.456255 293.887512 9.234583 9.239748 9.226836 9.237682 108.317839 … 24.726268 24.736597 47.285921 47.438281 47.285921 47.438281 3.741866 3.767689 3.741866 3.767689
27 40290.479167 293.887512 293.952071 293.507902 293.624109 9.239490 9.242330 9.224228 9.232001 108.273939 … 24.746927 24.746927 47.438281 47.438281 47.363392 47.438281 3.767689 3.767689 3.752195 3.762525
28 40290.482639 293.624109 293.642186 293.396860 293.474331 9.229418 9.237166 9.226836 9.237166 108.155149 … 24.746927 24.767586 47.438281 47.438281 47.363392 47.363392 3.762525 3.767689 3.762525 3.767689
29 40290.486111 293.474331 293.559550 293.216093 293.254829 9.239077 9.242305 9.234583 9.234583 108.206797 … 24.757256 24.767586 47.363392 47.438281 47.363392 47.438281 3.767689 3.767689 3.762525 3.762525
… … … … … … … … … … … … … … … … … … … … … …
2509 40336.593750 320.354302 320.421444 320.305237 320.364632 7.837517 7.837517 7.819440 7.825896 96.521537 … 22.722343 22.753331 37.157835 37.235306 37.157835 37.235306 2.476500 2.476500 2.468753 2.468753
2510 40336.597222 320.356885 320.473092 320.343973 320.442103 7.827187 7.837517 7.824605 7.829770 96.441483 … 22.732672 22.732672 37.157835 37.157835 37.082946 37.157835 2.468753 2.468753 2.463588 2.463588
2511 40336.600694 320.442103 320.480839 320.263919 320.390456 7.829770 7.850429 7.829770 7.847846 96.420824 … 22.732672 22.763661 37.157835 37.157835 37.082946 37.157835 2.463588 2.471336 2.463588 2.471336
2512 40336.604167 320.377544 320.545398 320.369797 320.511827 7.847846 7.850429 7.837517 7.837517 96.614503 … 22.722343 22.722343 37.157835 37.235306 37.157835 37.157835 2.471336 2.471336 2.468753 2.468753
2513 40336.607639 320.537651 320.537651 320.380126 320.447268 7.837517 7.850429 7.829770 7.829770 96.361430 … 22.691354 22.691354 37.005475 37.082946 36.930586 37.005475 2.463588 2.463588 2.458424 2.458424
2514 40336.611111 320.447268 320.483421 320.325896 320.336226 7.829770 7.832352 7.809111 7.811693 96.413077 … 22.681025 22.691354 37.005475 37.005475 36.855697 36.930586 2.458424 2.458424 2.453259 2.453259
2515 40336.614583 320.336226 320.444685 320.287160 320.310402 7.814275 7.819440 7.803946 7.819440 96.335606 … 22.598389 22.629377 36.930586 36.930586 36.778225 36.855697 2.453259 2.453259 2.442929 2.442929
2516 40336.618056 320.310402 320.367214 320.150294 320.163206 7.819440 7.827187 7.814275 7.822023 96.299453 … 22.598389 22.598389 36.855697 36.855697 36.550976 36.778225 2.442929 2.442929 2.442929 2.442929
2517 40336.621528 320.163206 320.395620 320.132218 320.395620 7.824605 7.827187 7.798781 7.803946 96.260717 … 22.598389 22.608718 36.703336 36.703336 36.550976 36.550976 2.442929 2.448094 2.437765 2.448094
2518 40336.625000 320.382708 321.079950 320.356885 320.816548 7.803946 7.822023 7.801363 7.803946 96.382089 … 22.608718 22.660366 36.550976 36.703336 36.550976 36.703336 2.453259 2.463588 2.453259 2.458424
2519 40336.628472 320.821713 321.392418 320.713253 321.358847 7.803946 7.827187 7.801363 7.811693 96.552526 … 22.660366 22.712013 36.703336 36.778225 36.625865 36.778225 2.458424 2.463588 2.458424 2.463588
2520 40336.631944 321.369177 321.441483 320.886272 320.997314 7.814275 7.814275 7.798781 7.803946 96.593844 … 22.650036 22.660366 36.778225 36.778225 36.550976 36.550976 2.463588 2.463588 2.453259 2.453259
2521 40336.635417 320.989567 321.126433 320.868195 321.056709 7.806528 7.814275 7.788452 7.798781 96.338188 … 22.588059 22.598389 36.550976 36.550976 36.398616 36.398616 2.458424 2.458424 2.442929 2.442929
2522 40336.638889 321.056709 321.260717 320.940502 321.190993 7.798781 7.801363 7.787160 7.791034 95.888854 … 22.557071 22.608718 36.321145 36.398616 36.246256 36.321145 2.442929 2.442929 2.432600 2.437765
2523 40336.642361 321.190993 321.309782 320.847536 320.860448 7.789743 7.796199 7.785869 7.788452 95.728747 … 22.567400 22.588059 36.246256 40.509761 36.246256 39.595600 2.437765 2.437765 2.427435 2.427435
2524 40336.645833 320.860448 320.899184 320.674517 320.860448 7.788452 7.788452 7.775540 7.780704 95.439521 … 22.567400 22.608718 39.443239 39.443239 38.301828 39.063630 2.427435 2.427435 2.427435 2.427435
2525 40336.649306 320.873360 321.286541 320.852701 321.183245 7.779413 7.796199 7.778122 7.788452 95.746824 … 22.619048 22.639707 39.138519 39.443239 38.758909 38.833798 2.427435 2.432600 2.427435 2.427435
2526 40336.652778 321.183245 321.335606 320.870778 320.950831 7.788452 7.788452 7.752298 7.765210 95.770065 … 22.526082 22.598389 39.138519 39.138519 38.606549 38.606549 2.427435 2.427435 2.417106 2.422270
2527 40336.656250 320.963743 321.043797 320.744241 320.821713 7.765210 7.778122 7.762628 7.767793 95.501498 … 22.536412 22.536412 38.758909 39.063630 38.681438 38.833798 2.427435 2.427435 2.411941 2.411941
2528 40336.659722 320.821713 320.850119 320.558310 320.609958 7.767793 7.775540 7.754881 7.757463 95.452433 … 22.464105 22.484764 38.911270 38.911270 38.529078 38.529078 2.422270 2.422270 2.411941 2.411941
2529 40336.663194 320.615122 320.684847 320.281996 320.524739 7.757463 7.767793 7.747134 7.749716 95.491168 … 22.298833 22.381469 38.606549 38.833798 38.529078 38.833798 2.411941 2.417106 2.406776 2.406776
2530 40336.666667 320.519574 320.537651 320.318149 320.524739 7.747134 7.747134 7.747134 7.747134 95.320731 … 22.340151 22.340151 38.833798 38.911270 38.833798 38.911270 2.406776 2.411941 2.406776 2.411941
2531 40337.395833 320.906931 321.072203 320.702923 320.754571 7.747134 7.809111 7.682574 7.798781 95.341390 … 22.340151 22.484764 38.911270 39.215990 38.606549 38.911270 2.411941 2.437765 2.411941 2.427435
2532 40337.399306 320.754571 320.968908 320.682264 320.901766 7.798781 7.824605 7.780704 7.809111 95.989567 … 22.505423 22.629377 38.833798 39.063630 38.833798 38.833798 2.437765 2.453259 2.437765 2.448094
2533 40337.402778 320.904349 320.912096 320.568640 320.850119 7.811693 7.834934 7.810402 7.827187 95.813966 … 22.515752 22.515752 38.833798 38.833798 38.149468 38.224357 2.442929 2.448094 2.432600 2.432600
2534 40337.406250 320.844954 320.935337 320.640946 320.785559 7.824605 7.850429 7.822023 7.847846 95.788142 … 22.412457 22.443446 38.149468 38.149468 37.462556 37.614916 2.432600 2.432600 2.417106 2.427435
2535 40337.409722 320.780395 320.966326 320.759736 320.912096 7.850429 7.853011 7.809111 7.822023 95.844954 … 22.267844 22.340151 37.614916 37.614916 37.235306 37.462556 2.427435 2.427435 2.396447 2.396447
2536 40337.413194 320.922425 320.940502 320.630617 320.739077 7.819440 7.829770 7.816858 7.822023 95.576387 … 22.236856 22.247185 37.462556 37.462556 37.235306 37.235306 2.396447 2.401611 2.391282 2.396447
2537 40337.416667 320.746824 322.038013 320.746824 321.875323 7.822023 7.850429 7.816858 7.842682 95.669352 … 22.247185 22.412457 37.310195 37.540027 37.310195 37.540027 2.396447 2.427435 2.396447 2.427435
2538 40337.420139 321.877905 321.963124 321.529284 321.735874 7.841390 7.853011 7.840099 7.842682 96.152257 … 22.402128 22.433116 37.540027 37.767276 37.540027 37.767276 2.427435 2.437765 2.427435 2.432600

2539 rows × 465 columns

In [21]:

# random_state = np.random.RandomState(0)
# cv = KFold(trainY.shape[0], n_folds=3, shuffle=True)

# def cv_auc(classifier, name):
# mean_tpr = 0.0
# mean_fpr = np.linspace(0, 1, 100)

# for i, (train, test) in enumerate(cv):

# probas_ = classifier.fit(trainX.values[train], trainY.values[train]).predict_proba(trainX.values[test])
# fpr, tpr, thresholds = roc_curve(trainY.values[test], probas_[:, 1])
# # print(name)
# # print(fpr)
# # print(tpr)
# # print(thresholds)
# # print(‘———-‘)

# mean_tpr += interp(mean_fpr, fpr, tpr)
# mean_tpr[0] = 0.0
# roc_auc = auc(fpr, tpr)
# plt.plot(fpr, tpr, lw=1, label=’ROC fold %d (area = %0.2f)’ % (i, roc_auc))

# plt.plot([0, 1], [0, 1], ‘–‘, color=(0.6, 0.6, 0.6), label=’Luck’)

# mean_tpr /= len(cv)
# mean_tpr[-1] = 1.0
# mean_auc = auc(mean_fpr, mean_tpr)
# plt.plot(mean_fpr, mean_tpr, ‘k–‘,
# label=’Mean ROC (area = %0.2f)’ % mean_auc, lw=2)

# plt.xlim([-0.05, 1.05])
# plt.ylim([-0.05, 1.05])
# plt.xlabel(‘False Positive Rate’)
# plt.ylabel(‘True Positive Rate’)
# plt.title(‘Receiver operating characteristic for ‘ + name)
# plt.legend(loc=”lower right”)
# plt.show()
# # plt.savefig(name + ‘.jpg’)

In [23]:

def cv_auc(trainX, trainY, numFold, classifier, name):

cv = KFold(trainY.shape[0], n_folds=numFold, shuffle=True)

mean_tpr = 0.0
mean_fpr = np.linspace(0, 1, 100)

for i, (train, test) in enumerate(cv):

probas_ = classifier.fit(trainX.values[train], trainY.values[train]).predict_proba(trainX.values[test])
fpr, tpr, thresholds = roc_curve(trainY.values[test], probas_[:, 1])

mean_tpr += interp(mean_fpr, fpr, tpr)
mean_tpr[0] = 0.0
roc_auc = auc(fpr, tpr)
plt.plot(fpr, tpr, lw=1, label=’ROC fold %d (area = %0.2f)’ % (i, roc_auc))

plt.plot([0, 1], [0, 1], ‘–‘, color=(0.6, 0.6, 0.6), label=’Luck’)

mean_tpr /= len(cv)
mean_tpr[-1] = 1.0
mean_auc = auc(mean_fpr, mean_tpr)
plt.plot(mean_fpr, mean_tpr, ‘k–‘,
label=’Mean ROC (area = %0.2f)’ % mean_auc, lw=2)

plt.xlim([-0.05, 1.05])
plt.ylim([-0.05, 1.05])
plt.xlabel(‘False Positive Rate’)
plt.ylabel(‘True Positive Rate’)
plt.title(‘Receiver operating characteristic for ‘ + name)
plt.legend(loc=”lower right”)
plt.show()

In [24]:

classifiers = [linear_model.LogisticRegression(class_weight=’balanced’),
svm.SVC(kernel=’linear’, probability=True,
random_state=random_state, class_weight=’balanced’)]

names = [‘Logistic Regression’, “SVM”]

for i in range(1):
plt.clf()
cv_auc(trainX, trainY, 3, classifiers[i], names[i])

In [28]:

logiRegClassifier = linear_model.LogisticRegression(class_weight=’balanced’)
logiRegClassifier.fit(trainX, trainY)

Out[28]:

LogisticRegression(C=1.0, class_weight=’balanced’, dual=False,
fit_intercept=True, intercept_scaling=1, max_iter=100,
multi_class=’ovr’, n_jobs=1, penalty=’l2′, random_state=None,
solver=’liblinear’, tol=0.0001, verbose=0, warm_start=False)

In [29]:

testX.isnull().any()

Out[29]:

Timestamp False
Variable159OPEN False
Variable159HIGH False
Variable159LOW False
Variable159LAST False
Variable164OPEN False
Variable164HIGH False
Variable164LOW False
Variable164LAST False
Variable8OPEN False
Variable8HIGH False
Variable8LOW False
Variable8LAST_PRICE False
Variable9OPEN False
Variable9HIGH False
Variable9LOW False
Variable9LAST_PRICE False
Variable10OPEN False
Variable10HIGH False
Variable10LOW False
Variable10LAST_PRICE False
Variable11OPEN False
Variable11HIGH False
Variable11LOW False
Variable11LAST_PRICE False
Variable12OPEN False
Variable12HIGH False
Variable12LOW False
Variable12LAST_PRICE False
Variable13OPEN False

Variable127LOW False
Variable127LAST_PRICE False
Variable129OPEN False
Variable129HIGH False
Variable129LOW False
Variable129LAST_PRICE False
Variable130OPEN False
Variable130HIGH False
Variable130LOW False
Variable130LAST_PRICE False
Variable133OPEN False
Variable133HIGH False
Variable133LOW False
Variable133LAST_PRICE False
Variable136OPEN False
Variable136HIGH False
Variable136LOW False
Variable136LAST_PRICE False
Variable137OPEN False
Variable137HIGH False
Variable137LOW False
Variable137LAST_PRICE False
Variable139OPEN False
Variable139HIGH False
Variable139LOW False
Variable139LAST_PRICE False
Variable141OPEN False
Variable141HIGH False
Variable141LOW False
Variable141LAST_PRICE False
dtype: bool

In [30]:

testYProb = logiRegClassifier.predict_proba(testX)

In [32]:

testYProb

Out[32]:

array([[ 5.00864148e-01, 4.99135852e-01],
[ 5.22711669e-01, 4.77288331e-01],
[ 4.70628896e-01, 5.29371104e-01],
…,
[ 9.99999999e-01, 5.77309140e-10],
[ 9.99999999e-01, 6.26978262e-10],
[ 9.99999999e-01, 7.30716361e-10]])

In [35]:

testY = logiRegClassifier.predict(testX)

In [33]:

testY

Out[33]:

array([0, 0, 1, …, 0, 0, 0])

In [42]:

outProb = pd.DataFrame({“Timestamp”: test[‘Timestamp’], “Score”: testYProb[:,1]})

In [50]:

outProb

Out[50]:

Score Timestamp
0 4.991359e-01 40289.659722
1 4.772883e-01 40289.663194
2 5.293711e-01 40289.666667
3 7.458748e-01 40290.395833
4 3.642648e-03 40290.399306
5 8.740669e-03 40290.402778
6 1.482215e-02 40290.406250
7 3.336558e-02 40290.409722
8 1.248093e-02 40290.413194
9 1.267349e-02 40290.416667
10 1.384272e-02 40290.420139
11 1.641626e-02 40290.423611
12 9.363629e-03 40290.427083
13 5.944474e-03 40290.430556
14 6.969733e-03 40290.434028
15 5.694134e-03 40290.437500
16 5.157876e-03 40290.440972
17 3.443934e-03 40290.444444
18 3.706470e-03 40290.447917
19 1.341812e-02 40290.451389
20 2.778245e-02 40290.454861
21 7.050519e-02 40290.458333
22 1.235218e-01 40290.461806
23 1.963404e-01 40290.465278
24 7.292517e-02 40290.468750
25 2.080013e-01 40290.472222
26 2.782143e-01 40290.475694
27 2.498681e-01 40290.479167
28 2.612405e-01 40290.482639
29 2.586164e-01 40290.486111
… … …
2509 1.230855e-09 40336.593750
2510 8.402939e-10 40336.597222
2511 6.962772e-10 40336.600694
2512 7.592883e-10 40336.604167
2513 5.664518e-10 40336.607639
2514 8.199473e-10 40336.611111
2515 1.173050e-09 40336.614583
2516 9.951754e-10 40336.618056
2517 1.593444e-09 40336.621528
2518 1.219115e-09 40336.625000
2519 8.164988e-10 40336.628472
2520 4.373459e-10 40336.631944
2521 4.732771e-10 40336.635417
2522 6.155041e-10 40336.638889
2523 2.345777e-10 40336.642361
2524 5.677176e-10 40336.645833
2525 4.727566e-10 40336.649306
2526 4.432033e-10 40336.652778
2527 3.487585e-10 40336.656250
2528 4.717321e-10 40336.659722
2529 5.292507e-10 40336.663194
2530 5.234629e-10 40336.666667
2531 5.180721e-09 40337.395833
2532 4.110906e-09 40337.399306
2533 1.292165e-09 40337.402778
2534 1.596810e-09 40337.406250
2535 1.935299e-09 40337.409722
2536 5.773091e-10 40337.413194
2537 6.269783e-10 40337.416667
2538 7.307164e-10 40337.420139

2539 rows × 2 columns

In [47]:

outProb[‘Timestamp’][0]

Out[47]:

40289.659722000004

In [49]:

f = open(‘logistic1.csv’, ‘w’)
f.write(‘Timestamp,Score
’)
for i in range(outProb.shape[0]):
f.write(‘%f,%f
’ %(outProb[‘Timestamp’][i], outProb[‘Score’][i]))

f.close()
# outProb.to_csv(“logistic1.csv”, index=False, header=True, cols=[‘Timestamp’, “Score”], engine=’python’)

In [25]:

from sklearn import preprocessing

zscoreScaler = preprocessing.StandardScaler()
normTrainX = pd.DataFrame(zscoreScaler.fit_transform(trainX))
normTestX = pd.DataFrame(zscoreScaler.transform(testX))

In [26]:

for i in range(1,2):
plt.clf()
cv_auc(normTrainX, trainY, 3, classifiers[i], names[i])

In [2]:

f = open(‘logistic1.csv’, ‘w’)
f.write(‘Timestamp,Score
’)
for i in range(outProb.shape[0]):
f.write(‘%f,%f
’ %(outProb[‘Timestamp’][i], outProb[‘Score’][i]))

f.close()

good

In [ ]:

Posted in Uncategorized

Leave a Reply

Your email address will not be published. Required fields are marked *