I got to section 9 (Using and Validating the Model Stored in WML) in the stock market predictor readme.
When I run the notebook "Using machine learning", it gets to section 2.1 and errors (error shown below).
The issue is that the date format is not as expected. The SPSS data modeller from section 7 & 8 has outputted files with a date format that is not expected by the script. I looked at the input file to the modeller and the date format is correct.
I had a look at the data modeller graphical steps and can't see any place that it is changing the date format, hence it's a mystery to me which the date format is changing and how to correct this.
Modeller output:
Tue Dec 16 00:00:00 GMT 1980
0
25.37
27.369983445431373
26.553793413102458
28.187857129086645
-0.07546457764654858
25.25
27.21687613499548
26.417546067369276
28.017830126442682
-0.07460859972469559
2.1: Reading the AAPL_Test data
Loading the CSV file into a pandas dataframe, with the correct datatypes for each column
dateparse = lambda dates: pd.datetime.strptime(dates, '%Y-%m-%d')
df_test = pd.read_csv('AAPL_Test.csv', parse_dates=['Date'], date_parser=dateparse)
print(df.info())
df_test = df_test[['Date','Open','High','Low','Close']]
df_test.tail()
TypeError Traceback (most recent call last)
/opt/conda/envs/DSX-Python35/lib/python3.5/site-packages/pandas/io/parsers.py in converter(*date_cols)
3020 result = tools.to_datetime(
-> 3021 date_parser(*date_cols), errors='ignore')
3022 if isinstance(result, datetime.datetime):
in (dates)
1 # Loading the CSV file into a pandas dataframe, with the correct datatypes for each column
----> 2 dateparse = lambda dates: pd.datetime.strptime(dates, '%Y-%m-%d')
3 df_test = pd.read_csv('AAPL_Test.csv', parse_dates=['Date'], date_parser=dateparse)
TypeError: strptime() argument 1 must be str, not numpy.ndarray
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
/opt/conda/envs/DSX-Python35/lib/python3.5/site-packages/pandas/io/parsers.py in converter(*date_cols)
3029 parser=date_parser,
-> 3030 dayfirst=dayfirst),
3031 errors='ignore')
pandas/_libs/tslibs/parsing.pyx in pandas._libs.tslibs.parsing.try_parse_dates()
pandas/_libs/tslibs/parsing.pyx in pandas._libs.tslibs.parsing.try_parse_dates()