0% found this document useful (0 votes)
8 views6 pages

Exercise 5

The document outlines exercises on training LSTM models for predicting Bitcoin prices and housing values using various data preprocessing techniques and model architectures. It details the training process, loss metrics, and evaluation methods, including Mean Squared Error and R-squared values. Additionally, it discusses the importance of feature normalization, model regularization, and hyperparameter tuning to improve model performance.

Uploaded by

pandumukesh143
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views6 pages

Exercise 5

The document outlines exercises on training LSTM models for predicting Bitcoin prices and housing values using various data preprocessing techniques and model architectures. It details the training process, loss metrics, and evaluation methods, including Mean Squared Error and R-squared values. Additionally, it discusses the importance of feature normalization, model regularization, and hyperparameter tuning to improve model performance.

Uploaded by

pandumukesh143
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Exercise 1:

Epoch 0 Loss: 0.015613915398716927

Epoch 25 Loss: 0.003066639183089137

Epoch 50 Loss: 0.0012870215578004718

Epoch 75 Loss: 0.0016396405408158898

Epoch 100 Loss: 0.0010618615197017789

Epoch 125 Loss: 0.0003182028012815863

Mean Squared Error: 0.23075591518161281

Data Preprocessing: Effectively using MinMaxScaler normalization enables models to operate on time
series data.

Model Architecture: The addition of linear layers (nn.Linear) could benefit the model in extracting
features regarding LSTM outputs for better prediction of the target.

Training: The training loop shows a steady decline in loss, with significant changes in loss every 25
epochs, implying the effectiveness of the model learning.

Prediction: The resultant Mean Squared Error (MSE) of 0.2308 is adequate. The graph describes how
the model has followed the trends and patterns in the actual data against its predictions.

Exercise 2:
1) Multivariate Data Representation And Lstm Prediction The historical bitcoin market data comprises
the following attributes:

Opening Price: The price at which Bitcoin was opened to trading.

High Price: The highest price reached by Bitcoin during the trading day.

Low Price: The lowest price reached by Bitcoin during a trading day.

Volume Traded: The total volume of bitcoins traded on that day.

Then, the task of the LSTM network is to analyse these features and predict the closing price of
Bitcoin for the next 50 days based on last 100 days.

2) Internal Correlation: Yes, there are entire correlations among features with respect to the data set.
For example, opening and closing prices are generally the same; transaction volume also depends on
the prices. These interdependencies are very important for LSTM learning and future price
predictions.

Some Improving Model Performance:

Data Normalization: normalizes all the input features to a common scale so that convergence is
achieved better during training

Model Architecture: Increase the number of LSTM layers or units in order to learn more complex
patterns. For example, for stacked LSTM, greater number of layers improved performance.

STACK OVERFLOW

Regularization: adding dropout layers to avoid overfitting and enhancing generalization.

Hyperparameter Tuning: Learning rates, batch sizes, and sequence lengths are different from the
above setting. Search for the optimal configuration.

Bidirectional LSTM: Use this method to capture patterns from both past and future contexts.

Exercise 3:
This basically takes care of data preprocessing, which is the data import and normalization through
Min Max Scaler, and then reformats data into a supervised learning problem for a look-back period of
1, and splits the data into a train dataset and test dataset. Next, it defines three models-RNN Model:
Uses basic RNN; GRU Model: Has a GRU Layer; and LSTM Model: Contains an LSTM layer.

Training/Evaluation: Each model is built on the Mean Squared Error (MSE) loss using Adam. After
training, the models were evaluated against the test set, and Root Mean Square Error (RMSE) was
computed. Predictions were reverse-transformed to the original scale, and test errors were
calculated.

This would mean plotting true vs predicted values for each model and visualizing the total errors
summed for each test sequence.

Exercise 4a:

dtype: int64

MedInc HouseAge AveRooms AveBedrms Population \

count 20640.000000 20640.000000 20640.000000 20640.000000 20640.000000

mean 3.870671 28.639486 5.429000 1.096675 1425.476744

std 1.899822 12.585558 2.474173 0.473911 1132.462122

min 0.499900 1.000000 0.846154 0.333333 3.000000

25% 2.563400 18.000000 4.440716 1.006079 787.000000

50% 3.534800 29.000000 5.229129 1.048780 1166.000000

75% 4.743250 37.000000 6.052381 1.099526 1725.000000


max 15.000100 52.000000 141.909091 34.066667 35682.000000

AveOccup Latitude Longitude MedHouseVal

count 20640.000000 20640.000000 20640.000000 20640.000000

mean 3.070655 35.631861 -119.569704 2.068558

std 10.386050 2.135952 2.003532 1.153956

min 0.692308 32.540000 -124.350000 0.149990

25% 2.429741 33.930000 -121.800000 1.196000

50% 2.818116 34.260000 -118.490000 1.797000

75% 3.282261 37.710000 -118.010000 2.647250

max 1243.333333 41.950000 -114.310000 5.000010

Intercept: -37.552166316589286

Coefficients: [ 4.41181942e-01 9.70730794e-03 -1.19993946e-01 7.84709051e-01

-3.39466724e-07 -3.28239095e-03 -4.23679731e-01 -4.39311822e-01]

Mean Squared Error: 0.5385446422423643

R-squared: 0.596623451962375
This dataset contains a total of 20,640 dimensions, with no individual missing values, as revealed by
the zeros in the count of their respective columns in the missing values check. The summary statistics
indicate that the dataset comprises a mixture of numerical features like 'MedInc' (the median
income), 'HouseAge' (median house age), 'MedHouseVal' (the median house value), and the others.

All the features' coefficients are displayed, the intercept being an estimated -37.55. These
coefficients of the features are:

'MedInc': 0.4418

'HouseAge': 0.0097

'AveRooms': -0.1199

'AveBedrms': 0.7847

'Population': -0.0000003395

'AveOccup': -0.0033

'Latitude': -0.4237

'Longitude': -0.4393

Mean Squared Error (MSE) is calculated at around 0.5385, R squared approximates to 0.5966. This
figure denotes that about 59.66% variance in the target variable 'MedHouseVal' has been explained
by the model.

This scatter plot likely shows how the actual values relate to the predicted values of 'MedHouseVal',
whereby a perfectly fitted model would be shown by points clustered very close to the line of perfect
prediction.

Exercise 4b:

You might also like