Do Earthquakes Follow A Pattern? (Part 2)

Kamil DİLBAZ
Datajarlabs
Published in
5 min readNov 18, 2019
Do Earthquakes Follow A Pattern?
(Photo by Petrovich9, Getty Images/iStockphoto)

If you have not read part 1, I recommend you to read it first from here: part 1

For predicting target features, I try both DNN (dense layer neural network) and LSTM (long short term memory) network with many variations of hyperparameters.

I use all 10 features that I mentioned in part 1.

new_labels = ["Latitude", "Longtitude", "Days", "Magnitude",              "Depth", "Fixed Depth", "Risk Grade", "Time Gap",              "Log.Days", "Log.Hour-Day Ratio"]new_data = extended_data[new_labels]
  • For dense layer, initial 4 of them are target variables and other 6 are independent variables.
  • For LSTM, independent variables are all 10 features and target variables are 1-shifted values of initial 4 features.

I reserve last 25% of data points as test set for both networks to be able to evaluate results fairly. Also, I use 25% of training set as validation set. Then, I choose hyperparameters (quantity of hidden layers, batch size, epochs and optimizers to use) to check out for both models.

# Hyperparameters of dense modelhidden=[32, 64, 100, 128]optimizers=["rmsprop", "adam", "SGD"]batch=[32, 64, 128, 256]epoch=[100, 300, 500, 700]
# Hyperparameters of LSTM modelhidden=[30, 50, 80]optimizers=["rmsprop"]batch=[32, 64, 128]epoch=[250, 500, 750]

There are 219 different variations (192 variations of dense model and 27 variations of LSTM model). To check all of them, there are some built-in algorithms such as GraphSearchCV and RandomizedSearchCV. But, they do not meet my needs. Some causes are:

  • I use Google Colaboratory and it does not allow to use more than 12 hours. Also, if there are no transactions for a while, runtime disconnects.
  • When there is an interruption due to any problems, it is mandatory to begin from the very beginning. The time spent becomes rubbish.
  • I need some extra information (recording history & evaluation values according to all hyperparameters and best models) then built-in algorithms give.

Because of these issues, I decide to write my own graph search algorithm. With this algorithm; values can be saved in time, the process can be interrupted and can be resumed.

When my algorithm is ready, it is time to go. My metrics are root mean square (rms)(recorded as evaluation_0) and mean absolute error (mae)(recorded as evaluation_1). Dense network takes 12 hours with GPU and 3 hours with TPU. LSTM takes 12 hours (approximately the same time) with both processors. We now can examine the results.

Dense network rms scores
Figure 1: Dense network rms scores
LSTM network rms scores
Figure 2: LSTM network rms scores

Lower lines on bars shows minimum scores and top of the bar shows maximum scores. Graphics are shown with different axis scales. Because, LSTM models perform pretty well according to Dense models. On the graphics, I see these:

  • LSTM models are better than Dense models.
  • Dense models can differentiate on a large scale.
  • All Dense models’ minimum performances are similar to each other. Can that mean “Dense models’ best performances are restricted for this kind of data sets?”
  • Hyperparameters achieve different effects on different model types.
Minimum rms scores
Figure 3: Minimum rms scores

As seen above, LSTM model has the lowest rms score. To see the results better, Lets predict on test set and compare them to real values.

Coordinates prediction
Figure 4: Coordinates (latitude and longitude) prediction

Dense network prediction seems like an arrow heading to right. There is no relation with real values.

LSTM network prediction is clustered in the center. It is a little bit better than dense network.

Days passed after the date 01.01.1900
Figure 5: Days passed since 01.01.1900

LSTM network fails to success. For days prediction, dense network’s performance is not very good, but it can handle.

Magnitude of earthquake prediction
Figure 6: Magnitude of earthquake prediction

This time, dense network fails again. It predicts all on same line. LSTM network is more realistic.

Prediction efforts in this study relies on checking out whether there are any correlations with former earthquakes. According to graphics above;

  • Placement prediction: Both models are not well enough to alarm anybody.
  • Days prediction: Dense model is pretty better than LSTM model.
  • Magnitude prediction: LSTM model seems better, but it is not what it is expected to be.

In total, Dense model is better for days prediction and LSTM model is better for others.

Overall, success is not high enough to prove that earthquakes follow a specific pattern. In all models, there are mainly three possible causes of uncertainty:

  • All observations happen in an exactly random state,
  • Lack of observations or features that affect the system,
  • The model is missing some required information.

As being interested in data science, you should know that all machine learning and deep learning models give some results on all occasions, even if input values has no relation with the target.

Former prediction researches and this study show that any seemingly related features should be added to models and model should be run from the very beginning.

For further information and codes, you can review my GitHub repository: Earthquake modeling

If you like this post, please hit the clap button on left as much as you can. And also, you can share it.

--

--

Kamil DİLBAZ
Datajarlabs

Computer Scientist | Data Scientist | AI Enthusiast