Class10

In Class10 we build a Machine Learning API server.

Topics:

Questions:

Lab (Setup)

Steps of KerasService.get() method in keras11.py Script:


The steps listed below are used to describe class KerasService.get() method.
Refer to:
https://github.com/danbikle/keras11

- Get tkr from end-user
- Get yr2predict, yrs2train, feature names from end-user
- Get CSV data from yahoo
- Copy Date and Close into a DF
- Sort the DF by Date
- Rename Close to Price
- Generate dependent variable:
  - pctlead (for regression predictions)
  - updown (for classification predictions)
- Generate price based features:
  - pctlagX
  - slopeX
- Generate date based features:
  - dow (Day of Week: 1,2,3,4,5)
  - moy (Month of Year: 1,2,3,4,5,6,7,8,9,10,11,12)
  - Scale them by dividing by 100
- Copy the features into feat_df
- Use yr2predict to copy one year of test data from feat_df into test_yr_df
- Use yr2predict, yrs2train to copy many years of training data from feat_df into train_df
- Create a model from Keras
- Fit the model to train_df
- Predict observations in test_yr_df
- Calculate Accuracy of predictions of test_yr_df
- Calculate Effectiveness of predictions of test_yr_df
- Save predictions to DB
- Report results to end-user

Lab (Demo 1)

Run the first demo with a simple shell command:

cd ~/keras11
python import_keras11.py

Q: What does this lab do?

Lab (Demo 2)

Run the next demo with these shell commands:

cd ~/keras11
./flask11.bash

The above shell command will start an API server. Let the server run and start another shell.

Run Demo 2:

cd ~/keras11
bash -x curlem.bash

Q: What does this lab do?

Lab (Demo 3)

Run the next demo with these shell commands:

cd ~/keras11
python import_keras12.py

Q: What does this lab do?

Lab (Demo 4)

Run the next demo with these shell commands:

cd ~/keras11
./flask12.bash

The above shell command will start an API server. Let the server run and start another shell.

Run Demo 4:

cd ~/keras11
curl localhost:5012/nnmodel/IBM/2017/3/2/3?features=pctlag1,slope2,dow,moy

Q: What does this lab do?


ml4.us About Blog Contact Class01 Class02 Class03 Class04 Class05 Class06 Class07 Class08 Class09 Class10 dan101 Forum Google Hangout Vboxen