# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python [conda root]
#     language: python
#     name: conda-root-py
# ---

import pandas as pd

import statsmodels.formula.api as sm

iris=pd.read_csv("http://vincentarelbundock.github.io/Rdatasets/csv/datasets/iris.csv")

iris =iris.drop('Unnamed: 0', 1)

iris.head()

iris.columns=['Sepal_Length', 'Sepal_Width', 'Petal_Length', 'Petal_Width',
       'Species']

iris.columns

result = sm.ols(formula="Sepal_Length  ~  Petal_Length  + Sepal_Width + Petal_Width + Species", data=iris)


result.fit()

result.fit().summary()

result.fit().params

result.fit().outlier_test(method='bonf', alpha=0.05)

dir(result.fit())

test=result.fit().outlier_test()
print ('Bad data points (bonf(p) < 0.05):')
print (test[test.icol(2) < 0.05])



StarcoderdataJupyterScriptsDedupFiltered