<jupyter_start><jupyter_text>One-way ANOVAhttps://www.kaggle.com/lakshmi25npathi/bike-sharing-dataset<jupyter_code>import pandas as pd
import numpy as np

import matplotlib.pyplot as plt
from scipy import stats
import researchpy as rp

from statsmodels.formula.api import ols 
bike_sharing_data = pd.read_csv('datasets/bike_sharing_data_processed.csv')

bike_sharing_data.head()
bike_sharing_data.shape
bike_sharing_data['weathersit'].unique()
bike_sharing_data.groupby('weathersit')['cnt'].describe().T
bike_sharing_data.boxplot(column=['cnt'], by='weathersit', figsize=(12, 8))<jupyter_output><empty_output><jupyter_text>The hypothesis being testedhttps://statisticsbyjim.com/anova/post-hoc-tests-anova/ * __H0: No difference between means, i.e. ?x1 = ?x2 = ?x3__* __Ha: Difference between means exist somewhere, i.e. ?x1 ? ?x2 ? ?x3, or ?x1 = ?x2 ? ?x3, or ?x1 ? ?x2 = ?x3__  ANOVA with `scipy.stats`<jupyter_code>stats.f_oneway(bike_sharing_data['cnt'][bike_sharing_data['weathersit'] == 1],
               bike_sharing_data['cnt'][bike_sharing_data['weathersit'] == 2],
               bike_sharing_data['cnt'][bike_sharing_data['weathersit'] == 3],)<jupyter_output><empty_output><jupyter_text>ANOVA with `statsmodels`https://www.statsmodels.org/stable/examples/notebooks/generated/interactions_anova.html<jupyter_code>result = ols('cnt ~ C(weathersit)', data = bike_sharing_data).fit()
print(result.summary())<jupyter_output>OLS Regression Results                            
==============================================================================
Dep. Variable:                    cnt   R-squared:                       0.099
Model:                            OLS   Adj. R-squared:                  0.097
Method:                 Least Squares   F-statistic:                     40.07
Date:                Sun, 22 Sep 2019   Prob (F-statistic):           3.11e-17
Time:                        21:00:10   Log-Likelihood:                -6531.5
No. Observations:                 731   AIC:                         1.307e+04
Df Residuals:                     728   BIC:                         1.308e+04
Df Model:                           2                                         
Covariance Type:            nonrobust                                         
======================================================================================
                         coef    std err    [...]<jupyter_text>Post - hoc test by using `Tukey's method`https://www.statisticshowto.datasciencecentral.com/tukey-test-honest-significant-difference/<jupyter_code>from statsmodels.stats.multicomp import MultiComparison

mul_com = MultiComparison(bike_sharing_data['cnt'], bike_sharing_data['weathersit'])

mul_result = mul_com.tukeyhsd()

print(mul_result)<jupyter_output>Multiple Comparison of Means - Tukey HSD, FWER=0.05    
===========================================================
group1 group2  meandiff  p-adj   lower      upper    reject
-----------------------------------------------------------
     1      2  -840.9238 0.001  -1181.639  -500.2086   True
     1      3 -3073.5005 0.001 -4038.2706 -2108.7304   True
     2      3 -2232.5766 0.001 -3215.4794 -1249.6738   True
-----------------------------------------------------------
{'fraction_non_alphanumeric': 0.2023370233702337, 'fraction_numerical': 0.051045510455104554, 'mean_word_length': 2.3126272912423627, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 4, 'lorem ipsum': 0, 'www.': 3, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '185253', 'license': 'MIT', 'n_tokens_mistral': 1115, 'n_tokens_neox': 958, 'n_words': 178, 'path': 'book/inferential/demo03_OneWayANOVA.ipynb', 'repo_name': 'hossainlab/statswithpy', 'size': '3252'}