daily pastebin goal
46%
SHARE
TWEET

Untitled

a guest Jul 12th, 2018 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top