Advertisement
Guest User

Kesciui

a guest
Jul 16th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.10 KB | None | 0 0
  1. import pandas as pd
  2. import quandl, math
  3. import numpy as np
  4. from sklearn import preprocessing, model_selection, svm
  5. from sklearn.linear_model import LinearRegression
  6.  
  7.  
  8. df = quandl.get('WIKI/GOOGL')
  9.  
  10. df = df [['Adj. Open','Adj. High','Adj. Low','Adj. Close','Adj. Volume']]
  11. df['HL_PCT'] = (df['Adj. High']-df['Adj. Close']) / df['Adj. Close'] *100.0
  12. df['PCT_change'] = (df['Adj. Close']-df['Adj. Open']) / df['Adj. Open'] *100.0
  13.  
  14. df=df[['Adj. Close','HL_PCT','PCT_change','Adj. Volume']]
  15.  
  16. forecast_col = 'Adj. Close'
  17. df.fillna(-99999, inplace=True)
  18. forecast_out = int(math.ceil(0.01*len(df)))
  19. df['label'] = df[forecast_col].shift(-forecast_out)
  20. df.dropna(inplace=True)
  21.  
  22. x = np.array(df.drop(['label'],1))
  23. y = np.array(df['label'])
  24. x = preprocessing.scale(x)
  25. y = np.array(df['label'])
  26.  
  27.  
  28. x_train, x_test, y_train, y_test = model_selection.train_test_split(x,y,test_size=0.2)
  29. clf = LinearRegression()
  30. clf.fit(x_train,y_train)
  31. accuracy = clf.score((x_test,y_test,))
  32.  
  33. print(accuracy)
  34. #gaunu error :   accuracy = clf.score((x_test,y_test,))
  35. TypeError: score() missing 1 required positional argument: 'y'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement