Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2022-211
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2022-211
2022-211
Commits
56470fd0
Commit
56470fd0
authored
Oct 13, 2022
by
H.C.K. De Silva
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
90% complete lstm
parent
2f5d63bf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
0 deletions
+38
-0
lstm.py
lstm.py
+38
-0
No files found.
lstm.py
0 → 100644
View file @
56470fd0
from
keras.preprocessing.sequence
import
TimeseriesGenerator
from
sklearn.preprocessing
import
MinMaxScaler
import
numpy
as
np
import
pandas
as
pd
from
statsmodels.tsa.statespace.sarimax
import
SARIMAX
from
statsmodels.graphics.tsaplots
import
plot_acf
,
plot_pacf
from
statsmodels.tsa.seasonal
import
seasonal_decompose
from
pmdarima
import
auto_arima
from
sklearn.metrics
import
mean_squared_error
from
statsmodels.tools.eval_measures
import
rmse
import
warnings
warnings
.
filterwarnings
(
"ignore"
)
df
=
pd
.
read_csv
(
'monthly-beer-production-in-austr.csv'
)
train_data
=
df
[:
len
(
df
)
-
12
]
test_data
=
df
[
len
(
df
)
-
12
:]
scaler
=
MinMaxScaler
()
scaler
.
fit
(
train_data
)
scaled_train_data
=
scaler
.
transform
(
train_data
)
scaled_test_data
=
scaler
.
transform
(
test_data
)
n_input
=
12
n_features
=
1
generator
=
TimeseriesGenerator
(
scaled_train_data
,
scaled_train_data
,
length
=
n_input
,
batch_size
=
1
)
from
keras.models
import
Sequential
from
keras.layers
import
Dense
from
keras.layers
import
LSTM
lstm_model
=
Sequential
()
lstm_model
.
add
(
LSTM
(
200
,
activation
=
'relu'
,
input_shape
=
(
n_input
,
n_features
)))
lstm_model
.
add
(
Dense
(
1
))
lstm_model
.
compile
(
optimizer
=
'adam'
,
loss
=
'mse'
)
lstm_model
.
summary
()
lstm_model
.
fit_generator
(
generator
,
epochs
=
20
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment