Is there a way to create a dynamic regression model (ARIMAX) with multiple explanatory variables? - dynamic

Is there a way to create a dynamic regression model (ARIMAX) with multiple explanatory variables?
The explanatory variables are introduced into the model with the regression part (xreg()).
(Fit <- auto.arima(Oct_Mar[, "ctr"],
                   xreg = Oct_Mar[, "price_purchase"]))`
As long as I use a variable it works to create the model.
As soon as I want to use several variables:
(Fit <- auto.arima(Oct_Mar[, "ctr"],
xreg = Oct_Mar[, "price_purchase"],
xreg = Oct_Mar[, "price_view"],
xreg = Oct_Mar[, "price_cart"]))`
Error:
Error in auto.arima(Oct_Mar[, "ctr"], xreg = Oct_Mar[, "price_purchase"], :
formal argument "xreg" matched by multiple actual arguments
When I try it like this:
(Fit <- auto.arima(Oct_Mar[, "ctr"],
xreg = Oct_Mar[, 2:6])) `
Error:
Error in auto.arima(Oct_Mar[, "ctr"], xreg = Oct_Mar[, 2:6]) :
xreg should be a numeric matrix or a numeric vector
All chosen variables should be numeric.
Data Subset:
structure(list(date = c("2019.10.01", "2019.10.02", "2019.10.03",
"2019.10.04", "2019.10.05", "2019.10.06", "2019.10.07", "2019.10.08",
"2019.10.09", "2019.10.10", "2019.10.11", "2019.10.12", "2019.10.13",
"2019.10.14", "2019.10.15", "2019.10.16", "2019.10.17", "2019.10.18",
"2019.10.19", "2019.10.20", "2019.10.21", "2019.10.22", "2019.10.23",
"2019.10.24", "2019.10.25", "2019.10.26", "2019.10.27", "2019.10.28",
"2019.10.29", "2019.10.30", "2019.10.31", "2019.11.01", "2019.11.02",
"2019.11.03", "2019.11.04", "2019.11.05", "2019.11.06", "2019.11.07",
"2019.11.08", "2019.11.09", "2019.11.10", "2019.11.11", "2019.11.12",
"2019.11.13", "2019.11.14", "2019.11.15", "2019.11.16", "2019.11.17",
"2019.11.18", "2019.11.19", "2019.11.20", "2019.11.21", "2019.11.22",
"2019.11.23", "2019.11.24", "2019.11.25", "2019.11.26", "2019.11.27",
"2019.11.28", "2019.11.29", "2019.11.30", "2019.12.01", "2019.12.02",
"2019.12.03", "2019.12.04", "2019.12.05", "2019.12.06", "2019.12.07",
"2019.12.08", "2019.12.09", "2019.12.10", "2019.12.11", "2019.12.12",
"2019.12.13", "2019.12.14", "2019.12.15", "2019.12.16", "2019.12.17",
"2019.12.18", "2019.12.19", "2019.12.20", "2019.12.21", "2019.12.22",
"2019.12.23", "2019.12.24", "2019.12.25", "2019.12.26", "2019.12.27",
"2019.12.28", "2019.12.29", "2019.12.30", "2019.12.31", "2020.01.01",
"2020.01.02", "2020.01.03", "2020.01.04", "2020.01.05", "2020.01.06",
"2020.01.07", "2020.01.08", "2020.01.09", "2020.01.10", "2020.01.11",
"2020.01.12", "2020.01.13", "2020.01.14", "2020.01.15", "2020.01.16",
"2020.01.17", "2020.01.18", "2020.01.19", "2020.01.20", "2020.01.21",
"2020.01.22", "2020.01.23", "2020.01.24", "2020.01.25", "2020.01.26",
"2020.01.27", "2020.01.28", "2020.01.29", "2020.01.30", "2020.01.31",
"2020.02.01", "2020.02.02", "2020.02.03", "2020.02.04", "2020.02.05",
"2020.02.06", "2020.02.07", "2020.02.08", "2020.02.09", "2020.02.10",
"2020.02.11", "2020.02.12", "2020.02.13", "2020.02.14", "2020.02.15",
"2020.02.16", "2020.02.17", "2020.02.18", "2020.02.19", "2020.02.20",
"2020.02.21", "2020.02.22", "2020.02.23", "2020.02.24", "2020.02.25",
"2020.02.26", "2020.02.27", "2020.02.28", "2020.02.29", "2020.03.01",
"2020.03.02", "2020.03.03", "2020.03.04", "2020.03.05", "2020.03.06",
"2020.03.07", "2020.03.08", "2020.03.09", "2020.03.10", "2020.03.11",
"2020.03.12", "2020.03.13", "2020.03.14", "2020.03.15", "2020.03.16",
"2020.03.17", "2020.03.18", "2020.03.19", "2020.03.20", "2020.03.21",
"2020.03.22", "2020.03.23", "2020.03.24", "2020.03.25", "2020.03.26",
"2020.03.27", "2020.03.28", "2020.03.29", "2020.03.30", "2020.03.31"
), price_view = c(35.79, 180.16, 437.57, 10.3, 74.26, 79.8, 89.84,
121.24, 461.95, 142.06, 241.71, 52, 43.24, 41.16, 167.05, 764.06,
91.64, 189.82, 38.59, 152.64, 86.23, 321.33, 411.83, 256.88,
352.39, 76.32, 360.11, 123.53, 43.41, 149.38, 14.16, 489.07,
1661.74, 1253.07, 25.71, 154.42, 990.89, 1645.93, 144.12, 84.43,
240.25, 148.18, 41.13, 262.56, 168.78, 860.85, 239.31, 372.98,
165.64, 134.32, 20.7, 43.73, 765.76, 51.48, 599.49, 893.79, 155.29,
334.37, 46.82, 1814.72, 196.27, 1302.48, 40.16, 1161.68, 381.48,
184.48, 48.91, 221.11, 434.73, 149.27, 77.22, 882.49, 106.05,
669.23, 282.86, 179.67, 12.97, 460.24, 38.59, 278.26, 243.76,
1904.79, 84.93, 32.18, 25.71, 496.54, 29.6, 1466.83, 164.33,
234.76, 19.95, 308.37, 1130.02, 7.47, 79.8, 65.9, 746.45, 1347.78,
1270.82, 69.42, 231.41, 195.6, 715.33, 208.47, 720.46, 414.68,
24.45, 217.82, 434.45, 483.92, 1500.42, 318.15, 339.29, 267.45,
133.85, 9.03, 11.81, 280.57, 916.74, 58.51, 339.78, 33.98, 263.58,
19.31, 239.88, 489.07, 84.92, 344.9, 95.24, 99.1, 142.58, 480.58,
104.74, 14.83, 252, 1039.41, 28.3, 328.97, 341.55, 278.26, 43.73,
91.35, 102.32, 131.25, 155.15, 77.74, 14.67, 132.63, 1185.36,
291.13, 1106.59, 849.42, 117.63, 171.32, 167.31, 252.23, 248.14,
111.15, 257.15, 27.62, 169.86, 101.89, 282.89, 298.57, 86.49,
196.32, 1415.45, 898.35, 334.6, 17.99, 13.62, 566.27, 60.41,
36.34, 62.04, 308.81, 32.95, 127.44, 836.57, 221.34, 360.34,
159.31, 20.57), view = c(1206151, 1152770, 1087372, 1344804,
1270060, 1262993, 1159265, 1323522, 1301376, 1240347, 1445162,
1432321, 1583572, 1376274, 1462409, 1443323, 1337174, 1413405,
1382403, 1443838, 1342668, 1353053, 1318395, 1252747, 1369922,
1288939, 1330209, 1220710, 1187883, 1169955, 1207854, 1402754,
1513400, 1524803, 1743304, 1670637, 1644359, 1748812, 1789808,
1783142, 1845552, 1907417, 1892753, 1920411, 2864410, 5691766,
5986292, 5759703, 1905351, 1627672, 1598554, 1573101, 1471242,
1474138, 1500022, 1496128, 1557252, 1547199, 1560191, 1727852,
1644405, 1706901, 1629904, 1547658, 1468085, 1540157, 1652208,
1725106, 1724452, 1627222, 1651328, 1605421, 1650612, 1634861,
1760750, 2167056, 2875847, 2780816, 2665285, 2528244, 2387520,
2340327, 2471739, 2372930, 2326654, 2322753, 2240514, 2058141,
2089081, 2474226, 2294820, 1603749, 1427733, 1700904, 1765457,
1754424, 1738774, 1696188, 1701769, 1585870, 1556542, 1557542,
1618230, 1645866, 1627433, 1612956, 1555416, 1773179, 1826768,
2021676, 2104199, 1801073, 1733142, 1593991, 1645225, 1557626,
1637470, 1721003, 1545472, 1594688, 1565742, 1651606, 1999670,
2217825, 1985751, 1680034, 1608904, 1620473, 1628906, 1726835,
1589058, 1714745, 1751044, 1896265, 2429526, 2268487, 1935249,
1916034, 2239698, 1916650, 1981570, 1948648, 1987134, 1749514,
1822349, 1830307, 1748590, 1734610, 1798308, 162557, 1000204,
1257475, 1770064, 2416707, 2477258, 2487470, 2457500, 2210539,
2377633, 2026050, 2301337, 2218894, 2012789, 1700619, 1481115,
1562027, 1560348, 1338829, 1244973, 1142989, 1260747, 1316975,
1387394, 1319559, 1440470, 1451015, 1439649, 1390411, 1336076,
1369834, 1255626, 1244163, 1283731), price_cart = c(29.51, 1415.48,
99.86, 358.57, 617.51, 1052.79, 1747.79, 190.56, 128.28, 252.38,
250.91, 720.48, 33.42, 643, 191.77, 460.11, 408.5, 789.9, 577.94,
49.36, 380.7, 19.56, 994.86, 756.71, 223.66, 437.33, 1684.28,
366.16, 968.34, 1683.07, 550.77, 503.09, 29.09, 179.67, 210.62,
22.66, 131.66, 68.96, 360.06, 494.22, 1023.62, 1569.92, 28.29,
694.97, 127.05, 37.85, 282.89, 178.9, 913.28, 1022.42, 424.7,
573.7, 1029.34, 30.12, 20.82, 17.99, 107.53, 41.19, 85.82, 1002.55,
140.98, 167.03, 231.67, 25.71, 205.64, 30.81, 51.22, 65.9, 7.08,
308.63, 227.79, 16.22, 7.89, 62.52, 48.88, 586.63, 602.07, 1312.26,
128.32, 179.9, 849.42, 100.9, 1284.2, 12.84, 128.42, 59.18, 176.99,
38.02, 48.88, 694.54, 262.3, 1402.84, 1453.18, 3.84, 453.01,
76.93, 7.04, 865.93, 865.4, 40.75, 1423.07, 1534.66, 679.27,
11.25, 102.63, 436.3, 853.93, 694.97, 850.47, 477.49, 1234.97,
10.27, 23.94, 643.23, 89.84, 290.34, 320.99, 6.44, 140.28, 188.89,
56.88, 1326.31, 194.34, 140.28, 771.96, 140.03, 20.21, 1464.39,
59.18, 57.92, 1156.81, 50.43, 300.12, 38.1, 832.71, 57.91, 174.5,
100.36, 248.14, 109.34, 100.7, 242.7, 266.67, 592.01, 242.18,
22.66, 566.04, 38.61, 812.06, 123.92, 168.6, 172.03, 49.91, 16.73,
108.04, 347.47, 97.79, 111.15, 514.79, 126.1, 178.87, 870.03,
529.31, 43.5, 2110.48, 771.94, 15.32, 105.25, 7.14, 312.67, 61.75,
165.51, 48.37, 643.49, 303.48, 35.78, 154.42, 209.71, 76.69,
25.46, 1415.45, 123.53, 602.31), cart = c(16658, 17268, 19323,
43826, 35493, 32145, 18052, 18442, 18432, 18997, 21450, 20691,
24833, 44821, 49513, 45272, 40368, 40127, 39455, 40533, 36675,
36945, 36407, 35721, 36800, 34776, 34256, 17838, 17455, 16996,
16798, 18911, 19350, 20211, 21960, 19231, 19670, 19446, 77319,
70093, 71585, 75135, 69669, 71613, 170183, 481862, 405584, 426261,
83117, 72450, 72311, 75530, 70171, 64801, 68099, 71405, 71622,
71324, 71504, 92345, 81760, 84473, 80869, 70192, 66718, 71048,
83618, 84231, 80773, 80675, 81420, 78947, 80162, 82360, 86689,
109721, 183764, 155406, 146906, 137487, 127900, 124577, 127381,
126700, 124797, 127554, 123966, 120940, 127769, 148663, 148608,
119062, 57614, 71342, 95608, 80629, 78782, 79099, 77396, 74671,
72772, 74827, 72221, 73406, 72999, 71182, 70235, 79414, 104791,
103481, 102597, 94354, 90666, 83642, 83223, 73075, 73582, 73849,
70067, 71600, 72179, 130757, 208231, 169156, 137970, 116560,
104701, 102836, 101145, 101605, 90864, 92635, 95114, 100283,
158447, 131720, 118661, 126405, 132399, 98277, 96270, 95284,
96886, 89046, 91384, 89585, 83771, 83241, 84151, 6104, 40574,
48944, 81869, 146953, 135144, 132819, 134255, 131648, 141696,
122204, 122752, 120927, 112159, 102239, 95998, 97600, 99032,
79662, 76622, 69585, 73822, 74488, 75621, 69098, 73761, 76429,
75664, 77671, 77090, 77835, 68888, 69091, 73986), price_purchase = c(130.76,
419.6, 251.74, 252.88, 64.02, 272.59, 172.72, 88.81, 28.73, 1003.86,
346.47, 130.48, 29.86, 280.11, 358.57, 385.83, 287.61, 22.95,
58.08, 854.08, 28.28, 62.91, 994.86, 51.22, 9.01, 77.21, 244.15,
366.16, 366.8, 213.25, 35.52, 566.3, 35.78, 1106.82, 64.35, 722.18,
131.66, 166.1, 823.9, 138.23, 334.6, 328.19, 243.51, 488.8, 159.57,
106.8, 54.03, 27, 308.63, 1022.42, 463.31, 144.66, 44.53, 25.48,
126.18, 365.52, 133.92, 97.27, 12.84, 1002.55, 107.41, 132.31,
131.2, 789.57, 230.2, 12.36, 229.86, 1386.91, 154.19, 18.19,
76.96, 882.49, 191.55, 46.08, 24.17, 102.65, 326.62, 924.06,
923.73, 88.29, 41.16, 128.42, 326.88, 137.96, 30.68, 108.88,
181.19, 241.34, 128.32, 137.46, 1279.81, 643.23, 1275.16, 717.245,
159.33, 745.37, 288.27, 177.26, 168.58, 66.85, 331.51, 437.31,
643.23, 9.3, 0.85, 436.3, 105.51, 7.7, 79.44, 1321.37, 160.89,
107.21, 172.25, 514.79, 141.06, 900.64, 153.22, 924.4, 176.34,
94.98, 162.6, 1326.25, 39.9, 38.15, 2162.22, 180.95, 153.41,
720.48, 720.48, 15.42, 140.28, 514.02, 720.47, 174.7, 197.69,
411.08, 741.07, 230.12, 501.89, 109.34, 643.26, 23.17, 242.48,
1317.36, 69.76, 178.11, 153.55, 32.18, 812.06, 302.2, 153.34,
172.03, 128.68, 939.54, 108.04, 165.89, 56.63, 43.76, 171.17,
98.59, 21.95, 280.28, 181.47, 730.01, 159.31, 60.75, 31.15, 1412.39,
7.14, 942.84, 321.06, 165.51, 284.95, 169.42, 303.48, 224.3,
416.43, 385.85, 492.08, 334.6, 1415.45, 123.53, 308.55), purchase = c(19307,
19469, 19255, 27041, 23494, 22171, 21378, 23072, 22748, 21993,
26224, 25373, 29561, 28405, 26372, 31394, 28318, 25850, 24657,
25098, 25167, 25385, 24731, 23999, 23929, 22653, 23403, 21112,
20374, 20817, 20099, 22458, 21864, 22145, 26889, 24875, 25319,
24863, 25714, 22768, 22878, 24931, 22725, 22548, 22124, 45185.5,
68247, 185195, 28537, 24967, 24947, 25266, 24187, 22243, 23163,
24827, 24226, 24443, 24305, 32107, 28178, 28345, 28548, 24358,
24473, 25469, 27505, 27012, 25766, 26802, 27059, 25906, 26044,
26712, 26559, 35077, 63796, 51899, 49578, 48212, 46405, 44255,
44719, 46602, 44917, 44949, 44154, 43081, 45287, 49597, 50729,
38233, 3574, 13975.5, 24377, 28938, 28427, 28875, 27722, 27510,
26492, 27481, 26059, 25869, 27525, 26322, 27121, 29614, 35086,
32884, 32548, 32619, 31698, 30089, 30398, 27579, 26662, 26880,
27052, 26841, 27403, 27612, 33750, 32536, 32308, 28645, 27652,
28276, 28533, 28426, 25379, 26027, 46480, 60013, 102117, 83216,
76048, 72365, 87586, 63260, 36377, 31438, 31258, 29324, 28946,
29017, 27884, 28063, 27809, 27499, 27490, 26316, 31358, 55087,
46356, 45228, 44406, 43521, 45501, 40281, 41091, 41681, 39266,
36268, 34754, 35341, 35943, 28852, 27810, 25186, 25501, 26232,
25775, 23698, 25314, 25960, 26259, 27487, 26966, 25817, 21294,
22704, 23997), ctr = c(0.0157890561813006, 0.0166396305077271,
0.0173986509381537, 0.0194731497951218, 0.0179954394804347, 0.01711863909483,
0.0181582360570687, 0.0171927115779559, 0.0172358403646591, 0.0174638541971058,
0.0178806664612045, 0.017462347179514, 0.0183790774089859, 0.0199881077619723,
0.0174426987635606, 0.021089685240109, 0.0205569049800296, 0.0177842661874661,
0.0173413941476575, 0.0169081718788632, 0.0182456430344012, 0.0182626162052032,
0.0182543279386951, 0.0186259961442581, 0.0170104683085926, 0.0171132003490177,
0.0171517774365777, 0.0170457664943143, 0.016903142521019, 0.0175382134561578,
0.0164120092891695, 0.0157969704536582, 0.014264557168488, 0.0143332034531726,
0.0152322825367764, 0.0147200846456646, 0.0152154800186776, 0.0140607309566817,
0.0137719608789332, 0.0122855439272407, 0.0119334194687182, 0.0125752060979989,
0.01158007808718, 0.0113191407332442, 0.00729059877222415, 0.00731911608538772,
0.0106771470535411, 0.029937936916542, 0.0143512493034839, 0.0146854166936255,
0.0149305898441825, 0.015325442746133, 0.015691446743994, 0.0144534643673336,
0.0147711815606066, 0.0158382630541111, 0.0148728508159624, 0.015102040564144,
0.0148955533969277, 0.0176392994824187, 0.0163240478169816, 0.0158230497930639,
0.0166871934499785, 0.0150557839107457, 0.0159453688844757, 0.0158074236363467,
0.0158454822084702, 0.0149292254566175, 0.0142730130593139, 0.0156929838274791,
0.0156162350209032, 0.0153802494466767, 0.0150476029799385, 0.015555365325721,
0.0143761174252573, 0.0154064275947974, 0.0208510166815324, 0.0176754346231314,
0.0176296702464377, 0.01808584587117, 0.0184482114318881, 0.0179540460804964,
0.0172054387638893, 0.0186435592467685, 0.0183226179107802, 0.0183442319676677,
0.0186738733252132, 0.0197702609494553, 0.0204285359857455, 0.0189093019186096,
0.0207614056972417, 0.0221922195760301, 0.00240617175649865,
0.00788575626634226, 0.01309841408011, 0.0157695717780358, 0.0156402333683254,
0.0162649757475833, 0.0155814665868539, 0.0165668899473124, 0.0162596037350689,
0.0168350415867981, 0.0154154128099543, 0.0150464847912372, 0.0161870630522126,
0.0156293605393382, 0.0166831626222356, 0.0159851624182969, 0.0181646017543342,
0.0154736802975027, 0.0147489845006063, 0.0172093148404027, 0.0173801189598905,
0.0179353887292393, 0.017586875624838, 0.0169123585500959, 0.0155822266067893,
0.0149761651657073, 0.0167448758587691, 0.0161082597966258, 0.0167303551270177,
0.0154917937591837, 0.015286011465188, 0.0136306070303869, 0.0152129210946259,
0.0159440585908669, 0.0161367409642245, 0.0164079686231546, 0.016492577386447,
0.0155465861608803, 0.0151072490270382, 0.0144004027929932, 0.0251766100192941,
0.0300583807652007, 0.0394582941939502, 0.0346703430162482, 0.0370259651104479,
0.0354306787130485, 0.0369234479028471, 0.0313956783546004, 0.0175071227813499,
0.0153811379243536, 0.0149988963637585, 0.0159494386911496, 0.0151254119566314,
0.0151138709885764, 0.0152175253675449, 0.015437458845637, 0.0147726989007463,
0.163043027137275, 0.0264129334017437, 0.0201436139554002, 0.0169325780144314,
0.0214876387664511, 0.0177445890793224, 0.0172606914733451, 0.017133563936406,
0.0185813515317095, 0.0180607614170281, 0.0187505760492009, 0.0169511102933927,
0.0178137558385877, 0.0184785698285323, 0.0201169476464591, 0.0220364679005246,
0.0212945438945016, 0.021660499704709, 0.0203399246100257, 0.021042755155702,
0.0207706911083365, 0.0191080416224264, 0.0188521002714409, 0.0176177277744931,
0.0170654092407268, 0.0167173964870618, 0.0169957130997929, 0.0173290930652611,
0.018723068602435, 0.0190819762151085, 0.0178334964691514, 0.0160768402598991,
0.0172883539665594, 0.0176745227466401)), row.names = c(NA, -183L
), class = "data.frame")

As the error explains, xreg should be a numeric matrix, not a data frame. The following works.
Fit <- auto.arima(Oct_Mar[, "ctr"], xreg = as.matrix(Oct_Mar[, 2:6]))

Related

Update records on one2many fields in wizard for odoo16

Geting Issue 'TypeError: unhashable type: 'dict' for insert values in one2many field from onchange method in odoo16
My code is below:
class EmployeeAddWizard(models.TransientModel):
_name = 'employee.add.wizard'
line_ids = fields.One2many('employee.goal.add.line', 'wizard_id', string="Lines")
#api.onchange('challenge_id', 'employee_id')
def _onchange_action_goal_add(self):
r = []
value = {}
self.line_ids = {}
if self.challenge_id and self.employee_id:
goal_records = self.env['gamification.challenge.line'].search([('challenge_id', '=', self.challenge_id.id)])
for emp in self.employee_id:
for line in goal_records:
data = {'wizard_id': self.id, # Other table m2o
'goal_definition_id': line.definition_id.id,
'goal_rating': 0.0,
'goal_target': line.target_goal,
'employee_id': emp.id,
}
r.append(data)
value.update(records=r)
self.line_ids = value['records']
class GoalLine(models.Model):
_name = 'employee.goal.add.line'
wizard_id = fields.Integer()
goal_definition_id = fields.Many2one('gamification.goal.definition', string='Goal Definition', required=True, ondelete="cascade")
goal_rating = fields.Float('Rating', required=True)
goal_target = fields.Float('Target Value ', required=True)
employee_id = fields.Many2one('res.users', string="Employee", required=True, ondelete="cascade")
Thanks in advance
You passed a list of dicts which is not valid, you need to use special commands
Example:
r.append(Command.create(data))
or:
r.append((0, 0, data))
You can use Command.clear(), to remove previous lines if needed ( self.line_ids = {} should raise an error: ValueError: Wrong value).
Check this answer

How to create a Dynamic Regression Model (ARIMAX) in R?

I created an ARIMAX model. Unfortunately, the forecasting that is created is not as it should be.
I want to predict the clickthrough rate "ctr" and use 6 explanatory variables.
enter image description here
#Step 4: Fit the forecasting model (ARIMAX) to the data
Fit <- auto.arima(Oct_Mar[, "ctr"], xreg = as.matrix(Oct_Mar[, 2:7]))
#Step 5: Predict values for Apr
Forecast_ctr <- Fit %>% forecast(xreg = as.matrix(Oct_Mar[, 2:7], h=30)
#Step 6: Forecast values
Forecast_ctr
#Step 7: Plot the forecast
autoplot(Forecast_ctr)+ xlab("Anzahl an Tagen")+ ylab("CTR")
Dataset:
structure(list(date = c("2019.10.01", "2019.10.02", "2019.10.03",
"2019.10.04", "2019.10.05", "2019.10.06", "2019.10.07", "2019.10.08",
"2019.10.09", "2019.10.10", "2019.10.11", "2019.10.12", "2019.10.13",
"2019.10.14", "2019.10.15", "2019.10.16", "2019.10.17", "2019.10.18",
"2019.10.19", "2019.10.20", "2019.10.21", "2019.10.22", "2019.10.23",
"2019.10.24", "2019.10.25", "2019.10.26", "2019.10.27", "2019.10.28",
"2019.10.29", "2019.10.30", "2019.10.31", "2019.11.01", "2019.11.02",
"2019.11.03", "2019.11.04", "2019.11.05", "2019.11.06", "2019.11.07",
"2019.11.08", "2019.11.09", "2019.11.10", "2019.11.11", "2019.11.12",
"2019.11.13", "2019.11.14", "2019.11.15", "2019.11.16", "2019.11.17",
"2019.11.18", "2019.11.19", "2019.11.20", "2019.11.21", "2019.11.22",
"2019.11.23", "2019.11.24", "2019.11.25", "2019.11.26", "2019.11.27",
"2019.11.28", "2019.11.29", "2019.11.30", "2019.12.01", "2019.12.02",
"2019.12.03", "2019.12.04", "2019.12.05", "2019.12.06", "2019.12.07",
"2019.12.08", "2019.12.09", "2019.12.10", "2019.12.11", "2019.12.12",
"2019.12.13", "2019.12.14", "2019.12.15", "2019.12.16", "2019.12.17",
"2019.12.18", "2019.12.19", "2019.12.20", "2019.12.21", "2019.12.22",
"2019.12.23", "2019.12.24", "2019.12.25", "2019.12.26", "2019.12.27",
"2019.12.28", "2019.12.29", "2019.12.30", "2019.12.31", "2020.01.01",
"2020.01.02", "2020.01.03", "2020.01.04", "2020.01.05", "2020.01.06",
"2020.01.07", "2020.01.08", "2020.01.09", "2020.01.10", "2020.01.11",
"2020.01.12", "2020.01.13", "2020.01.14", "2020.01.15", "2020.01.16",
"2020.01.17", "2020.01.18", "2020.01.19", "2020.01.20", "2020.01.21",
"2020.01.22", "2020.01.23", "2020.01.24", "2020.01.25", "2020.01.26",
"2020.01.27", "2020.01.28", "2020.01.29", "2020.01.30", "2020.01.31",
"2020.02.01", "2020.02.02", "2020.02.03", "2020.02.04", "2020.02.05",
"2020.02.06", "2020.02.07", "2020.02.08", "2020.02.09", "2020.02.10",
"2020.02.11", "2020.02.12", "2020.02.13", "2020.02.14", "2020.02.15",
"2020.02.16", "2020.02.17", "2020.02.18", "2020.02.19", "2020.02.20",
"2020.02.21", "2020.02.22", "2020.02.23", "2020.02.24", "2020.02.25",
"2020.02.26", "2020.02.27", "2020.02.28", "2020.02.29", "2020.03.01",
"2020.03.02", "2020.03.03", "2020.03.04", "2020.03.05", "2020.03.06",
"2020.03.07", "2020.03.08", "2020.03.09", "2020.03.10", "2020.03.11",
"2020.03.12", "2020.03.13", "2020.03.14", "2020.03.15", "2020.03.16",
"2020.03.17", "2020.03.18", "2020.03.19", "2020.03.20", "2020.03.21",
"2020.03.22", "2020.03.23", "2020.03.24", "2020.03.25", "2020.03.26",
"2020.03.27", "2020.03.28", "2020.03.29", "2020.03.30", "2020.03.31"
), price_view = c(35.79, 180.16, 437.57, 10.3, 74.26, 79.8, 89.84,
121.24, 461.95, 142.06, 241.71, 52, 43.24, 41.16, 167.05, 764.06,
91.64, 189.82, 38.59, 152.64, 86.23, 321.33, 411.83, 256.88,
352.39, 76.32, 360.11, 123.53, 43.41, 149.38, 14.16, 489.07,
1661.74, 1253.07, 25.71, 154.42, 990.89, 1645.93, 144.12, 84.43,
240.25, 148.18, 41.13, 262.56, 168.78, 860.85, 239.31, 372.98,
165.64, 134.32, 20.7, 43.73, 765.76, 51.48, 599.49, 893.79, 155.29,
334.37, 46.82, 1814.72, 196.27, 1302.48, 40.16, 1161.68, 381.48,
184.48, 48.91, 221.11, 434.73, 149.27, 77.22, 882.49, 106.05,
669.23, 282.86, 179.67, 12.97, 460.24, 38.59, 278.26, 243.76,
1904.79, 84.93, 32.18, 25.71, 496.54, 29.6, 1466.83, 164.33,
234.76, 19.95, 308.37, 1130.02, 7.47, 79.8, 65.9, 746.45, 1347.78,
1270.82, 69.42, 231.41, 195.6, 715.33, 208.47, 720.46, 414.68,
24.45, 217.82, 434.45, 483.92, 1500.42, 318.15, 339.29, 267.45,
133.85, 9.03, 11.81, 280.57, 916.74, 58.51, 339.78, 33.98, 263.58,
19.31, 239.88, 489.07, 84.92, 344.9, 95.24, 99.1, 142.58, 480.58,
104.74, 14.83, 252, 1039.41, 28.3, 328.97, 341.55, 278.26, 43.73,
91.35, 102.32, 131.25, 155.15, 77.74, 14.67, 132.63, 1185.36,
291.13, 1106.59, 849.42, 117.63, 171.32, 167.31, 252.23, 248.14,
111.15, 257.15, 27.62, 169.86, 101.89, 282.89, 298.57, 86.49,
196.32, 1415.45, 898.35, 334.6, 17.99, 13.62, 566.27, 60.41,
36.34, 62.04, 308.81, 32.95, 127.44, 836.57, 221.34, 360.34,
159.31, 20.57), view = c(1206151L, 1152770L, 1087372L, 1344804L,
1270060L, 1262993L, 1159265L, 1323522L, 1301376L, 1240347L, 1445162L,
1432321L, 1583572L, 1376274L, 1462409L, 1443323L, 1337174L, 1413405L,
1382403L, 1443838L, 1342668L, 1353053L, 1318395L, 1252747L, 1369922L,
1288939L, 1330209L, 1220710L, 1187883L, 1169955L, 1207854L, 1402754L,
1513400L, 1524803L, 1743304L, 1670637L, 1644359L, 1748812L, 1789808L,
1783142L, 1845552L, 1907417L, 1892753L, 1920411L, 2864410L, 5691766L,
5986292L, 5759703L, 1905351L, 1627672L, 1598554L, 1573101L, 1471242L,
1474138L, 1500022L, 1496128L, 1557252L, 1547199L, 1560191L, 1727852L,
1644405L, 1706901L, 1629904L, 1547658L, 1468085L, 1540157L, 1652208L,
1725106L, 1724452L, 1627222L, 1651328L, 1605421L, 1650612L, 1634861L,
1760750L, 2167056L, 2875847L, 2780816L, 2665285L, 2528244L, 2387520L,
2340327L, 2471739L, 2372930L, 2326654L, 2322753L, 2240514L, 2058141L,
2089081L, 2474226L, 2294820L, 1603749L, 1427733L, 1700904L, 1765457L,
1754424L, 1738774L, 1696188L, 1701769L, 1585870L, 1556542L, 1557542L,
1618230L, 1645866L, 1627433L, 1612956L, 1555416L, 1773179L, 1826768L,
2021676L, 2104199L, 1801073L, 1733142L, 1593991L, 1645225L, 1557626L,
1637470L, 1721003L, 1545472L, 1594688L, 1565742L, 1651606L, 1999670L,
2217825L, 1985751L, 1680034L, 1608904L, 1620473L, 1628906L, 1726835L,
1589058L, 1714745L, 1751044L, 1896265L, 2429526L, 2268487L, 1935249L,
1916034L, 2239698L, 1916650L, 1981570L, 1948648L, 1987134L, 1749514L,
1822349L, 1830307L, 1748590L, 1734610L, 1798308L, 162557L, 1000204L,
1257475L, 1770064L, 2416707L, 2477258L, 2487470L, 2457500L, 2210539L,
2377633L, 2026050L, 2301337L, 2218894L, 2012789L, 1700619L, 1481115L,
1562027L, 1560348L, 1338829L, 1244973L, 1142989L, 1260747L, 1316975L,
1387394L, 1319559L, 1440470L, 1451015L, 1439649L, 1390411L, 1336076L,
1369834L, 1255626L, 1244163L, 1283731L), price_cart = c(29.51,
1415.48, 99.86, 358.57, 617.51, 1052.79, 1747.79, 190.56, 128.28,
252.38, 250.91, 720.48, 33.42, 643, 191.77, 460.11, 408.5, 789.9,
577.94, 49.36, 380.7, 19.56, 994.86, 756.71, 223.66, 437.33,
1684.28, 366.16, 968.34, 1683.07, 550.77, 503.09, 29.09, 179.67,
210.62, 22.66, 131.66, 68.96, 360.06, 494.22, 1023.62, 1569.92,
28.29, 694.97, 127.05, 37.85, 282.89, 178.9, 913.28, 1022.42,
424.7, 573.7, 1029.34, 30.12, 20.82, 17.99, 107.53, 41.19, 85.82,
1002.55, 140.98, 167.03, 231.67, 25.71, 205.64, 30.81, 51.22,
65.9, 7.08, 308.63, 227.79, 16.22, 7.89, 62.52, 48.88, 586.63,
602.07, 1312.26, 128.32, 179.9, 849.42, 100.9, 1284.2, 12.84,
128.42, 59.18, 176.99, 38.02, 48.88, 694.54, 262.3, 1402.84,
1453.18, 3.84, 453.01, 76.93, 7.04, 865.93, 865.4, 40.75, 1423.07,
1534.66, 679.27, 11.25, 102.63, 436.3, 853.93, 694.97, 850.47,
477.49, 1234.97, 10.27, 23.94, 643.23, 89.84, 290.34, 320.99,
6.44, 140.28, 188.89, 56.88, 1326.31, 194.34, 140.28, 771.96,
140.03, 20.21, 1464.39, 59.18, 57.92, 1156.81, 50.43, 300.12,
38.1, 832.71, 57.91, 174.5, 100.36, 248.14, 109.34, 100.7, 242.7,
266.67, 592.01, 242.18, 22.66, 566.04, 38.61, 812.06, 123.92,
168.6, 172.03, 49.91, 16.73, 108.04, 347.47, 97.79, 111.15, 514.79,
126.1, 178.87, 870.03, 529.31, 43.5, 2110.48, 771.94, 15.32,
105.25, 7.14, 312.67, 61.75, 165.51, 48.37, 643.49, 303.48, 35.78,
154.42, 209.71, 76.69, 25.46, 1415.45, 123.53, 602.31), cart = c(16658L,
17268L, 19323L, 43826L, 35493L, 32145L, 18052L, 18442L, 18432L,
18997L, 21450L, 20691L, 24833L, 44821L, 49513L, 45272L, 40368L,
40127L, 39455L, 40533L, 36675L, 36945L, 36407L, 35721L, 36800L,
34776L, 34256L, 17838L, 17455L, 16996L, 16798L, 18911L, 19350L,
20211L, 21960L, 19231L, 19670L, 19446L, 77319L, 70093L, 71585L,
75135L, 69669L, 71613L, 170183L, 481862L, 405584L, 426261L, 83117L,
72450L, 72311L, 75530L, 70171L, 64801L, 68099L, 71405L, 71622L,
71324L, 71504L, 92345L, 81760L, 84473L, 80869L, 70192L, 66718L,
71048L, 83618L, 84231L, 80773L, 80675L, 81420L, 78947L, 80162L,
82360L, 86689L, 109721L, 183764L, 155406L, 146906L, 137487L,
127900L, 124577L, 127381L, 126700L, 124797L, 127554L, 123966L,
120940L, 127769L, 148663L, 148608L, 119062L, 57614L, 71342L,
95608L, 80629L, 78782L, 79099L, 77396L, 74671L, 72772L, 74827L,
72221L, 73406L, 72999L, 71182L, 70235L, 79414L, 104791L, 103481L,
102597L, 94354L, 90666L, 83642L, 83223L, 73075L, 73582L, 73849L,
70067L, 71600L, 72179L, 130757L, 208231L, 169156L, 137970L, 116560L,
104701L, 102836L, 101145L, 101605L, 90864L, 92635L, 95114L, 100283L,
158447L, 131720L, 118661L, 126405L, 132399L, 98277L, 96270L,
95284L, 96886L, 89046L, 91384L, 89585L, 83771L, 83241L, 84151L,
6104L, 40574L, 48944L, 81869L, 146953L, 135144L, 132819L, 134255L,
131648L, 141696L, 122204L, 122752L, 120927L, 112159L, 102239L,
95998L, 97600L, 99032L, 79662L, 76622L, 69585L, 73822L, 74488L,
75621L, 69098L, 73761L, 76429L, 75664L, 77671L, 77090L, 77835L,
68888L, 69091L, 73986L), price_purchase = c(130.76, 419.6, 251.74,
252.88, 64.02, 272.59, 172.72, 88.81, 28.73, 1003.86, 346.47,
130.48, 29.86, 280.11, 358.57, 385.83, 287.61, 22.95, 58.08,
854.08, 28.28, 62.91, 994.86, 51.22, 9.01, 77.21, 244.15, 366.16,
366.8, 213.25, 35.52, 566.3, 35.78, 1106.82, 64.35, 722.18, 131.66,
166.1, 823.9, 138.23, 334.6, 328.19, 243.51, 488.8, 159.57, 106.8,
54.03, 27, 308.63, 1022.42, 463.31, 144.66, 44.53, 25.48, 126.18,
365.52, 133.92, 97.27, 12.84, 1002.55, 107.41, 132.31, 131.2,
789.57, 230.2, 12.36, 229.86, 1386.91, 154.19, 18.19, 76.96,
882.49, 191.55, 46.08, 24.17, 102.65, 326.62, 924.06, 923.73,
88.29, 41.16, 128.42, 326.88, 137.96, 30.68, 108.88, 181.19,
241.34, 128.32, 137.46, 1279.81, 643.23, 1275.16, 717.245, 159.33,
745.37, 288.27, 177.26, 168.58, 66.85, 331.51, 437.31, 643.23,
9.3, 0.85, 436.3, 105.51, 7.7, 79.44, 1321.37, 160.89, 107.21,
172.25, 514.79, 141.06, 900.64, 153.22, 924.4, 176.34, 94.98,
162.6, 1326.25, 39.9, 38.15, 2162.22, 180.95, 153.41, 720.48,
720.48, 15.42, 140.28, 514.02, 720.47, 174.7, 197.69, 411.08,
741.07, 230.12, 501.89, 109.34, 643.26, 23.17, 242.48, 1317.36,
69.76, 178.11, 153.55, 32.18, 812.06, 302.2, 153.34, 172.03,
128.68, 939.54, 108.04, 165.89, 56.63, 43.76, 171.17, 98.59,
21.95, 280.28, 181.47, 730.01, 159.31, 60.75, 31.15, 1412.39,
7.14, 942.84, 321.06, 165.51, 284.95, 169.42, 303.48, 224.3,
416.43, 385.85, 492.08, 334.6, 1415.45, 123.53, 308.55), purchase = c(19307,
19469, 19255, 27041, 23494, 22171, 21378, 23072, 22748, 21993,
26224, 25373, 29561, 28405, 26372, 31394, 28318, 25850, 24657,
25098, 25167, 25385, 24731, 23999, 23929, 22653, 23403, 21112,
20374, 20817, 20099, 22458, 21864, 22145, 26889, 24875, 25319,
24863, 25714, 22768, 22878, 24931, 22725, 22548, 22124, 45185.5,
68247, 185195, 28537, 24967, 24947, 25266, 24187, 22243, 23163,
24827, 24226, 24443, 24305, 32107, 28178, 28345, 28548, 24358,
24473, 25469, 27505, 27012, 25766, 26802, 27059, 25906, 26044,
26712, 26559, 35077, 63796, 51899, 49578, 48212, 46405, 44255,
44719, 46602, 44917, 44949, 44154, 43081, 45287, 49597, 50729,
38233, 3574, 13975.5, 24377, 28938, 28427, 28875, 27722, 27510,
26492, 27481, 26059, 25869, 27525, 26322, 27121, 29614, 35086,
32884, 32548, 32619, 31698, 30089, 30398, 27579, 26662, 26880,
27052, 26841, 27403, 27612, 33750, 32536, 32308, 28645, 27652,
28276, 28533, 28426, 25379, 26027, 46480, 60013, 102117, 83216,
76048, 72365, 87586, 63260, 36377, 31438, 31258, 29324, 28946,
29017, 27884, 28063, 27809, 27499, 27490, 26316, 31358, 55087,
46356, 45228, 44406, 43521, 45501, 40281, 41091, 41681, 39266,
36268, 34754, 35341, 35943, 28852, 27810, 25186, 25501, 26232,
25775, 23698, 25314, 25960, 26259, 27487, 26966, 25817, 21294,
22704, 23997), ctr = c(0.0157890561813006, 0.0166396305077271,
0.0173986509381537, 0.0194731497951218, 0.0179954394804347, 0.01711863909483,
0.0181582360570687, 0.0171927115779559, 0.0172358403646591, 0.0174638541971058,
0.0178806664612045, 0.017462347179514, 0.0183790774089859, 0.0199881077619723,
0.0174426987635606, 0.021089685240109, 0.0205569049800296, 0.0177842661874661,
0.0173413941476575, 0.0169081718788632, 0.0182456430344012, 0.0182626162052032,
0.0182543279386951, 0.0186259961442581, 0.0170104683085926, 0.0171132003490177,
0.0171517774365777, 0.0170457664943143, 0.016903142521019, 0.0175382134561578,
0.0164120092891695, 0.0157969704536582, 0.014264557168488, 0.0143332034531726,
0.0152322825367764, 0.0147200846456646, 0.0152154800186776, 0.0140607309566817,
0.0137719608789332, 0.0122855439272407, 0.0119334194687182, 0.0125752060979989,
0.01158007808718, 0.0113191407332442, 0.00729059877222415, 0.00731911608538772,
0.0106771470535411, 0.029937936916542, 0.0143512493034839, 0.0146854166936255,
0.0149305898441825, 0.015325442746133, 0.015691446743994, 0.0144534643673336,
0.0147711815606066, 0.0158382630541111, 0.0148728508159624, 0.015102040564144,
0.0148955533969277, 0.0176392994824187, 0.0163240478169816, 0.0158230497930639,
0.0166871934499785, 0.0150557839107457, 0.0159453688844757, 0.0158074236363467,
0.0158454822084702, 0.0149292254566175, 0.0142730130593139, 0.0156929838274791,
0.0156162350209032, 0.0153802494466767, 0.0150476029799385, 0.015555365325721,
0.0143761174252573, 0.0154064275947974, 0.0208510166815324, 0.0176754346231314,
0.0176296702464377, 0.01808584587117, 0.0184482114318881, 0.0179540460804964,
0.0172054387638893, 0.0186435592467685, 0.0183226179107802, 0.0183442319676677,
0.0186738733252132, 0.0197702609494553, 0.0204285359857455, 0.0189093019186096,
0.0207614056972417, 0.0221922195760301, 0.00240617175649865,
0.00788575626634226, 0.01309841408011, 0.0157695717780358, 0.0156402333683254,
0.0162649757475833, 0.0155814665868539, 0.0165668899473124, 0.0162596037350689,
0.0168350415867981, 0.0154154128099543, 0.0150464847912372, 0.0161870630522126,
0.0156293605393382, 0.0166831626222356, 0.0159851624182969, 0.0181646017543342,
0.0154736802975027, 0.0147489845006063, 0.0172093148404027, 0.0173801189598905,
0.0179353887292393, 0.017586875624838, 0.0169123585500959, 0.0155822266067893,
0.0149761651657073, 0.0167448758587691, 0.0161082597966258, 0.0167303551270177,
0.0154917937591837, 0.015286011465188, 0.0136306070303869, 0.0152129210946259,
0.0159440585908669, 0.0161367409642245, 0.0164079686231546, 0.016492577386447,
0.0155465861608803, 0.0151072490270382, 0.0144004027929932, 0.0251766100192941,
0.0300583807652007, 0.0394582941939502, 0.0346703430162482, 0.0370259651104479,
0.0354306787130485, 0.0369234479028471, 0.0313956783546004, 0.0175071227813499,
0.0153811379243536, 0.0149988963637585, 0.0159494386911496, 0.0151254119566314,
0.0151138709885764, 0.0152175253675449, 0.015437458845637, 0.0147726989007463,
0.163043027137275, 0.0264129334017437, 0.0201436139554002, 0.0169325780144314,
0.0214876387664511, 0.0177445890793224, 0.0172606914733451, 0.017133563936406,
0.0185813515317095, 0.0180607614170281, 0.0187505760492009, 0.0169511102933927,
0.0178137558385877, 0.0184785698285323, 0.0201169476464591, 0.0220364679005246,
0.0212945438945016, 0.021660499704709, 0.0203399246100257, 0.021042755155702,
0.0207706911083365, 0.0191080416224264, 0.0188521002714409, 0.0176177277744931,
0.0170654092407268, 0.0167173964870618, 0.0169957130997929, 0.0173290930652611,
0.018723068602435, 0.0190819762151085, 0.0178334964691514, 0.0160768402598991,
0.0172883539665594, 0.0176745227466401)), row.names = c(NA, -183L
), class = "data.frame")

Add values on One2many field onchange

I'm trying to add values in my one2many field onchange.
I tried using the [(0,0, {values})] but nothing happened. Any idea on how to implement it?
custom_line_ids = fields.One2many('mrp.production', 'product_id', 'Custom Line')
#api.onchange('product_id')
def add_custom_line_ids(self):
mrp = self.env['mrp.productions'].search([])
result = []
vals = {
'sequence': self.sequence,
'name': self.name,
'product_id': self.product_id,
'date_planned_start': self.date_planned_start,
'state': self.state,
}
self.update({'custom_line_ids':[(0, 0, vals)]})
Actually you are using update method, which only update the model's value but not yet stored on database. You should use write method instead.
You need to return the value in onchange. This would work:
custom_line_ids = fields.One2many('mrp.production', 'product_id', 'Custom Line')
#api.onchange('product_id')
def add_custom_line_ids(self):
vals = {}
mrp_ids = self.env['mrp.productions'].search([])
if mrp_ids:
for mrp in mrp_ids:
vals['custom_line_ids']=[(0,0,{
'date': mrp.date,
})]
return {'value': vals}

Add labels to estimator.export_saved_model when exporting a keras model for google cloud

I am trying to export a hdf5 model created by Keras training to Google cloud ML Engine. I have everything except the labels after making an online prediction and I would like to have the labels with probability after making a prediction.
Here is my code after the training and the creation of an hdf5 model with Keras.
First, I create an estimator from a keras model.
estimator = keras.estimator.model_to_estimator(
keras_model_path="model.hdf5",
model_dir="output/")
Now, I export the model like this:
estimator.export_saved_model(
"output/model"
serving_input_receiver_fn=serving_input_receiver_fn)
with the function serving_input_receiver_fn that will allow me to accept a base 64 json file as input for an online prediction with google cloud.
def serving_input_receiver_fn():
def prepare_image(image_str_tensor):
image = tf.image.decode_jpeg(image_str_tensor, channels=3)
return image_preprocessing(image)
input_ph = tf.placeholder(tf.string, shape=[None])
images_tensor = tf.map_fn(
prepare_image, input_ph, back_prop=False, dtype=tf.uint8)
images_tensor = tf.image.convert_image_dtype(images_tensor,
dtype=tf.float32)
return tf.estimator.export.ServingInputReceiver(
{'input_1': images_tensor},
{'image_bytes': input_ph})
However, I want to have a classification result with the labels ( I have around 10 classes in my results ). Now my only result is like this :
{"input_1": [0.001,0.9,...]}
I would like to have the result with the labels. Is it possible to do it with a small change and not by doing an other training but by keeping my hdf5 model file ?
Thank you in advance.
We had similar requirement for a demo:
I have a dictionary of classes:
https://gist.github.com/yrevar/942d3a0ac09ec9e5eb3a
{0: 'tench, Tinca tinca',
1: 'goldfish, Carassius auratus', ...}
and so on.
I did the conversion at client level:
def get_classes():
url = 'https://gist.githubusercontent.com/yrevar/942d3a0ac09ec9e5eb3a/raw' \
'/238f720ff059c1f82f368259d1ca4ffa5dd8f9f5' \
'/imagenet1000_clsidx_to_labels.txt'
response = requests.get(url)
classes = literal_eval(response.text)
return classes
...
classes = get_classes()
response = model_predict(predict_request)
if response:
prediction_class = response.get('predictions')[0].get('classes') - 1
prediction_probabilities = response.get('predictions')[0].get('probabilities')
print(
'Prediction: [%d] %s Probability [%.2f] ' % (
prediction_class, classes[prediction_class], max(prediction_probabilities)))
Code here:
https://github.com/GoogleCloudPlatform/ml-on-gcp/blob/master/dlvm/nvidia/inference.py
Response looks like this:
{'predictions': [{'probabilities': [1.55508e-05, 8.52272e-05, 0.000124575, 0.000202289, 7.25561e-05, 0.00125153, 0.000195685, 0.000298364, 6.305e-05, 0.000101759, 0.000189796, 9.83266e-06, 6.09115e-06, 2.93628e-05, 3.79306e-05, 1.80906e-05, 3.27449e-05, 1.44569e-05, 2.08072e-05, 0.000211307, 2.92737e-05, 2.62217e-05, 5.72919e-05, 0.000113042, 2.7489e-05, 4.75314e-05, 3.24912e-05, 9.47271e-06, 0.000175823, 1.07195e-05, 2.23769e-05, 2.77867e-05, 9.41769e-06, 2.75326e-06, 5.0539e-05, 0.000196899, 1.57362e-05, 9.59799e-05, 3.38195e-05, 7.26347e-06, 6.13557e-05, 5.6595e-05, 2.1883e-05, 3.92613e-05, 2.65449e-05, 5.75036e-05, 0.000152569, 8.00665e-05, 2.52358e-05, 7.63134e-05, 1.58771e-05, 0.00046693, 8.97672e-05, 2.64159e-05, 0.000107967, 0.000105322, 2.51052e-05, 0.000134213, 2.02501e-05, 8.42264e-05, 5.74879e-05, 0.000147237, 8.60201e-05, 0.000159229, 2.82999e-05, 7.0453e-05, 9.804e-05, 1.53984e-05, 0.000442353, 4.83388e-05, 0.000111974, 1.64856e-05, 3.9036e-05, 8.38488e-06, 8.2569e-05, 4.60937e-05, 1.9807e-05, 0.000101196, 0.00014236, 0.000169874, 0.000836153, 9.40354e-05, 4.6951e-05, 0.000131597, 2.86648e-05, 0.000158368, 5.29119e-05, 3.52403e-05, 7.17581e-05, 0.000116447, 0.000253711, 5.35324e-05, 8.56567e-06, 4.87063e-05, 0.000110679, 2.18005e-05, 8.59478e-06, 7.40535e-05, 2.38494e-05, 3.12719e-05, 0.000714874, 0.000145422, 0.000137946, 9.94839e-05, 0.000283478, 0.000357132, 2.73016e-05, 0.0002482, 8.15625e-05, 7.40048e-05, 3.81499e-05, 9.95147e-06, 2.86458e-05, 6.22204e-05, 0.000123885, 8.62779e-05, 3.16152e-05, 2.91354e-05, 5.67827e-05, 0.000652813, 0.000101906, 1.61919e-05, 2.92731e-05, 4.40727e-05, 8.18691e-06, 2.21699e-05, 5.32086e-05, 3.21545e-05, 3.22796e-05, 2.6318e-05, 1.88785e-05, 2.11514e-05, 1.48076e-05, 7.21377e-05, 7.36493e-06, 0.000353744, 0.000141821, 8.97949e-06, 1.61471e-05, 0.000122686, 4.4602e-05, 2.3205e-05, 4.94825e-05, 1.67007e-05, 6.61634e-05, 8.84246e-05, 0.000172353, 7.35944e-05, 0.000391683, 0.000185004, 0.00039224, 0.000324578, 0.000331324, 1.30768e-05, 0.000374572, 9.66308e-05, 0.000116723, 9.00387e-05, 9.85038e-05, 6.74917e-05, 0.000493128, 7.29576e-05, 0.00450054, 0.00298045, 0.00203722, 0.00164224, 0.000846203, 0.00017548, 0.000317891, 0.000788288, 0.000143928, 0.000854663, 0.000351869, 0.000692566, 0.000377429, 0.000629245, 6.21199e-05, 0.000200465, 0.00307031, 0.000723996, 0.000117597, 0.000115785, 5.71359e-05, 0.000496389, 8.51815e-05, 0.000474041, 0.000364161, 2.79947e-05, 6.08602e-05, 0.000209289, 0.00255232, 8.92871e-05, 0.00296907, 0.000557994, 3.34299e-05, 2.18733e-05, 0.00575903, 0.000440953, 0.00127525, 6.44013e-05, 0.0101199, 0.000215603, 4.69506e-05, 0.000803412, 0.0136009, 0.000157733, 0.000238714, 0.000401412, 0.000817349, 0.00053235, 0.00576978, 0.0001202, 0.00019474, 0.00292783, 0.000253787, 0.000986474, 0.000137718, 3.35719e-05, 0.00109508, 3.28824e-05, 0.00050906, 8.51038e-05, 0.000519757, 0.000235538, 0.00788667, 0.00105736, 0.000530407, 0.000325091, 0.00107374, 0.000230244, 0.00076778, 0.000659183, 0.000224508, 0.000202612, 0.000678197, 0.00448022, 0.00289446, 9.32325e-05, 0.00977335, 0.000435942, 0.004958, 0.000386235, 0.00736235, 0.00115626, 0.000177735, 2.56265e-05, 0.0015713, 0.000136755, 0.000602412, 0.0012884, 0.00719902, 0.0119457, 0.000945569, 0.000219249, 0.000347739, 0.00519515, 0.000225742, 0.00246375, 0.000453139, 0.0029661, 0.000804986, 0.000914697, 0.000287989, 0.000264725, 0.000630987, 0.000351136, 0.000733556, 2.37422e-05, 0.000517571, 4.77645e-05, 0.0003319, 0.000405211, 0.000283034, 0.00159746, 0.00177935, 5.88713e-05, 7.11461e-05, 5.91759e-05, 0.000503971, 8.6978e-06, 0.00120087, 0.000813549, 0.000343971, 0.000687556, 0.000340041, 0.000355475, 0.000275208, 0.000696902, 8.2474e-05, 7.0166e-05, 0.000210933, 3.90627e-05, 1.89524e-05, 0.000368501, 0.000351007, 0.00060404, 0.000106084, 0.000331506, 8.32554e-05, 2.15891e-05, 0.000193192, 6.84955e-06, 0.000331523, 3.66652e-05, 1.12194e-05, 1.92205e-05, 2.50185e-05, 5.33112e-05, 1.32986e-05, 8.2467e-05, 5.92258e-05, 0.00283379, 2.84016e-05, 5.96508e-05, 0.000182353, 0.000241587, 4.9405e-05, 0.000256186, 6.64698e-06, 4.18161e-05, 4.28466e-05, 1.34901e-05, 1.77119e-05, 1.13135e-05, 1.55582e-05, 1.01246e-05, 2.15158e-06, 4.84249e-06, 0.000493645, 5.86358e-05, 3.79742e-05, 0.000325346, 0.000130454, 5.81232e-05, 6.95239e-05, 0.000220773, 5.40073e-05, 0.000293129, 9.38502e-05, 3.10892e-05, 0.000135327, 0.000216272, 0.000535513, 0.000271741, 0.000101224, 7.6724e-05, 0.000640805, 0.000273377, 0.00658155, 0.000621818, 0.00113372, 0.000305679, 3.32551e-05, 2.73262e-05, 0.000193103, 0.000359639, 0.00254883, 0.000114939, 5.88418e-05, 8.44255e-05, 8.56286e-05, 0.00014276, 9.35917e-05, 0.000153505, 6.59843e-05, 0.000114629, 0.000208262, 4.78108e-05, 3.78621e-05, 2.35319e-05, 1.77599e-05, 1.24966e-05, 6.25085e-05, 0.000493294, 9.21813e-05, 5.45179e-05, 4.59296e-05, 4.71062e-06, 7.51103e-05, 0.000342672, 0.000133267, 3.98604e-05, 0.000152585, 7.34054e-05, 0.000268039, 3.68195e-05, 0.000300117, 6.67261e-05, 3.72905e-05, 1.53376e-05, 5.58414e-05, 3.97029e-05, 0.00076366, 6.3162e-06, 1.66135e-05, 0.000325842, 0.000388785, 7.0573e-06, 1.1251e-05, 0.000252132, 0.000904097, 5.66675e-05, 5.92502e-05, 0.000555106, 3.88775e-05, 4.98873e-05, 0.000385996, 3.6577e-05, 0.000351803, 0.000243754, 0.0002531, 0.00544143, 0.000563464, 0.00103145, 0.00181722, 0.000466597, 9.86767e-06, 0.000341469, 0.0015705, 0.000206699, 7.92459e-05, 0.000345893, 0.000593111, 3.06207e-05, 8.75688e-05, 3.0376e-05, 0.00197111, 1.03584e-05, 0.000251229, 0.000428186, 2.60413e-05, 1.62735e-05, 0.000118388, 0.000196341, 0.000216079, 0.000269054, 9.98427e-05, 7.99718e-05, 0.000267069, 2.71418e-06, 1.367e-05, 0.000239831, 0.000567004, 0.000292397, 0.000207042, 0.000774038, 0.000156459, 0.00022772, 0.000720916, 0.00062859, 0.00150372, 0.000512822, 0.000119685, 3.59513e-05, 1.95859e-05, 0.000101747, 6.89584e-05, 0.000450811, 0.000977539, 0.000681986, 6.28705e-05, 0.000568139, 0.000504166, 0.000472052, 0.000321606, 0.000639555, 9.82591e-05, 0.000272632, 2.82421e-05, 0.00426243, 0.000141967, 9.05156e-05, 0.000199219, 0.00452672, 3.99683e-05, 0.000368264, 0.0296196, 0.0004709, 7.90032e-05, 0.000176198, 0.000204283, 0.00739515, 1.6471e-05, 4.34332e-05, 0.000124695, 0.000136671, 2.44544e-05, 4.26264e-05, 8.98381e-05, 0.000859267, 0.00728019, 0.00102531, 0.000398277, 0.000125742, 5.01795e-05, 0.000100727, 1.86502e-05, 0.000123926, 0.000238162, 0.000418217, 0.000152855, 0.0018571, 0.000290411, 8.05784e-05, 0.000291634, 0.000174392, 0.000212666, 0.000200596, 6.78554e-05, 0.000258088, 1.28704e-05, 0.000396029, 8.78131e-05, 0.000241314, 0.000312604, 0.000107392, 0.00110502, 0.000166141, 0.000168017, 0.000474729, 6.27281e-05, 3.09645e-05, 2.28196e-05, 0.000283914, 0.00209177, 0.000227949, 0.000394017, 5.04358e-05, 0.00118297, 9.57517e-06, 0.000171489, 0.00078891, 4.71934e-05, 2.50277e-05, 0.000438497, 4.65839e-05, 3.58285e-05, 0.000123489, 0.0143988, 0.000553773, 0.000116806, 0.000316215, 0.000281624, 9.31204e-05, 0.000223639, 0.000307707, 0.000271174, 4.04945e-05, 3.46877e-05, 0.000431537, 0.00151671, 5.3359e-06, 7.53046e-05, 0.000235918, 2.56014e-05, 0.000112486, 0.0014654, 0.000480544, 0.000316342, 0.000544367, 0.000444946, 0.000607547, 0.000481535, 0.000104002, 3.70468e-05, 2.8174e-05, 0.00106104, 5.66228e-05, 0.000109865, 0.000220595, 0.000238312, 0.000102476, 0.000189638, 0.000149645, 0.00118128, 0.000259041, 0.00139206, 8.37191e-05, 0.000226957, 0.000306372, 0.000450006, 0.000106509, 0.000303578, 3.29038e-05, 0.000159814, 9.35702e-05, 0.000326935, 7.2301e-05, 5.81706e-05, 0.000159592, 0.000618135, 0.000134879, 0.000182668, 7.6661e-05, 0.00198678, 0.000125605, 0.000412593, 0.000615485, 4.16444e-05, 0.000203402, 0.00362499, 0.000604073, 0.000812219, 5.87236e-05, 0.000445537, 7.08274e-05, 0.000538608, 0.000330699, 1.94176e-05, 0.000821484, 0.0112315, 0.000932525, 4.65331e-05, 0.000127888, 0.000212339, 9.2608e-05, 0.000237337, 0.000529908, 3.73669e-05, 0.000106617, 0.00372401, 0.00353945, 0.000357516, 0.000152526, 0.000225924, 2.47649e-05, 5.32593e-05, 0.00123404, 0.000897687, 4.55089e-05, 0.000217386, 0.000406262, 3.08005e-05, 0.00455928, 0.000140245, 0.00053089, 0.000170293, 0.000447217, 0.000803549, 5.35199e-05, 4.1243e-05, 5.38527e-05, 0.00086276, 0.000112361, 0.000115841, 0.000209599, 8.73793e-05, 0.015637, 1.19475e-05, 1.12752e-05, 0.00139052, 0.00375697, 0.000647192, 6.92945e-05, 6.92814e-05, 0.00316057, 0.000166111, 0.00758618, 0.000948753, 0.000197994, 5.97069e-05, 0.000606452, 6.79047e-05, 5.83162e-05, 7.09706e-05, 0.00241091, 0.000311754, 8.73588e-05, 4.62264e-05, 7.9378e-05, 0.00141774, 0.00103621, 0.0379155, 0.0388486, 0.000159568, 9.80266e-05, 0.000818292, 0.000181057, 0.000274421, 0.000267676, 0.000226017, 5.04306e-05, 0.000275776, 0.000747819, 0.000149055, 0.0002615, 0.000160578, 8.37152e-05, 1.11533e-05, 9.96574e-05, 6.02464e-05, 0.000143476, 0.000239814, 0.000773004, 0.00441533, 0.000319619, 0.0006442, 5.03002e-05, 1.85892e-05, 8.72792e-06, 0.000120659, 0.00128101, 0.00125803, 7.76589e-05, 0.0045897, 0.000584449, 6.5189e-05, 0.0010469, 9.78898e-05, 1.77179e-05, 3.70118e-05, 5.48802e-06, 0.000212075, 0.000140139, 3.12479e-05, 0.000133606, 6.63303e-05, 0.00745455, 0.000123391, 0.00053998, 0.000146543, 4.19799e-05, 0.000315619, 4.18607e-05, 8.34441e-05, 0.000146504, 0.000260877, 6.31252e-06, 8.27619e-05, 0.00193441, 3.89437e-05, 0.000232354, 0.00077451, 4.3871e-05, 0.000841214, 2.80011e-05, 0.0023251, 0.000533739, 5.10349e-05, 7.1796e-05, 2.07323e-05, 0.000167656, 0.000143678, 0.00014051, 0.000108807, 0.000233951, 0.000541688, 0.000581492, 0.000194971, 6.06314e-05, 7.98194e-05, 0.000168223, 0.000221727, 4.17056e-05, 0.000429627, 0.000114364, 0.000403723, 0.000223281, 0.00434498, 0.000408545, 9.39891e-06, 0.000177339, 0.000601626, 0.000167407, 0.000210305, 0.00486655, 0.000501063, 0.000437227, 0.000286798, 5.71393e-05, 6.61158e-05, 8.59685e-05, 3.14945e-05, 0.000633855, 0.00105124, 0.000168122, 0.000471016, 0.000197255, 0.000241811, 2.63944e-05, 0.000267025, 9.11511e-05, 0.000679203, 0.0557757, 0.00381419, 0.000337966, 0.00482909, 5.72956e-05, 0.000130052, 2.01935e-05, 6.77933e-05, 4.27964e-05, 0.00175907, 0.000649202, 0.000907705, 0.00146462, 0.0166741, 0.0075755, 0.0245835, 4.10026e-06, 0.000940845, 0.000576762, 0.000410642, 0.0242613, 0.00392809, 1.0285e-05, 0.000278193, 8.99299e-05, 0.000228249, 9.60876e-05, 6.41274e-06, 1.52377e-05, 0.000132558, 0.000359305, 0.000768309, 0.000233007, 0.00724834, 4.80489e-05, 3.41695e-05, 0.00499713, 1.23432e-05, 3.43374e-05, 4.30402e-05, 5.59372e-05, 2.3765e-05, 0.00300365, 0.00431638, 0.000161293, 2.90676e-05, 0.000763955, 0.000167918, 0.000183525, 0.000683445, 0.00106749, 2.89752e-05, 0.000364255, 2.42001e-05, 0.00205144, 0.00235832, 0.00116137, 0.00301419, 0.000934434, 0.000845667, 7.64749e-05, 0.000820362, 0.000122261, 9.32608e-05, 0.000223282, 7.85736e-05, 2.60183e-05, 5.02393e-05, 2.43877e-05, 0.0105237, 0.000292717, 0.00139134, 0.00010222, 0.000164221, 3.3359e-05, 6.15358e-05, 8.36216e-05, 0.000747535, 4.55981e-06, 0.000331875, 0.00021054, 0.000624574, 0.000307265, 6.56963e-06, 0.00236067, 0.00044436, 0.000450789, 0.000353041, 0.000100967, 3.37242e-05, 0.00720478, 0.000148686, 3.37161e-05, 0.000218007, 0.000307866, 0.000852728, 1.23465e-05, 0.000321398, 0.00219071, 0.000254209, 0.000577832, 0.000126005, 0.000151009, 9.99839e-05, 0.000903734, 1.52066e-05, 0.000521119, 5.78883e-05, 1.16647e-05, 8.59855e-05, 9.17357e-05, 0.000196617, 1.47663e-05, 4.3448e-05, 0.000330379, 8.82993e-05, 0.00075393, 0.00018865, 2.31207e-05, 4.4101e-05, 0.00244245, 0.000283023, 0.0106583, 0.000117731, 2.23972e-05, 0.000153825, 0.000967888, 0.0001583, 2.60177e-05, 0.000290019, 0.00297588, 0.000398894, 1.71261e-05, 0.00858669, 0.00211729, 1.6242e-05, 0.000301345, 0.00137275, 0.000372956, 3.09104e-05, 0.000351122, 4.80173e-05, 1.63996e-05, 4.22602e-05, 3.19259e-06, 3.63146e-05, 4.45177e-05, 7.56894e-05, 5.70432e-05, 0.000136668, 0.000120945, 7.85435e-05, 4.80372e-05, 9.4714e-06, 0.000304405, 1.76088e-05, 3.26987e-05, 0.00010463, 5.63494e-05, 3.0221e-05, 2.3453e-05, 0.00012479, 8.95265e-06, 6.9025e-05, 1.08093e-05, 0.000699259, 0.000548753, 0.000196507, 0.00022843, 0.00051543, 0.000110283, 0.000173086, 0.000424951, 0.00035482, 1.48939e-05, 1.94998e-05, 0.000484427, 2.33123e-05, 4.86105e-05, 0.000148831, 4.71529e-05, 1.15327e-05, 1.46404e-05, 0.00138581, 9.02665e-05, 4.18611e-05, 0.000265539, 3.91982e-05, 0.0805373, 0.000834312, 0.00716731, 0.000183447, 0.00333792, 0.010186, 0.00180289, 0.00658991, 0.00702397, 0.0418009, 0.00235253, 0.00024491, 0.000449987, 9.01764e-05, 0.000527748, 0.000131736, 3.40312e-05, 0.00435704, 6.92113e-05, 0.000118533, 0.000149927, 4.5531e-05, 3.98839e-05, 5.29356e-06, 4.02724e-05, 2.74253e-05, 8.40502e-05, 6.12322e-05, 0.00344411, 0.000671335], 'classes': 971}]}

Odoo: Two selection fields, second selection depends on the first selected value

I have a model with two selection fields. In the first selection field the user chooses a project, and in second the user chooses a tranche, depends on the selected first field. (for one project, we have many tranche)
I use this declaration to my function:
#api.multi
#api.onchange('project')
def _get_tranche(self):
print res
return res`
If I'll print in console the result of returned value is correct, and I have exactly what I search, but in the view, the second field value does not displays computed values to choose after setting the second field value.
Is there any method to make it work properly?
This is my code:
#api.model
def _get_project(self):
values = {'$top' : 100,
'$filter' : "'name==:1&&parent==null'",
'$params' : '\'["*"]\'' }
response = requests.get('http://localhost:8081/rest/Project/name',
auth=('admin', 'admin'),
params=values)
data = response.json()
res = []
for record in data['__ENTITIES']:
res.append((record['__KEY'], record['name']))
return res
#property
def ret_value(self):
return self.project
#api.multi
#api.onchange('project')
def _get_tranche(self):
if self.ret_value == False:
return []
values = {'$top' : 100,
'$filter' : "'parent.ID==:1'",
'$params' : '\'[' + self.ret_value + ']\'' }
response = requests.get('http://localhost:8081/rest/Project/name',
auth=('admin', 'admin'),
params=values)
data = response.json()
res = []
for record in data['__ENTITIES']:
res.append((record['__KEY'], record['name']))
print res
return res
_columns = {
'name': fields.char("Name", required=True),
'description' : fields.text(),
'project' :fields.selection(selection=_get_project, string="Project"),
'tranche' : fields.selection(selection=_get_tranche, string="Tranche"),
}
NB: a tranche is a project with parent_id (not null) = id of a project, I need do the following: when I select a project X from the first field selection "project", I can select the tranches of this project (project with parent_id=X) from the second field selection "tranche" what I can't understand is the result of print in the console is correct, but in the view the field tranche is empty??!!
Now I am trying this:
_columns = {
'name': fields.char("Name", required=True),
'description' : fields.text(),
'project' :fields.selection(selection=_get_project, string="Project"),
'tranche' : fields.selection(selection=_get_tranche,
string="Tranche", compute='_return_tranche'),
}
#api.depends('project')
def _return_tranche(self):
if self.ret_value == False:
self.tranche = []
return
values = {'$top' : 100,
'$filter' : "'parent.ID==:1'",
'$params' : '\'[' + self.ret_value + ']\'' }
response = requests.get('http://localhost:8081/rest/Project/name',
auth=('admin', 'admin'),
params=values)
data = response.json()
res = []
for record in data['__ENTITIES']:
res.append((str(record['__KEY']),str(record['name'])))
print res
self.tranche = res
return
#api.model
def _get_tranche(self):
values = {'$top' : 100,
'$filter' : "'name==:1&&parent!=null'",
'$params' : '\'["*"]\'' }
response = requests.get('http://localhost:8081/rest/Project/name',
auth=('admin', 'admin'),
params=values)
data = response.json()
res = []
for record in data['__ENTITIES']:
res.append((record['__KEY'], record['name']))
return res
But I get this error
File "/opt/odoo/odoo/openerp/fields.py", line 1529, in convert_to_cache
raise ValueError("Wrong value for %s: %r" % (self, value))
ValueError: Wrong value for crm.lead.tranche: [('6', 'Tranche I'), ('7', 'Tranche II'), ('8', 'Tranche III')]
Help me please...