Guest User

Untitled

a guest
Jul 12th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. # データの読み込み
  2. import pandas as pd
  3.  
  4. file = 'data/1_test_reg.csv'
  5. df = pd.read_csv(file)
  6.  
  7. print (df)
  8.  
  9. # statsmodelsのライブラリ呼び出し
  10. import statsmodels.api as sm
  11.  
  12. # 変数の定義
  13. X = df['Earn']
  14. Y = df.loc[:,['MaxTemp','MinTemp','Humi','Wind','Sun']]
  15. model = sm.OLS(X, sm.add_constant(Y))
  16.  
  17. # Elastic Netで回帰分析を実行する
  18. result = model.fit_regularized(
  19. method='elastic_net',
  20. alpha=1000.0,
  21. L1_wt=1.0,
  22. start_params=None,
  23. profile_scale=False,
  24. refit=False
  25. )
  26.  
  27. # パラメータを調べる
  28. b= result.params
  29. print(b)
Add Comment
Please, Sign In to add comment