SHARE
TWEET

Untitled

a guest Aug 13th, 2019 111 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. df = pd.concat([df.drop('IssueCode', 1), pd.get_dummies(df['IssueCode'],prefix = 'IssueCode_').astype(np.int8)], axis=1)
  2. df = pd.concat([df.drop('SolutionCode', 1), pd.get_dummies(df['SolutionCode'],prefix = 'SolutionCode_').astype(np.int8)], axis=1)
  3. df = pd.concat([df.drop('Col1', 1), pd.get_dummies(df['Col1'],prefix = 'Col1_').astype(np.int8)], axis=1)
  4. df = pd.concat([df.drop('Col2', 1), pd.get_dummies(df['Col2'],prefix = 'Col2_').astype(np.int8)], axis=1)
  5. df = pd.concat([df.drop('Col3', 1), pd.get_dummies(df['Col3'],prefix = 'Col3_').astype(np.int8)], axis=1)
  6.      
  7. from sklearn.model_selection import cross_val_predict
  8. import pymssql
  9. import pandas as pd
  10. import numpy as np
  11. from sklearn.model_selection import train_test_split
  12. from sklearn.metrics import mean_squared_error
  13. from sklearn.metrics import r2_score
  14. import datetime
  15. import random
  16. from sklearn.ensemble import RandomForestRegressor
  17.  
  18.  
  19. pd.set_option('display.max_rows', 5000)
  20. pd.set_option('display.max_columns', 5000)
  21. pd.set_option('display.width', 10000)
  22.  
  23.  
  24. TaskTime = 900
  25. RunTime = 120
  26. sFolder = "/mnt/c/temp/"
  27.  
  28. def Lead0(value):
  29.         return "0" + str(value) if value < 10 else str(value)
  30.  
  31. dNow = datetime.datetime.now()
  32. sNow = Lead0(dNow.year) + Lead0(dNow.month) + Lead0(dNow.day) + Lead0(dNow.hour) + Lead0(dNow.minute) + Lead0(dNow.second)
  33.  
  34. print(sNow)
  35.  
  36. conn = pymssql.connect(server="MyServer", database="MyDB", port="1433", user="***", password="*****")
  37. df = pd.read_sql("SELECT   *  FROM MyTable where MyDate between '1 jul 2018' and '30 jun 2019'", conn)
  38. conn.close()
  39.  
  40.  
  41. #df = pd.get_dummies(df)
  42. #When I uncomment this I get Memory Error
  43.  
  44.  
  45. mdl = RandomForestRegressor(n_estimators = 500)
  46.  
  47. y_pred = cross_val_predict(mdl, X, y, cv=5)
  48. #This is causing error String to float
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