Quiero saber cuantos tiempos un elemento fue en un intervalo de confianza, que muevo también por consiguiente :
prices_well_predicted = len([x for x in prediction if x in range(lower,upper) for lower,upper in low_CI,upper_CI])
Intento también:
prices_well_predicted = len([x for x,lower,upper in prediction,low_CI,upper_CI if x in range(lower,upper)])
Pero ambos me dan SyntaxError
.
Adjuntos:
El contexto está predicciones que traze con CI, el intervalo de confianza.
Aquí los datos son :
prediction :
[17294.9 17424.2 17465.7 17348.8 17345.8 17037.4 16783. 17067.8 17194.
16655.8 17035.8 16839.2 16829.9 16437.1 16561.1 16641. 16793.7 16366.3
16486.6 16722. 16142.6 17098.2 16608.9 16320.8 15979.2 16328.1 16672.4
16470.4 16536.2 17320.7 16940.8 16595.1 16469.4 16682.7 16443.2 16619.8
16308.8 16355.7 16409.7 16570.4 16174.9 16327.7 16594.8 17177.1 17304.8
17217.6 17064.4 17042.5 16818.5 17293.2 16689.3 17099.6 16870.1 16623.1
17386.8 16928.2 17002.4 17096.2 16745.8 16609.5 17055.7 16974.7 17354.4
17205. 17178.7 17185.1 16966.6 17021.4 17062.3 17238.6 17263.3 17339.3
17455.5 17327.4 17155.1 16824.8 17617.4 17505.7 17709.1 17646.1 17715.1
17008.4 17572.4 17604.8 17815.4 17682.7 17775.5 17726.2 17950.8 17781.6
17504.7 17586.3 17906.2 17640.2 17865.8 17624.9 17579.6 17657.4 17778.5
17578.2 17850.7 17752.1 17199.5 18018.3 18059.1 17525.7 17930.6 17991.3
18032.2 18124.7 17717.3 17623.7 17871. 17956.6 17611.5 18014. 18018.8
17736. 17537.3 17690.9 17880.5 17906.1 17960.1 17976. 17925.6 17611.3
17703.5 17603.8 17820.5 17815.8 17838.2 17622.2 17616.6 17574.3 17852.5
17644.8 17581.2 17452.9 17887. 17439.8 17733.5 17401.7 17799.9 17619.9
17375. 17696.6 17867.1 17156.4 17847.6 17773.4 17376.8 17882.4 17945.
17565.4 17699.5 17985.9 18144. 18100.6 17896.6 17978.6 17872.1 17618.4
17946.2 17824.7 17863.4 17541.2 17776.4 17675.5 17460.5 17746.1 17923.5
17604. 17418.8 17715.7 18074.6 17484.4 17403.9 17327.6 17419.6 17937.6
17734.7 17202.7 17957.8 17967.6 18173.7 17867.6 17364.5 17817.1 17705.
18081.5 18244.3 18158.4 18071.8 17759.6 18055.3 18291.7 18322.6 18300.9
18343. 18230.2 18555.8 17537.3 18175.4 18249. 18408.3 18011.6 18393.1
18296.9 18152.4 17625. 18184.5 18358.4 17681.3 17977.5 18018.9 18228.5
17342. 18301.3 18410.8 18255.2 18330.5 18092.3 18442.2 18281.9 18502.4
17891.7 18272.3 18602.3 18480.2 18066.9 17654.3 18395.6 18162.8 18322.3
18427. 18329.3 18162.2 18046.9 18085.8 17964.4 18206.7 18098.6 18074.6
18217.7 17692.4 18346.3 18090.1 17954. 18466.6 18376.4 18254.4 18184.6
17866. 17591.4 17986.5 18168.5 18177.1 18028.8 18214.2 17910.2 18085.6
17995.2 18022. 18137.7 17706.2 17937.6 17548.7 17641.9 18071.9 18063.8
17866.3 17073. 18155.8 18098.8 18142. 18173.6 17774.7 18179.6 17931.2
18153. 18101.1 17170.4 18317.6 18424.3 18063.6 18246.6 18189.1 17503.1
17853.9 17967.6 17858.5 17945. 18165.4 17944.4 18056.3 18196.1 17753.7
18201.8 18208.5 18100. 17774.3 18045.9 17781.4 18163.1 18104.7]
y
low_CI = 0.95*prediction
upper_CI = 1.05*prediction