LSTM of TF: Based on the tensorflow framework, using the LSTM algorithm (random search/grid search parameters) to realize the case of house price regression prediction on the boston house price data set

LSTM of TF: Based on the tensorflow framework, using the LSTM algorithm (random search/grid search parameters) to realize the case of house price regression prediction on the boston house price data set

Directory

Based on the tensorflow framework, using the LSTM algorithm (random search parameters) to realize the house price regression prediction case for the boston house price data set

# 1. Define the data set

# 2. Data preprocessing

# 2.1, Separate features and labels

# 3. Model training and reasoning

# 3.1. Segmentation dataset

# 3.2, data reprocessing

# Reshape the input data into a 3D tensor (number of samples, time steps, number of features)

# 3.3. Establish LSTM model

# 3.4. Model tuning: #Output the best score and hyperparameter combination

# 3.4,1. Random search based on LSTM model

# 3.4,2. Grid search based on LSTM model

# 3.5. Model verification based on the best parameters of the model

# draw the loss curve of the training set and test set

# Model evaluation

# draw predictions


Related articles
LSTM/GRU of TF: Based on tensorflow framework, use LSTM and GRU algorithm (batch_size tuning comparison) to realize house price regression prediction case for boston house price data set respectively
LSTM/GRU of TF: Based on tensorflow framework, use LSTM and GRU algorithm (batch_size tuning comparison) to realize house price regression prediction case implementation code for boston house price data set respectively

LSTM of TF: Based on the tensorflow framework, using the LSTM algorithm (random search and tuning parameters) to realize the case of house price regression prediction on the boston house price data set
LSTM of TF: Based on the tensorflow framework, using the LSTM algorithm (random search and tuning parameters) to realize the house price regression prediction case implementation code for the boston house price data set

LSTM of TF: Based on tensorflow framework, using LSTM algorithm (grid search parameter tuning) to realize house price regression prediction case implementation code for boston house price data set

Using the LSTM algorithm (random search parameter) to realize the case of house price regression prediction on the boston house price data set based on the tensorflow framework

# 1. Define the data set

 CRIM ZN INDUS CHAS NOX ... TAX PTRATIO B LSTAT target
0 0.00632 18.0 2.31 0.0 0.538 ... 296.0 15.3 396.90 4.98 24.0
1 0.02731 0.0 7.07 0.0 0.469 ... 242.0 17.8 396.90 9.14 21.6
2 0.02729 0.0 7.07 0.0 0.469 ... 242.0 17.8 392.83 4.03 34.7
3 0.03237 0.0 2.18 0.0 0.458 ... 222.0 18.7 394.63 2.94 33.4
4 0.06905 0.0 2.18 0.0 0.458 ... 222.0 18.7 396.90 5.33 36.2
.. ... ... ... ... ... ... ... ... ... ... ...
501 0.06263 0.0 11.93 0.0 0.573 ... 273.0 21.0 391.99 9.67 22.4
502 0.04527 0.0 11.93 0.0 0.573 ... 273.0 21.0 396.90 9.08 20.6
503 0.06076 0.0 11.93 0.0 0.573 ... 273.0 21.0 396.90 5.64 23.9
504 0.10959 0.0 11.93 0.0 0.573 ... 273.0 21.0 393.45 6.48 22.0
505 0.04741 0.0 11.93 0.0 0.573 ... 273.0 21.0 396.90 7.88 11.9

[506 rows x 14 columns]
<class 'pandas. core. frame. DataFrame'>
RangeIndex: 506 entries, 0 to 505
Data columns (total 14 columns):
 # Column Non-Null Count Dtype
--- ------ -------------- -----
 0 CRIM 506 non-null float64
 1 ZN 506 non-null float64
 2 INDUS 506 non-null float64
 3 CHAS 506 non-null float64
 4 NOX 506 non-null float64
 5 RM 506 non-null float64
 6 AGE 506 non-null float64
 7 DIS 506 non-null float64
 8 RAD 506 non-null float64
 9 TAX 506 non-null float64
 10 PTRATIO 506 non-null float64
 11 B 506 non-null float64
 12 LSTAT 506 non-null float64
 13 target 506 non-null float64
dtypes: float64(14)
memory usage: 55.5 KB

# 2. Data preprocessing

# 2.1, Separate Features and Labels

# 3. Model training and reasoning

# 3.1, split data set

# 3.2, data reprocessing

# Reshape the input data into a 3D tensor (number of samples, time steps, number of features)

<class 'numpy.ndarray'> (455, 1, 13) X_train
 [[[6.04700e-02 0.00000e + 00 2.46000e + 00 ... 1.78000e + 01 3.87110e + 02
   1.31500e+01]]

 [[6.29760e-01 0.00000e + 00 8.14000e + 00 ... 2.10000e + 01 3.96900e + 02
   8.26000e+00]]

 [[7.99248e + 00 0.00000e + 00 1.81000e + 01 ... 2.02000e + 01 3.96900e + 02
   2.45600e+01]]

 ...

 [[3.51140e-01 0.00000e + 00 7.38000e + 00 ... 1.96000e + 01 3.96900e + 02
   7.70000e+00]]

 [[9.18702e + 00 0.00000e + 00 1.81000e + 01 ... 2.02000e + 01 3.96900e + 02
   2.36000e+01]]

 [[4.55587e + 00 0.00000e + 00 1.81000e + 01 ... 2.02000e + 01 3.54700e + 02
   7.12000e+00]]]

# 3.3, Establish LSTM model

'''
    Best score: -21.122341, Best params: {'dropout_rate': 0.0, 'learning_rate': 0.0001, 'num_layers': 1, 'num_units': 143}
    Best score: -23.943178, Best params: {'dropout_rate': 0.1, 'learning_rate': 0.0001, 'num_layers': 2, 'num_units': 196}
    '''

updating……

# 3.5, Model validation based on the best parameters of the model

# Draw the loss curve of training set and test set

# Model Evaluation

boston_val_MAE: 3.313431107764151
boston_val_MSE: 31.028591241678967
boston_val_RMSE: 5.570331340385325
boston_val_R2: 0.7286054759011734

# Draw forecast results

The knowledge points of the article match the official knowledge files, and you can further learn relevant knowledge Algorithm skill treeHomepageOverview 41925 people are studying systematically