In [2]:
# Basic imports
import os
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import datetime as dt
import scipy.optimize as spo
import sys
from time import time
from sklearn.metrics import r2_score, median_absolute_error
%matplotlib inline
%pylab inline
pylab.rcParams['figure.figsize'] = (20.0, 10.0)
%load_ext autoreload
%autoreload 2
sys.path.append('../../')
Populating the interactive namespace from numpy and matplotlib
The autoreload extension is already loaded. To reload it, use:
%reload_ext autoreload
In [3]:
levels = [-13.5, -10.0, -1.0, 2.0, 3.0]
In [5]:
real_value = -6.7
temp_list = levels + [real_value]
temp_list
Out[5]:
[-13.5, -10.0, -1.0, 2.0, 3.0, -6.7]
In [8]:
temp_list.sort()
temp_list
Out[8]:
[-13.5, -10.0, -6.7, -1.0, 2.0, 3.0]
In [11]:
sorted_index = temp_list.index(real_value)
if sorted_index == 0:
q_value = levels[0]
elif sorted_index == len(temp_list)-1:
q_value = levels[-1]
else:
q_value = (temp_list[sorted_index-1] + temp_list[sorted_index+1])/2
q_value
Out[11]:
-5.5
In [58]:
def quantize(real_value, levels):
temp_list = levels + [real_value]
temp_list.sort()
sorted_index = temp_list.index(real_value)
if sorted_index == 0:
q_value = levels[0]
elif sorted_index == len(temp_list)-1:
q_value = levels[-1]
else:
q_value = (temp_list[sorted_index-1] + temp_list[sorted_index+1])/2
return q_value
In [59]:
levels
Out[59]:
[-13.5, -10.0, -1.0, 2.0, 3.0]
In [60]:
x = arange(-20,20,0.2)
x_df = pd.DataFrame(x, columns=['real_value'])
x_df
Out[60]:
real_value
0
-20.0
1
-19.8
2
-19.6
3
-19.4
4
-19.2
5
-19.0
6
-18.8
7
-18.6
8
-18.4
9
-18.2
10
-18.0
11
-17.8
12
-17.6
13
-17.4
14
-17.2
15
-17.0
16
-16.8
17
-16.6
18
-16.4
19
-16.2
20
-16.0
21
-15.8
22
-15.6
23
-15.4
24
-15.2
25
-15.0
26
-14.8
27
-14.6
28
-14.4
29
-14.2
...
...
170
14.0
171
14.2
172
14.4
173
14.6
174
14.8
175
15.0
176
15.2
177
15.4
178
15.6
179
15.8
180
16.0
181
16.2
182
16.4
183
16.6
184
16.8
185
17.0
186
17.2
187
17.4
188
17.6
189
17.8
190
18.0
191
18.2
192
18.4
193
18.6
194
18.8
195
19.0
196
19.2
197
19.4
198
19.6
199
19.8
200 rows × 1 columns
In [61]:
len(x_df.values.tolist())
Out[61]:
200
In [62]:
from functools import partial
# x_df.apply(lambda x:print('{} \n {}'.format(x,'-'*20)), axis=1)
x_df['q_value'] = x_df.apply(lambda x: partial(quantize, levels=levels)(x[0]), axis=1)
x_df.head()
Out[62]:
real_value
q_value
0
-20.0
-13.5
1
-19.8
-13.5
2
-19.6
-13.5
3
-19.4
-13.5
4
-19.2
-13.5
In [63]:
plt.plot(x_df['real_value'], x_df['q_value'])
Out[63]:
[<matplotlib.lines.Line2D at 0x7f6d7bda1518>]
In [64]:
data_df = pd.read_pickle('../../data/data_df.pkl')
In [79]:
first_date = data_df.index.get_level_values(0)[0]
first_date
Out[79]:
Timestamp('1993-01-29 00:00:00')
In [84]:
one_input_df = data_df.loc[first_date,:]
one_input_df
Out[84]:
SPY
MMM
ABT
ABBV
ACN
ATVI
AYI
ADBE
AMD
AAP
...
XEL
XRX
XLNX
XL
XYL
YHOO
YUM
ZBH
ZION
ZTS
feature
Open
0.00
0.00
0.00
NaN
NaN
NaN
NaN
0.00
0.00
NaN
...
0.00
0.00
0.00
NaN
NaN
NaN
NaN
NaN
0.00
NaN
High
43.97
24.62
6.88
NaN
NaN
NaN
NaN
2.64
19.12
NaN
...
22.00
14.32
2.50
NaN
NaN
NaN
NaN
NaN
10.94
NaN
Low
43.75
24.47
6.75
NaN
NaN
NaN
NaN
2.56
18.62
NaN
...
21.88
13.84
2.46
NaN
NaN
NaN
NaN
NaN
10.62
NaN
Close
43.94
24.50
6.88
NaN
NaN
NaN
NaN
2.59
18.75
NaN
...
22.00
14.28
2.50
NaN
NaN
NaN
NaN
NaN
10.94
NaN
Volume
1003200.00
1242800.00
4638400.00
NaN
NaN
NaN
NaN
4990400.00
730600.00
NaN
...
87800.00
7633602.00
1745196.00
NaN
NaN
NaN
NaN
NaN
33600.00
NaN
5 rows × 503 columns
Normally, the data to pass to the extractor will be all the data, for one symbol, during a period of some days.
In [98]:
num_days = 50
end_date = data_df.index.get_level_values(0).unique()[num_days-1]
In [99]:
sym_data = data_df['MSFT'].unstack()
sym_data.head()
Out[99]:
feature
Close
High
Low
Open
Volume
date
1993-01-29
2.70
2.75
2.68
0.0
39424000.0
1993-02-01
2.73
2.75
2.67
0.0
42854400.0
1993-02-02
2.78
2.80
2.73
0.0
70252800.0
1993-02-03
2.76
2.82
2.75
0.0
71728000.0
1993-02-04
2.67
2.74
2.64
0.0
24214400.0
In [100]:
batch_data = sym_data[first_date:end_date]
batch_data.shape
Out[100]:
(50, 5)
In [101]:
from recommender.indicator import Indicator
In [118]:
arange(0,1e4,1)
Out[118]:
array([ 0.00000000e+00, 1.00000000e+00, 2.00000000e+00, ...,
9.99700000e+03, 9.99800000e+03, 9.99900000e+03])
In [123]:
ind1 = Indicator(lambda x: x['Close'].mean(), arange(0,10000,0.1).tolist())
In [124]:
ind1.extract(batch_data)
Out[124]:
2.6500000000000004
In [125]:
ind1.q_levels
Out[125]:
[0.0,
0.1,
0.2,
0.30000000000000004,
0.4,
0.5,
0.6000000000000001,
0.7000000000000001,
0.8,
0.9,
1.0,
1.1,
1.2000000000000002,
1.3,
1.4000000000000001,
1.5,
1.6,
1.7000000000000002,
1.8,
1.9000000000000001,
2.0,
2.1,
2.2,
2.3000000000000003,
2.4000000000000004,
2.5,
2.6,
2.7,
2.8000000000000003,
2.9000000000000004,
3.0,
3.1,
3.2,
3.3000000000000003,
3.4000000000000004,
3.5,
3.6,
3.7,
3.8000000000000003,
3.9000000000000004,
4.0,
4.1000000000000005,
4.2,
4.3,
4.4,
4.5,
4.6000000000000005,
4.7,
4.800000000000001,
4.9,
5.0,
5.1000000000000005,
5.2,
5.300000000000001,
5.4,
5.5,
5.6000000000000005,
5.7,
5.800000000000001,
5.9,
6.0,
6.1000000000000005,
6.2,
6.300000000000001,
6.4,
6.5,
6.6000000000000005,
6.7,
6.800000000000001,
6.9,
7.0,
7.1000000000000005,
7.2,
7.300000000000001,
7.4,
7.5,
7.6000000000000005,
7.7,
7.800000000000001,
7.9,
8.0,
8.1,
8.200000000000001,
8.3,
8.4,
8.5,
8.6,
8.700000000000001,
8.8,
8.9,
9.0,
9.1,
9.200000000000001,
9.3,
9.4,
9.5,
9.600000000000001,
9.700000000000001,
9.8,
9.9,
10.0,
10.100000000000001,
10.200000000000001,
10.3,
10.4,
10.5,
10.600000000000001,
10.700000000000001,
10.8,
10.9,
11.0,
11.100000000000001,
11.200000000000001,
11.3,
11.4,
11.5,
11.600000000000001,
11.700000000000001,
11.8,
11.9,
12.0,
12.100000000000001,
12.200000000000001,
12.3,
12.4,
12.5,
12.600000000000001,
12.700000000000001,
12.8,
12.9,
13.0,
13.100000000000001,
13.200000000000001,
13.3,
13.4,
13.5,
13.600000000000001,
13.700000000000001,
13.8,
13.9,
14.0,
14.100000000000001,
14.200000000000001,
14.3,
14.4,
14.5,
14.600000000000001,
14.700000000000001,
14.8,
14.9,
15.0,
15.100000000000001,
15.200000000000001,
15.3,
15.4,
15.5,
15.600000000000001,
15.700000000000001,
15.8,
15.9,
16.0,
16.1,
16.2,
16.3,
16.400000000000002,
16.5,
16.6,
16.7,
16.8,
16.900000000000002,
17.0,
17.1,
17.2,
17.3,
17.400000000000002,
17.5,
17.6,
17.7,
17.8,
17.900000000000002,
18.0,
18.1,
18.2,
18.3,
18.400000000000002,
18.5,
18.6,
18.7,
18.8,
18.900000000000002,
19.0,
19.1,
19.200000000000003,
19.3,
19.400000000000002,
19.5,
19.6,
19.700000000000003,
19.8,
19.900000000000002,
20.0,
20.1,
20.200000000000003,
20.3,
20.400000000000002,
20.5,
20.6,
20.700000000000003,
20.8,
20.900000000000002,
21.0,
21.1,
21.200000000000003,
21.3,
21.400000000000002,
21.5,
21.6,
21.700000000000003,
21.8,
21.900000000000002,
22.0,
22.1,
22.200000000000003,
22.3,
22.400000000000002,
22.5,
22.6,
22.700000000000003,
22.8,
22.900000000000002,
23.0,
23.1,
23.200000000000003,
23.3,
23.400000000000002,
23.5,
23.6,
23.700000000000003,
23.8,
23.900000000000002,
24.0,
24.1,
24.200000000000003,
24.3,
24.400000000000002,
24.5,
24.6,
24.700000000000003,
24.8,
24.900000000000002,
25.0,
25.1,
25.200000000000003,
25.3,
25.400000000000002,
25.5,
25.6,
25.700000000000003,
25.8,
25.900000000000002,
26.0,
26.1,
26.200000000000003,
26.3,
26.400000000000002,
26.5,
26.6,
26.700000000000003,
26.8,
26.900000000000002,
27.0,
27.1,
27.200000000000003,
27.3,
27.400000000000002,
27.5,
27.6,
27.700000000000003,
27.8,
27.900000000000002,
28.0,
28.1,
28.200000000000003,
28.3,
28.400000000000002,
28.5,
28.6,
28.700000000000003,
28.8,
28.900000000000002,
29.0,
29.1,
29.200000000000003,
29.3,
29.400000000000002,
29.5,
29.6,
29.700000000000003,
29.8,
29.900000000000002,
30.0,
30.1,
30.200000000000003,
30.3,
30.400000000000002,
30.5,
30.6,
30.700000000000003,
30.8,
30.900000000000002,
31.0,
31.1,
31.200000000000003,
31.3,
31.400000000000002,
31.5,
31.6,
31.700000000000003,
31.8,
31.900000000000002,
32.0,
32.1,
32.2,
32.300000000000004,
32.4,
32.5,
32.6,
32.7,
32.800000000000004,
32.9,
33.0,
33.1,
33.2,
33.300000000000004,
33.4,
33.5,
33.6,
33.7,
33.800000000000004,
33.9,
34.0,
34.1,
34.2,
34.300000000000004,
34.4,
34.5,
34.6,
34.7,
34.800000000000004,
34.9,
35.0,
35.1,
35.2,
35.300000000000004,
35.4,
35.5,
35.6,
35.7,
35.800000000000004,
35.9,
36.0,
36.1,
36.2,
36.300000000000004,
36.4,
36.5,
36.6,
36.7,
36.800000000000004,
36.9,
37.0,
37.1,
37.2,
37.300000000000004,
37.4,
37.5,
37.6,
37.7,
37.800000000000004,
37.9,
38.0,
38.1,
38.2,
38.300000000000004,
38.400000000000006,
38.5,
38.6,
38.7,
38.800000000000004,
38.900000000000006,
39.0,
39.1,
39.2,
39.300000000000004,
39.400000000000006,
39.5,
39.6,
39.7,
39.800000000000004,
39.900000000000006,
40.0,
40.1,
40.2,
40.300000000000004,
40.400000000000006,
40.5,
40.6,
40.7,
40.800000000000004,
40.900000000000006,
41.0,
41.1,
41.2,
41.300000000000004,
41.400000000000006,
41.5,
41.6,
41.7,
41.800000000000004,
41.900000000000006,
42.0,
42.1,
42.2,
42.300000000000004,
42.400000000000006,
42.5,
42.6,
42.7,
42.800000000000004,
42.900000000000006,
43.0,
43.1,
43.2,
43.300000000000004,
43.400000000000006,
43.5,
43.6,
43.7,
43.800000000000004,
43.900000000000006,
44.0,
44.1,
44.2,
44.300000000000004,
44.400000000000006,
44.5,
44.6,
44.7,
44.800000000000004,
44.900000000000006,
45.0,
45.1,
45.2,
45.300000000000004,
45.400000000000006,
45.5,
45.6,
45.7,
45.800000000000004,
45.900000000000006,
46.0,
46.1,
46.2,
46.300000000000004,
46.400000000000006,
46.5,
46.6,
46.7,
46.800000000000004,
46.900000000000006,
47.0,
47.1,
47.2,
47.300000000000004,
47.400000000000006,
47.5,
47.6,
47.7,
47.800000000000004,
47.900000000000006,
48.0,
48.1,
48.2,
48.300000000000004,
48.400000000000006,
48.5,
48.6,
48.7,
48.800000000000004,
48.900000000000006,
49.0,
49.1,
49.2,
49.300000000000004,
49.400000000000006,
49.5,
49.6,
49.7,
49.800000000000004,
49.900000000000006,
50.0,
50.1,
50.2,
50.300000000000004,
50.400000000000006,
50.5,
50.6,
50.7,
50.800000000000004,
50.900000000000006,
51.0,
51.1,
51.2,
51.300000000000004,
51.400000000000006,
51.5,
51.6,
51.7,
51.800000000000004,
51.900000000000006,
52.0,
52.1,
52.2,
52.300000000000004,
52.400000000000006,
52.5,
52.6,
52.7,
52.800000000000004,
52.900000000000006,
53.0,
53.1,
53.2,
53.300000000000004,
53.400000000000006,
53.5,
53.6,
53.7,
53.800000000000004,
53.900000000000006,
54.0,
54.1,
54.2,
54.300000000000004,
54.400000000000006,
54.5,
54.6,
54.7,
54.800000000000004,
54.900000000000006,
55.0,
55.1,
55.2,
55.300000000000004,
55.400000000000006,
55.5,
55.6,
55.7,
55.800000000000004,
55.900000000000006,
56.0,
56.1,
56.2,
56.300000000000004,
56.400000000000006,
56.5,
56.6,
56.7,
56.800000000000004,
56.900000000000006,
57.0,
57.1,
57.2,
57.300000000000004,
57.400000000000006,
57.5,
57.6,
57.7,
57.800000000000004,
57.900000000000006,
58.0,
58.1,
58.2,
58.300000000000004,
58.400000000000006,
58.5,
58.6,
58.7,
58.800000000000004,
58.900000000000006,
59.0,
59.1,
59.2,
59.300000000000004,
59.400000000000006,
59.5,
59.6,
59.7,
59.800000000000004,
59.900000000000006,
60.0,
60.1,
60.2,
60.300000000000004,
60.400000000000006,
60.5,
60.6,
60.7,
60.800000000000004,
60.900000000000006,
61.0,
61.1,
61.2,
61.300000000000004,
61.400000000000006,
61.5,
61.6,
61.7,
61.800000000000004,
61.900000000000006,
62.0,
62.1,
62.2,
62.300000000000004,
62.400000000000006,
62.5,
62.6,
62.7,
62.800000000000004,
62.900000000000006,
63.0,
63.1,
63.2,
63.300000000000004,
63.400000000000006,
63.5,
63.6,
63.7,
63.800000000000004,
63.900000000000006,
64.0,
64.10000000000001,
64.2,
64.3,
64.4,
64.5,
64.60000000000001,
64.7,
64.8,
64.9,
65.0,
65.10000000000001,
65.2,
65.3,
65.4,
65.5,
65.60000000000001,
65.7,
65.8,
65.9,
66.0,
66.10000000000001,
66.2,
66.3,
66.4,
66.5,
66.60000000000001,
66.7,
66.8,
66.9,
67.0,
67.10000000000001,
67.2,
67.3,
67.4,
67.5,
67.60000000000001,
67.7,
67.8,
67.9,
68.0,
68.10000000000001,
68.2,
68.3,
68.4,
68.5,
68.60000000000001,
68.7,
68.8,
68.9,
69.0,
69.10000000000001,
69.2,
69.3,
69.4,
69.5,
69.60000000000001,
69.7,
69.8,
69.9,
70.0,
70.10000000000001,
70.2,
70.3,
70.4,
70.5,
70.60000000000001,
70.7,
70.8,
70.9,
71.0,
71.10000000000001,
71.2,
71.3,
71.4,
71.5,
71.60000000000001,
71.7,
71.8,
71.9,
72.0,
72.10000000000001,
72.2,
72.3,
72.4,
72.5,
72.60000000000001,
72.7,
72.8,
72.9,
73.0,
73.10000000000001,
73.2,
73.3,
73.4,
73.5,
73.60000000000001,
73.7,
73.8,
73.9,
74.0,
74.10000000000001,
74.2,
74.3,
74.4,
74.5,
74.60000000000001,
74.7,
74.8,
74.9,
75.0,
75.10000000000001,
75.2,
75.3,
75.4,
75.5,
75.60000000000001,
75.7,
75.8,
75.9,
76.0,
76.10000000000001,
76.2,
76.3,
76.4,
76.5,
76.60000000000001,
76.7,
76.80000000000001,
76.9,
77.0,
77.10000000000001,
77.2,
77.30000000000001,
77.4,
77.5,
77.60000000000001,
77.7,
77.80000000000001,
77.9,
78.0,
78.10000000000001,
78.2,
78.30000000000001,
78.4,
78.5,
78.60000000000001,
78.7,
78.80000000000001,
78.9,
79.0,
79.10000000000001,
79.2,
79.30000000000001,
79.4,
79.5,
79.60000000000001,
79.7,
79.80000000000001,
79.9,
80.0,
80.10000000000001,
80.2,
80.30000000000001,
80.4,
80.5,
80.60000000000001,
80.7,
80.80000000000001,
80.9,
81.0,
81.10000000000001,
81.2,
81.30000000000001,
81.4,
81.5,
81.60000000000001,
81.7,
81.80000000000001,
81.9,
82.0,
82.10000000000001,
82.2,
82.30000000000001,
82.4,
82.5,
82.60000000000001,
82.7,
82.80000000000001,
82.9,
83.0,
83.10000000000001,
83.2,
83.30000000000001,
83.4,
83.5,
83.60000000000001,
83.7,
83.80000000000001,
83.9,
84.0,
84.10000000000001,
84.2,
84.30000000000001,
84.4,
84.5,
84.60000000000001,
84.7,
84.80000000000001,
84.9,
85.0,
85.10000000000001,
85.2,
85.30000000000001,
85.4,
85.5,
85.60000000000001,
85.7,
85.80000000000001,
85.9,
86.0,
86.10000000000001,
86.2,
86.30000000000001,
86.4,
86.5,
86.60000000000001,
86.7,
86.80000000000001,
86.9,
87.0,
87.10000000000001,
87.2,
87.30000000000001,
87.4,
87.5,
87.60000000000001,
87.7,
87.80000000000001,
87.9,
88.0,
88.10000000000001,
88.2,
88.30000000000001,
88.4,
88.5,
88.60000000000001,
88.7,
88.80000000000001,
88.9,
89.0,
89.10000000000001,
89.2,
89.30000000000001,
89.4,
89.5,
89.60000000000001,
89.7,
89.80000000000001,
89.9,
90.0,
90.10000000000001,
90.2,
90.30000000000001,
90.4,
90.5,
90.60000000000001,
90.7,
90.80000000000001,
90.9,
91.0,
91.10000000000001,
91.2,
91.30000000000001,
91.4,
91.5,
91.60000000000001,
91.7,
91.80000000000001,
91.9,
92.0,
92.10000000000001,
92.2,
92.30000000000001,
92.4,
92.5,
92.60000000000001,
92.7,
92.80000000000001,
92.9,
93.0,
93.10000000000001,
93.2,
93.30000000000001,
93.4,
93.5,
93.60000000000001,
93.7,
93.80000000000001,
93.9,
94.0,
94.10000000000001,
94.2,
94.30000000000001,
94.4,
94.5,
94.60000000000001,
94.7,
94.80000000000001,
94.9,
95.0,
95.10000000000001,
95.2,
95.30000000000001,
95.4,
95.5,
95.60000000000001,
95.7,
95.80000000000001,
95.9,
96.0,
96.10000000000001,
96.2,
96.30000000000001,
96.4,
96.5,
96.60000000000001,
96.7,
96.80000000000001,
96.9,
97.0,
97.10000000000001,
97.2,
97.30000000000001,
97.4,
97.5,
97.60000000000001,
97.7,
97.80000000000001,
97.9,
98.0,
98.10000000000001,
98.2,
98.30000000000001,
98.4,
98.5,
98.60000000000001,
98.7,
98.80000000000001,
98.9,
99.0,
99.10000000000001,
99.2,
99.30000000000001,
99.4,
99.5,
99.60000000000001,
99.7,
99.80000000000001,
99.9,
...]
Another Indicator
In [135]:
ind2 = Indicator(lambda x: (x['Volume']/x['Close']).max(), arange(0,1e8,1e4).tolist())
In [136]:
ind2.extract(batch_data)
Out[136]:
38995000.0
In [137]:
(batch_data['Volume']/batch_data['Close']).max()
Out[137]:
38993734.939759031
In [139]:
ind3 = Indicator(lambda x: x['High'].min(), arange(0,1000,0.1).tolist())
In [140]:
ind3.extract(batch_data)
Out[140]:
2.55
In [141]:
indicators = [ind1, ind2, ind3]
In [145]:
vect_state = list(map(lambda x: x.extract(batch_data), indicators))
vect_state
Out[145]:
[2.6500000000000004, 38995000.0, 2.55]
Let's generate the q_values for the q_levels
In [156]:
len(ind1.q_levels)
Out[156]:
100000
In [165]:
q_values = [ind1.q_levels[0]] + (np.array(ind1.q_levels[1:]) + np.array(ind1.q_levels[:-1])).tolist() + [ind1.q_levels[-1]]
q_values
Out[165]:
[0.0,
0.1,
0.30000000000000004,
0.5,
0.7000000000000001,
0.9,
1.1,
1.3000000000000003,
1.5,
1.7000000000000002,
1.9,
2.1,
2.3000000000000003,
2.5,
2.7,
2.9000000000000004,
3.1,
3.3000000000000003,
3.5,
3.7,
3.9000000000000004,
4.1,
4.300000000000001,
4.5,
4.700000000000001,
4.9,
5.1,
5.300000000000001,
5.5,
5.700000000000001,
5.9,
6.1,
6.300000000000001,
6.5,
6.700000000000001,
6.9,
7.1,
7.300000000000001,
7.5,
7.700000000000001,
7.9,
8.100000000000001,
8.3,
8.5,
8.7,
8.9,
9.100000000000001,
9.3,
9.5,
9.700000000000001,
9.9,
10.100000000000001,
10.3,
10.5,
10.700000000000001,
10.9,
11.100000000000001,
11.3,
11.5,
11.700000000000001,
11.9,
12.100000000000001,
12.3,
12.5,
12.700000000000001,
12.9,
13.100000000000001,
13.3,
13.5,
13.700000000000001,
13.9,
14.100000000000001,
14.3,
14.5,
14.700000000000001,
14.9,
15.100000000000001,
15.3,
15.5,
15.700000000000001,
15.9,
16.1,
16.3,
16.5,
16.700000000000003,
16.9,
17.1,
17.3,
17.5,
17.700000000000003,
17.9,
18.1,
18.3,
18.5,
18.700000000000003,
18.9,
19.1,
19.300000000000004,
19.5,
19.700000000000003,
19.9,
20.1,
20.300000000000004,
20.5,
20.700000000000003,
20.9,
21.1,
21.300000000000004,
21.5,
21.700000000000003,
21.9,
22.1,
22.300000000000004,
22.5,
22.700000000000003,
22.9,
23.1,
23.300000000000004,
23.5,
23.700000000000003,
23.9,
24.1,
24.300000000000004,
24.5,
24.700000000000003,
24.9,
25.1,
25.300000000000004,
25.5,
25.700000000000003,
25.9,
26.1,
26.300000000000004,
26.5,
26.700000000000003,
26.9,
27.1,
27.300000000000004,
27.5,
27.700000000000003,
27.9,
28.1,
28.300000000000004,
28.5,
28.700000000000003,
28.9,
29.1,
29.300000000000004,
29.5,
29.700000000000003,
29.9,
30.1,
30.300000000000004,
30.5,
30.700000000000003,
30.9,
31.1,
31.300000000000004,
31.5,
31.700000000000003,
31.9,
32.1,
32.3,
32.5,
32.7,
32.900000000000006,
33.1,
33.3,
33.5,
33.7,
33.900000000000006,
34.1,
34.3,
34.5,
34.7,
34.900000000000006,
35.1,
35.3,
35.5,
35.7,
35.900000000000006,
36.1,
36.3,
36.5,
36.7,
36.900000000000006,
37.1,
37.3,
37.5,
37.7,
37.900000000000006,
38.1,
38.300000000000004,
38.5,
38.7,
38.900000000000006,
39.1,
39.300000000000004,
39.5,
39.7,
39.900000000000006,
40.1,
40.300000000000004,
40.5,
40.7,
40.900000000000006,
41.1,
41.300000000000004,
41.5,
41.7,
41.900000000000006,
42.1,
42.300000000000004,
42.5,
42.7,
42.900000000000006,
43.1,
43.300000000000004,
43.5,
43.7,
43.900000000000006,
44.1,
44.300000000000004,
44.5,
44.7,
44.900000000000006,
45.1,
45.300000000000004,
45.5,
45.7,
45.900000000000006,
46.1,
46.300000000000004,
46.5,
46.7,
46.900000000000006,
47.1,
47.300000000000004,
47.5,
47.7,
47.900000000000006,
48.1,
48.300000000000004,
48.5,
48.7,
48.900000000000006,
49.1,
49.300000000000004,
49.5,
49.7,
49.900000000000006,
50.1,
50.300000000000004,
50.5,
50.7,
50.900000000000006,
51.1,
51.300000000000004,
51.5,
51.7,
51.900000000000006,
52.1,
52.300000000000004,
52.5,
52.7,
52.900000000000006,
53.1,
53.300000000000004,
53.5,
53.7,
53.900000000000006,
54.1,
54.300000000000004,
54.5,
54.7,
54.900000000000006,
55.1,
55.300000000000004,
55.5,
55.7,
55.900000000000006,
56.1,
56.300000000000004,
56.5,
56.7,
56.900000000000006,
57.1,
57.300000000000004,
57.5,
57.7,
57.900000000000006,
58.1,
58.300000000000004,
58.5,
58.7,
58.900000000000006,
59.1,
59.300000000000004,
59.5,
59.7,
59.900000000000006,
60.1,
60.300000000000004,
60.5,
60.7,
60.900000000000006,
61.1,
61.300000000000004,
61.5,
61.7,
61.900000000000006,
62.1,
62.300000000000004,
62.5,
62.7,
62.900000000000006,
63.1,
63.300000000000004,
63.5,
63.7,
63.900000000000006,
64.1,
64.30000000000001,
64.5,
64.7,
64.9,
65.1,
65.30000000000001,
65.5,
65.7,
65.9,
66.1,
66.30000000000001,
66.5,
66.7,
66.9,
67.1,
67.30000000000001,
67.5,
67.7,
67.9,
68.1,
68.30000000000001,
68.5,
68.7,
68.9,
69.1,
69.30000000000001,
69.5,
69.7,
69.9,
70.1,
70.30000000000001,
70.5,
70.7,
70.9,
71.1,
71.30000000000001,
71.5,
71.7,
71.9,
72.1,
72.30000000000001,
72.5,
72.7,
72.9,
73.1,
73.30000000000001,
73.5,
73.7,
73.9,
74.1,
74.30000000000001,
74.5,
74.7,
74.9,
75.1,
75.30000000000001,
75.5,
75.7,
75.9,
76.1,
76.30000000000001,
76.5,
76.70000000000002,
76.9,
77.1,
77.30000000000001,
77.5,
77.70000000000002,
77.9,
78.1,
78.30000000000001,
78.5,
78.70000000000002,
78.9,
79.1,
79.30000000000001,
79.5,
79.70000000000002,
79.9,
80.1,
80.30000000000001,
80.5,
80.70000000000002,
80.9,
81.1,
81.30000000000001,
81.5,
81.70000000000002,
81.9,
82.1,
82.30000000000001,
82.5,
82.70000000000002,
82.9,
83.1,
83.30000000000001,
83.5,
83.70000000000002,
83.9,
84.1,
84.30000000000001,
84.5,
84.70000000000002,
84.9,
85.1,
85.30000000000001,
85.5,
85.70000000000002,
85.9,
86.1,
86.30000000000001,
86.5,
86.70000000000002,
86.9,
87.1,
87.30000000000001,
87.5,
87.70000000000002,
87.9,
88.1,
88.30000000000001,
88.5,
88.70000000000002,
88.9,
89.1,
89.30000000000001,
89.5,
89.70000000000002,
89.9,
90.1,
90.30000000000001,
90.5,
90.70000000000002,
90.9,
91.1,
91.30000000000001,
91.5,
91.70000000000002,
91.9,
92.1,
92.30000000000001,
92.5,
92.70000000000002,
92.9,
93.1,
93.30000000000001,
93.5,
93.70000000000002,
93.9,
94.1,
94.30000000000001,
94.5,
94.70000000000002,
94.9,
95.1,
95.30000000000001,
95.5,
95.70000000000002,
95.9,
96.1,
96.30000000000001,
96.5,
96.70000000000002,
96.9,
97.1,
97.30000000000001,
97.5,
97.70000000000002,
97.9,
98.1,
98.30000000000001,
98.5,
98.70000000000002,
98.9,
99.1,
99.30000000000001,
99.5,
99.70000000000002,
99.9,
100.1,
100.30000000000001,
100.5,
100.70000000000002,
100.9,
101.1,
101.30000000000001,
101.5,
101.70000000000002,
101.9,
102.1,
102.30000000000001,
102.5,
102.70000000000002,
102.9,
103.1,
103.30000000000001,
103.5,
103.70000000000002,
103.9,
104.1,
104.30000000000001,
104.5,
104.70000000000002,
104.9,
105.1,
105.30000000000001,
105.5,
105.70000000000002,
105.9,
106.1,
106.30000000000001,
106.5,
106.70000000000002,
106.9,
107.1,
107.30000000000001,
107.5,
107.70000000000002,
107.9,
108.1,
108.30000000000001,
108.5,
108.70000000000002,
108.9,
109.1,
109.30000000000001,
109.5,
109.70000000000002,
109.9,
110.1,
110.30000000000001,
110.5,
110.70000000000002,
110.9,
111.1,
111.30000000000001,
111.5,
111.70000000000002,
111.9,
112.1,
112.30000000000001,
112.5,
112.70000000000002,
112.9,
113.1,
113.30000000000001,
113.5,
113.70000000000002,
113.9,
114.1,
114.30000000000001,
114.5,
114.70000000000002,
114.9,
115.1,
115.30000000000001,
115.5,
115.70000000000002,
115.9,
116.1,
116.30000000000001,
116.5,
116.70000000000002,
116.9,
117.1,
117.30000000000001,
117.5,
117.70000000000002,
117.9,
118.1,
118.30000000000001,
118.5,
118.70000000000002,
118.9,
119.1,
119.30000000000001,
119.5,
119.70000000000002,
119.9,
120.1,
120.30000000000001,
120.5,
120.70000000000002,
120.9,
121.1,
121.30000000000001,
121.5,
121.70000000000002,
121.9,
122.1,
122.30000000000001,
122.5,
122.70000000000002,
122.9,
123.1,
123.30000000000001,
123.5,
123.70000000000002,
123.9,
124.1,
124.30000000000001,
124.5,
124.70000000000002,
124.9,
125.1,
125.30000000000001,
125.5,
125.70000000000002,
125.9,
126.1,
126.30000000000001,
126.5,
126.70000000000002,
126.9,
127.1,
127.30000000000001,
127.5,
127.70000000000002,
127.9,
128.10000000000002,
128.3,
128.5,
128.7,
128.9,
129.10000000000002,
129.3,
129.5,
129.7,
129.9,
130.10000000000002,
130.3,
130.5,
130.7,
130.9,
131.10000000000002,
131.3,
131.5,
131.7,
131.9,
132.10000000000002,
132.3,
132.5,
132.7,
132.9,
133.10000000000002,
133.3,
133.5,
133.7,
133.9,
134.10000000000002,
134.3,
134.5,
134.7,
134.9,
135.10000000000002,
135.3,
135.5,
135.7,
135.9,
136.10000000000002,
136.3,
136.5,
136.7,
136.9,
137.10000000000002,
137.3,
137.5,
137.7,
137.9,
138.10000000000002,
138.3,
138.5,
138.7,
138.9,
139.10000000000002,
139.3,
139.5,
139.7,
139.9,
140.10000000000002,
140.3,
140.5,
140.7,
140.9,
141.10000000000002,
141.3,
141.5,
141.7,
141.9,
142.10000000000002,
142.3,
142.5,
142.7,
142.9,
143.10000000000002,
143.3,
143.5,
143.7,
143.9,
144.10000000000002,
144.3,
144.5,
144.7,
144.9,
145.10000000000002,
145.3,
145.5,
145.7,
145.9,
146.10000000000002,
146.3,
146.5,
146.7,
146.9,
147.10000000000002,
147.3,
147.5,
147.7,
147.9,
148.10000000000002,
148.3,
148.5,
148.7,
148.9,
149.10000000000002,
149.3,
149.5,
149.7,
149.9,
150.10000000000002,
150.3,
150.5,
150.7,
150.9,
151.10000000000002,
151.3,
151.5,
151.7,
151.9,
152.10000000000002,
152.3,
152.5,
152.7,
152.9,
153.10000000000002,
153.3,
153.5,
153.70000000000002,
153.9,
154.10000000000002,
154.3,
154.5,
154.70000000000002,
154.9,
155.10000000000002,
155.3,
155.5,
155.70000000000002,
155.9,
156.10000000000002,
156.3,
156.5,
156.70000000000002,
156.9,
157.10000000000002,
157.3,
157.5,
157.70000000000002,
157.9,
158.10000000000002,
158.3,
158.5,
158.70000000000002,
158.9,
159.10000000000002,
159.3,
159.5,
159.70000000000002,
159.9,
160.10000000000002,
160.3,
160.5,
160.70000000000002,
160.9,
161.10000000000002,
161.3,
161.5,
161.70000000000002,
161.9,
162.10000000000002,
162.3,
162.5,
162.70000000000002,
162.9,
163.10000000000002,
163.3,
163.5,
163.70000000000002,
163.9,
164.10000000000002,
164.3,
164.5,
164.70000000000002,
164.9,
165.10000000000002,
165.3,
165.5,
165.70000000000002,
165.9,
166.10000000000002,
166.3,
166.5,
166.70000000000002,
166.9,
167.10000000000002,
167.3,
167.5,
167.70000000000002,
167.9,
168.10000000000002,
168.3,
168.5,
168.70000000000002,
168.9,
169.10000000000002,
169.3,
169.5,
169.70000000000002,
169.9,
170.10000000000002,
170.3,
170.5,
170.70000000000002,
170.9,
171.10000000000002,
171.3,
171.5,
171.70000000000002,
171.9,
172.10000000000002,
172.3,
172.5,
172.70000000000002,
172.9,
173.10000000000002,
173.3,
173.5,
173.70000000000002,
173.9,
174.10000000000002,
174.3,
174.5,
174.70000000000002,
174.9,
175.10000000000002,
175.3,
175.5,
175.70000000000002,
175.9,
176.10000000000002,
176.3,
176.5,
176.70000000000002,
176.9,
177.10000000000002,
177.3,
177.5,
177.70000000000002,
177.9,
178.10000000000002,
178.3,
178.5,
178.70000000000002,
178.9,
179.10000000000002,
179.3,
179.5,
179.70000000000002,
179.9,
180.10000000000002,
180.3,
180.5,
180.70000000000002,
180.9,
181.10000000000002,
181.3,
181.5,
181.70000000000002,
181.9,
182.10000000000002,
182.3,
182.5,
182.70000000000002,
182.9,
183.10000000000002,
183.3,
183.5,
183.70000000000002,
183.9,
184.10000000000002,
184.3,
184.5,
184.70000000000002,
184.9,
185.10000000000002,
185.3,
185.5,
185.70000000000002,
185.9,
186.10000000000002,
186.3,
186.5,
186.70000000000002,
186.9,
187.10000000000002,
187.3,
187.5,
187.70000000000002,
187.9,
188.10000000000002,
188.3,
188.5,
188.70000000000002,
188.9,
189.10000000000002,
189.3,
189.5,
189.70000000000002,
189.9,
190.10000000000002,
190.3,
190.5,
190.70000000000002,
190.9,
191.10000000000002,
191.3,
191.5,
191.70000000000002,
191.9,
192.10000000000002,
192.3,
192.5,
192.70000000000002,
192.9,
193.10000000000002,
193.3,
193.5,
193.70000000000002,
193.9,
194.10000000000002,
194.3,
194.5,
194.70000000000002,
194.9,
195.10000000000002,
195.3,
195.5,
195.70000000000002,
195.9,
196.10000000000002,
196.3,
196.5,
196.70000000000002,
196.9,
197.10000000000002,
197.3,
197.5,
197.70000000000002,
197.9,
198.10000000000002,
198.3,
198.5,
198.70000000000002,
198.9,
199.10000000000002,
199.3,
199.5,
199.70000000000002,
...]
In [166]:
len(q_values)
Out[166]:
100001
In [ ]:
In [147]:
indicators[0].q_levels.index(vect_state[0])
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-147-26c4252ab9ae> in <module>()
----> 1 indicators[0].q_levels.index(vect_state[0])
ValueError: 2.6500000000000004 is not in list
In [ ]:
Content source: mtasende/Machine-Learning-Nanodegree-Capstone
Similar notebooks: