[overig] Vraag omtrent Python
Moderators: ArcherBarry, Fuzzwood
-
- Berichten: 22
Vraag omtrent Python
Hallo,
Ik moet in python een Z-test maken, maar als output krijg ik een waarschuwing en NaN.
Kan iemand mij misschien vertellen waarom dit fout is?
Ik heb het volgende:
-----------------------------------------------------
oscar_profit = 253
oscar_totalprofit = 303
rate_oscar = oscar_profit/oscar_totalprofit
#proportion films winst+no-oscar = films-no-oscar/amount of no-oscars
noscar_profit = 521
noscar_totalprofit = 736
rate_noscar = noscar_profit/noscar_totalprofit
rate_oscar, rate_noscar
---------------------------------------
ztest = sm.stats.proportions_ztest([oscar_totalprofit, noscar_totalprofit], [oscar_profit, noscar_profit], alternative='larger')
ztest
Maar dan krijg je dit als output:
C:\ProgramData\Anaconda3\lib\site-packages\statsmodels\stats\proportion.py:806: RuntimeWarning: invalid value encountered in sqrt
std_diff = np.sqrt(var_)
C:\ProgramData\Anaconda3\lib\site-packages\scipy\stats\_distn_infrastructure.py:879: RuntimeWarning: invalid value encountered in greater
return (self.a < x) & (x < self.b)
C:\ProgramData\Anaconda3\lib\site-packages\scipy\stats\_distn_infrastructure.py:879: RuntimeWarning: invalid value encountered in less
return (self.a < x) & (x < self.b)
C:\ProgramData\Anaconda3\lib\site-packages\scipy\stats\_distn_infrastructure.py RuntimeWarning: invalid value encountered in less_equal
cond2 = cond0 & (x <= self.a)
Out[70]:
(nan, nan)
Ik moet in python een Z-test maken, maar als output krijg ik een waarschuwing en NaN.
Kan iemand mij misschien vertellen waarom dit fout is?
Ik heb het volgende:
-----------------------------------------------------
oscar_profit = 253
oscar_totalprofit = 303
rate_oscar = oscar_profit/oscar_totalprofit
#proportion films winst+no-oscar = films-no-oscar/amount of no-oscars
noscar_profit = 521
noscar_totalprofit = 736
rate_noscar = noscar_profit/noscar_totalprofit
rate_oscar, rate_noscar
---------------------------------------
ztest = sm.stats.proportions_ztest([oscar_totalprofit, noscar_totalprofit], [oscar_profit, noscar_profit], alternative='larger')
ztest
Maar dan krijg je dit als output:
C:\ProgramData\Anaconda3\lib\site-packages\statsmodels\stats\proportion.py:806: RuntimeWarning: invalid value encountered in sqrt
std_diff = np.sqrt(var_)
C:\ProgramData\Anaconda3\lib\site-packages\scipy\stats\_distn_infrastructure.py:879: RuntimeWarning: invalid value encountered in greater
return (self.a < x) & (x < self.b)
C:\ProgramData\Anaconda3\lib\site-packages\scipy\stats\_distn_infrastructure.py:879: RuntimeWarning: invalid value encountered in less
return (self.a < x) & (x < self.b)
C:\ProgramData\Anaconda3\lib\site-packages\scipy\stats\_distn_infrastructure.py RuntimeWarning: invalid value encountered in less_equal
cond2 = cond0 & (x <= self.a)
Out[70]:
(nan, nan)
- Berichten: 821
Re: Vraag omtrent Python
Ik ben hier onbekend mee, maar gebruikt de z-toets niet 4 parameters? (jij hebt er 3)
- Berichten: 897
Re: Vraag omtrent Python
Is dat letterlijk je python code???
Misschien stomme opmerking maar ben je zeker dat je de juiste libraries hebt geïmporteerd?
Misschien stomme opmerking maar ben je zeker dat je de juiste libraries hebt geïmporteerd?
-
- Berichten: 22
Re: Vraag omtrent Python
We hadden 3 tabellen gekregen die we hebben omgezet naar een dataframe. Dus de getallen die daar staan komen uit die dataframes en die zijn correct.