Giter VIP home page Giter VIP logo

ibm / watson-stock-market-predictor Goto Github PK

View Code? Open in Web Editor NEW
110.0 29.0 83.0 21.56 MB

A IBM Developer code pattern for Watson Studio: forecast the stock market with Python Notebooks, SPSS Modeler, Data Refinery, and other Watson Studio tools.

Home Page: https://developer.ibm.com/patterns/predicting-the-stock-market-in-watson-studio/

License: Apache License 2.0

Jupyter Notebook 100.00%
watson-studio python spss

watson-stock-market-predictor's Issues

Unexpected date format in output CVS files of SPSS Modeller flow

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()

Model to be used to predict the Exact Date an item with X quantity will get finished

Hi Experts,

I need help in identifying the model that I can use to predict the exact date when an item with some quantity will get finished.

For.e.g:

Sample Data:

Quantity --- Finished_Date

10 ----------- 01-Jan-2018

5 ----------- 02-Jan-2018

20 ----------- 03-Jan-2018

Now, I want if user inputs quantity as 1000 then the output should give the date when this will get finished (such as 06-Jan-2018).

@stevemart @vnderlev Request your help on the same.

Thanks.

Error while running the SPSS Modeler.

Hi,
I am creating a sales forecast model using Time Series Node in Watson Studio SPSS Modeler Add On.
When I am running the model its giving me error "A valid Date, Time or TimeStamp field must be specified.".
Although in Data Refinery I am selecting column datatype as "DATE" and format as "YMD".

Need help on this.

Notebook Validation Failed

I tried running the code on localhost with anaconda, I keep getting this error.

Notebook JSON is invalid: 'application/vnd.bokehjs_load.v0+json' does not match any of the regexes: '^(?!application/json$)[a-zA-Z0-9]+/[a-zA-Z0-9\-\+\.]+$'

Failed validating 'additionalProperties' in display_data['properties']['data']:

On instance['cells'][19]['outputs'][1]['data']:
{'application/javascript': '\n'
                           '(function(root) {\n'
                           '  function now() {\n'
                           '    return new Date();\n'
                           '  }...',
 'application/vnd.bokehjs_load.v0+json': '\n'
                                         '(function(root) {\n'
                                         '  function now() {\n'
                                         '    return new Date();\n'
                                         '  }...'}

2.1: Fbprophet Setup code error

Issue with matplotlib install, code shows ( matplotlib=3.0.2 )

!pip install --user pystan==2.17.1.0 holidays==0.9.8 setuptools-git==1.2 matplotlib=3.0.2 --upgrade

to fix the issue, just update to: ( matplotlib==3.0.2 )

!pip install --user pystan==2.17.1.0 holidays==0.9.8 setuptools-git==1.2 matplotlib==3.0.2 --upgrade

Unable to install fbprophet using pip on watson studio cloud

!pip install --user fbprophet

ERROR: Complete output from command /opt/conda/envs/Python36/bin/python -u -c 'import setuptools, tokenize;file='"'"'/home/dsxuser/.tmp/pip-install-66hlx4dn/fbprophet/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' bdist_wheel -d /home/dsxuser/.tmp/pip-wheel-divwrn93 --python-tag cp36:
ERROR: running bdist_wheel
running build
running build_py
creating build
creating build/lib
creating build/lib/fbprophet
creating build/lib/fbprophet/stan_model
INFO:pystan:COMPILING THE C++ CODE FOR MODEL anon_model_861b75c6337e237650a61ae58c4385ef NOW.
error: command 'gcc' failed with exit status 1

ERROR: Failed building wheel for fbprophet

Alternative is to use

!conda install -c conda-forge fbprophet -y

Fbprophet Setup Issue

ImportError Traceback (most recent call last)
in
4 get_ipython().system('pip install fbprophet==0.6')
5 import datetime as dt
----> 6 import fbprophet
7
8 print('Packages imported.')

/opt/conda/envs/Python36/lib/python3.6/site-packages/fbprophet/init.py in
6 # of patent rights can be found in the PATENTS file in the same directory.
7
----> 8 from fbprophet.forecaster import Prophet
9
10 version = '0.6'

/opt/conda/envs/Python36/lib/python3.6/site-packages/fbprophet/forecaster.py in
16
17 from fbprophet.make_holidays import get_holiday_names, make_holidays_df
---> 18 from fbprophet.models import StanBackendEnum
19 from fbprophet.plot import (plot, plot_components)
20

ImportError: cannot import name 'StanBackendEnum'

Error in the 5th step

There is an error shows up in the 5th step when I import fbprophet

# Import packages
import fbprophet
import datetime as dt

print('Packages imported.')
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-17-88bc45a5ace3> in <module>
      1 # Import packages
----> 2 import fbprophet
      3 import datetime as dt
      4 
      5 print('Packages imported.')

/opt/conda/envs/Python36/lib/python3.6/site-packages/fbprophet/__init__.py in <module>
      6 # of patent rights can be found in the PATENTS file in the same directory.
      7 
----> 8 from fbprophet.forecaster import Prophet
      9 
     10 __version__ = '0.5'

/opt/conda/envs/Python36/lib/python3.6/site-packages/fbprophet/forecaster.py in <module>
     20 from fbprophet.make_holidays import get_holiday_names, make_holidays_df
     21 from fbprophet.models import prophet_stan_model
---> 22 from fbprophet.plot import (plot, plot_components, plot_forecast_component,
     23                             plot_seasonality, plot_weekly, plot_yearly,
     24                             seasonality_plot_df)

/opt/conda/envs/Python36/lib/python3.6/site-packages/fbprophet/plot.py in <module>
     20 
     21 try:
---> 22     from matplotlib import pyplot as plt
     23     from matplotlib.dates import (
     24         MonthLocator,

/opt/conda/envs/Python36/lib/python3.6/site-packages/matplotlib/pyplot.py in <module>
     30 from cycler import cycler
     31 import matplotlib
---> 32 import matplotlib.colorbar
     33 import matplotlib.image
     34 from matplotlib import rcsetup, style

/opt/conda/envs/Python36/lib/python3.6/site-packages/matplotlib/colorbar.py in <module>
     25 
     26 import matplotlib as mpl
---> 27 import matplotlib.artist as martist
     28 import matplotlib.cbook as cbook
     29 import matplotlib.collections as collections

/opt/conda/envs/Python36/lib/python3.6/site-packages/matplotlib/artist.py in <module>
     55 
     56 
---> 57 class Artist(object):
     58     """
     59     Abstract base class for objects that render into a FigureCanvas.

/opt/conda/envs/Python36/lib/python3.6/site-packages/matplotlib/artist.py in Artist()
     62     """
     63     @cbook.deprecated("3.1")
---> 64     @property
     65     def aname(self):
     66         return 'Artist'

/opt/conda/envs/Python36/lib/python3.6/site-packages/matplotlib/cbook/deprecation.py in deprecate(obj, message, name, alternative, pending, addendum)
    180                 pass
    181     """
--> 182 
    183     def deprecate(obj, message=message, name=name, alternative=alternative,
    184                   pending=pending, obj_type=obj_type, addendum=addendum):

AttributeError: 'property' object has no attribute '__name__'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.