Last active
November 8, 2022 03:55
-
-
Save yoki/ea6bfba0749d68b6635bd41169ab7ce0 to your computer and use it in GitHub Desktop.
Python Statistics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
from sklearn import datasets | |
import statsmodels.api as sm | |
from stargazer.stargazer import Stargazer | |
from IPython.core.display import HTML | |
diabetes = datasets.load_diabetes() | |
df = pd.DataFrame(diabetes.data) | |
df.columns = ['Age', 'Sex', 'BMI', 'ABP', 'S1', 'S2', 'S3', 'S4', 'S5', 'S6'] | |
df['target'] = diabetes.target | |
est = sm.OLS(endog=df['target'], exog=sm.add_constant(df[df.columns[0:4]])).fit() | |
est2 = sm.OLS(endog=df['target'], exog=sm.add_constant(df[df.columns[0:6]])).fit() | |
stargazer = Stargazer([est, est2]) | |
HTML(stargazer.render_html()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment