$30.00
Description

Aim
Please estimate a trend in a time series regression model, especially with deep neural network methods multilayer perceptrons and LSTM RNN model. The DNN models could predict the price curve within the nite steps. You may apply new methods or use new packages to improve the the quality of clustering, but if you do so, you have to give a brief introduction of the key concepts and provide necessary citations, instead of just direct copy paste or importing. However, in this assignment, you must have models utilizing multilayer perceptrons(MLP) and LSTM via keras(ver 2.2)[1] or tensor ow(ver 1.8).contrib.keras. In order to save your keras.model, please install h5py(ver. 2.8) with pip. Once an algorithm package is merged or imported into your code, please list the package link in your reference and describe its mathematical concepts in your report followed by the reason for adoption.

Dataset Description
The dataset `apple price close.csv’ is the minute APPLE stock close price downloaded from www.google.com/ nance. All the records in the dataset ars ordered by time stamp covering from May 21 to Jun 9. The headers in the dataset are time Taiwan, index min and close price. Note based on the trading time window, there are only 391 index min from 0 to 390 within a trading day. In this dataset, it covers the mintrading history for 14 days.

Submission Format
You have to submit a compressed le hw4 studentID.zip which contains the following les:

hw4 studentID.ipynb: detailed report, Python codes, results, discussion and mathematical descriptions;

hw4 studentID.tplx: extra Latex related setting, including the bibliography;

hw4 studentID.bib: citations in the “bibtex” format;

hw4 studentID.pdf: the pdf version of your report which is exported by your ipynb with


%% jupyter nbconvert – to latex – template hw4 studentID.tplx hw4 studentID.ipynb



%% pd atex hw4 studentID.tex



%% bibtex hw4 studentID



%% pd atex hw4 studentID.tex



%% pd atex hw4 studentID.tex


Other les or folders in a workable path hierarchy to your jupyter notebook (ipynb).

Coding Guidelines
For the purpose of individual demonstration with TA, you are required to create a function code in your jupyter notebook, as speci ed below, to reduce the data dimensionality, learn a classi cation model, and evaluate the performance of the learned model.
hw4 studentID demo(in x=None,in y=None,mode=None,model type=None, header=True)
{ in x: [string] CSV le for `data’.
{ in y: [string] CSV le for `labels’. Assign a le when mode=`train’.
{ mode: [string] mode=`preprocessing’ Please set in y=None. If you have any preprocessing, please do the preprocessing in this mode. After preprocessing, save
the processed data as `HW4 studentID MLP data.csv’ and `HW4 studentID MLP labels.csv’ (`HW4 studentID LSTM data.csv’ and `HW4 studentID LSTM labels.csv’) with
header if header=True or without header when header=False. You can design
your own `* data.csv’ format. For `* labels.csv’, there would be only one column for the prices. Assume timesteps= n and denote the sequence of price as fs_{r}g^{m}_{r=0}^{1}. We want to predict s_{r} under mode=`train’. For example, when header=True, data dim=1, the in x=`HW4 studentID MLP data.csv’ could be

^{x}1
^{x}2
^{x}n
.
.
.
^{s}r n
^{s}r n+1
^{s}r 1
.
.
.
and with (batch
size= ,timesteps= n, data
size=k),
the in
x=`HW4
studentID
LSTM
data.csv’ could be
batch
idx
x
(0)
(0)
(0)
(1)
(1)
(n 1)
(n 1)
x_{0}
x_{1}
x_{k}
1
x_{0}
x_{k}
1
x_{0}
^{x}k 1
(1)
(1)
(1)
(2)
(2)
(n)
(n)
0
x_{0}
x_{1}
^{x}k 1
x_{0}
^{x}k 1
x_{0}
^{x}k 1
.
.
.
( 1)
( 1)
( 1)
( )
( )
( +n 2)
( +n 2)
^{x}0
^{x}1
^{x}k 1
^{x}0
^{x}k 1
^{x}0
^{x}k 1
.
.
.
.
.
.
and in
y`HW4
studentID
MLP
labels.csv’
labels.csv’ is set as
y
^{..}. _{.}
s_{r}
^{.}._{.}
and in y=`HW4 studentID LSTM

batch
idx
y
_{y}(n 1)
0
_{y}(n)
.
.
.
.
_{y}( +n 2)
.
.
.
.
.
.
You can design your `HW4 studentID MLP data.csv’ and
`HW4 studentID LSTM data.csv’ base on the timesteps and data dimension in your models with data dim> 1, including the price di erence, indicator for increase or decrease and so on. Just remember to reshape it to match your deployment of the model when mode=`train’.
mode=`train’ The `x in’ is assigned to `HW4 studentID MLP data.csv’
(or `HW4 studentID LSTM data.csv’). `y in’ is assigned to `HW4 studentID MLP labels.csv’ (or `HW4 studentID LSTM labels.csv’). Please do MLP and LSTM in this mode and output the corresponding les which are speci ed next.
{ model type:[string] when mode=`train’. use model type=`MLP’ or model type=`LSTM’ to select training model.
{ header:[bool] if header=True, there has header in `HW4 studentID MLP data.csv’ (or `HW4 studentID LSTM data.csv’); if header=False, there is no header in the `HW4 studentID MLP data.csv’ (or `HW4 studentID LSTM data.csv’).
In mode=`train’, please output the following `CSV’ les with headers and your model to `h5′ les. Also set your models as globel when mode=`train’, model type=`MLP’ or mode=`train’, model type=`LSTM’. Please set the loss function as loss=’mean squared error’.
MLP:
le 1 ‘HW4 studentID MLP.csv’ with header
optimizer,loss, batch size, timesteps, data dim, avg loss, last loss
optimizer: type of optimizer[2];
loss: type of loss[3];
batch size: how many instances in one batch;
timesteps: time steps to look back;
data dim: data dimension for each instance;
avg loss: the average loss for overall batches;
last loss: the loss for the last batch training.
le 2 `HW4 studentID MLP model.h5′: save you model with keras
if your keras LSTM model is named with `model’ model.save(`HW4 studentID MLP model.h5′)
LSTM:
le 1 ‘HW4 studentID LSTM.csv’ with header
optimizer,loss, batch size, timesteps, data dim, avg loss, last loss
optimizer: type of optimizer[2];
loss: type of loss[3];
batch size: how many instances in one batch;
timesteps: time steps to look back;
data dim: data dimension for each instance;
avg loss: the average loss for overall batches;
last loss: the loss for the last batch training.
le 2 `HW4 studentID LSTM model.h5′: save you model with keras
if your keras LSTM model is named with `model’ model.save(`HW4 studentID LSTM model.h5′)
In demonstration, the training dataset is the same as homework assignment. The score of the demonstration has two parts, MLP and LSTM. For each part, the score will be graded by the ranking of average batch loss value for the test dataset via your model. The test dataset will not be o ered. It is tested only on the given webpage and go through your preprocessing before evaluation. In the script le `hw4 studentID.py’, please add the following code to your program before you import keras.
import tensor ow as tf from keras.backend.tensor ow backend import set session con g = tf.Con gProto() con g.gpu options.allow growth = True
set session(tf.Session(con g=con g))
Note: the script you submit in demonstration will be referred when TA is grading your report and jupyter notebook. Make sure TA knows how to modify your code if TA can not execute your jupyter notebook properly.

Report Requirement
List names of packages used in your program;
A owchart for Preprocessing with explanation to your method. A diagram for your MLP model.
A diagram for your LSTM model.
Compare and conclude results between two methods,
5.1 Basic Requirement
Implement 2 methods after the preprocessing is nished.
Based on the average of loss value, decide the architecture of your models. The grading will also refer to this value.
Please make sure hw4 student ID demo is functional and can output the required les in both mode=`preprocessing’ and mode=`train’.
If you apply new methods or use new packages to improve the classi cation performance, you have to give a brief introduction of the key concepts and provide necessary citations/links, instead of just direct copy paste or importing.
Please submit your `report’ in English. Be aware that a `report’ is much more than a `program.’
References

Guideline for keras. https://keras.io/gettingstarted/sequentialmodelguide/. Accessed: 20180609.

optimizer function in keras. https://keras.io/optimizers/. Accessed: 20180609.

loss function in keras. https://keras.io/losses/. Accessed: 20180609.
6