Cubike is a fictional Bike Sharing company that we use the series of articless about Data Science with TM1 and Planning Analytics:
- Part 1: Upload weather data from web services
- Part 2: Explore your TM1 and Planning Analytics data with Pandas and Ploty
- Part 3: Timeseries Forecasting with Facebook Prophet
If you are new to TM1py, this article will guide you to setup TM1py and all the different modules required in the Cubike example.
The only prerequisite is to have IBM TM1 10.2.2 FP5 as minimum already installed. For this example we are going to work with the TM1 instance called tm1srv01:
and then type the following command to get the Python version:
In this example the Python version is v3.6.2:
2. Install TM1py
First you need to navigate to the Scripts folder where Python has been installed. To find out the Python location, in a Windows command promt type:
It should return you the location:
To go to the Python location just type cd and then the folder location:
To install TM1py you just need the following command line:
pip install TM1py
To check if the installation was successful just type:
pip show TM1py
It is going to show you information about TM1py and the version number, in this example v1.0.2:
TM1py uses the TM1 REST API to connect to the TM1 instance. In this example, our tm1srv01 instance uses the port 17001 for the REST API. To find out which port your TM1 instance is using, open the tm1s.cfg file and check the HttpPortNumber value.
To enable the REST API, open a web browser and paste the following URL:
You should be prompted this warning message, click Advanced and then Proceed to localhost (unsafe):
You should then see the metadata information of your TM1 instance:
4. Test connection with TM1
Once the TM1 REST API has been enabled, the next step is to check if you have the right TM1 settings to connect to your TM1 instance. Just follow steps described in the following article:
After running the check.py script from the TM1py samples, TM1py should be able to find your TM1 instance name:
5. Download Cubike example
All the files you need to go through the Cubike examples are gathered in one zip file which you can download here:
After unzipping this file, you should see two Jupyter notebooks, four csv files and one python script:
- chicago.csv: Bike Sharing data from Chicago.+
- Data Integration with TM1py.ipynb: Jupyter Notebook to load data into TM1 from a web service.
- Data Science with TM1py.ipynb: Jupyter Notebook to analyse the data.
- nyc.csv: Bike Sharing data from New Yord City.
- public holidays.csv: Public Holidays data.
- washington_dc.csv: Bike Sharing data from Washington DC.
- setup.py: Python script to create TM1 objects.
6. Install Jupyter Notebook
For demonstration and documentation purposes all the python code in this series is distributed through Jupyter Notebooks. Jupyter Notebooks allow you to create and share documents that contain live code, equations, visualizations and narrative text. A quick introduciton to Jupyter can be found here.
This example contains two Jupyter notebook (.ipynb). To open these two notebook, we have to install Jupyter first.
To install Jupyter, you just need to run the following command from the Scripts Python folder:
pip install jupyter
7. Open a Jupyter Notebook
To open Jupyter Notebook, you need to run Jupyter. To open a Windows command prompt, go to the folder location where you downloaded the Cubike example and then in the Windows Explorer bar, just type cmd and press enter:
To run Jupyter from this location, just type:
A new tab on your web browser should open and you should be able to see the two Jupyter Notebooks (.ipynb) file, just click on the first one to open it:
Once opened, you can then use the buttons at the top to navigate through the code's blocks. The most important button are the Up/Down arrow and the Run button which executes a code block and go to the next one:
Other Python packages required for Part 2 and Part 3 articles:
To run the Data Science with TM1py.ipynb, you will need to install in the Python folder, the following packages:
1) Ploty is a graphing library
pip install plotly
2) C++ Compiler is required by Facebook Prophet, you can download it from Build Tools for Visual Studio 2017 and run as administrator .exe file.
A restart of the server will be required.
3) Msgpack: (required by Facebook Prophet):
pip install msgpack-python
4) PyStan (required by Facebook Prophet)
pip install PyStan
5) Facebook Prophet is a forecasting tool.
pip install fbprophet
6) Matplotlib is a plotting library
python -mpip install -U matplotlib
You are now ready to start the Part 1 article: