Skip to content

Commit

Permalink
Merge branch 'main' into visualize-climatology
Browse files Browse the repository at this point in the history
  • Loading branch information
eeholmes authored Aug 22, 2024
2 parents 36b4c09 + eb3f6b9 commit d6c7285
Show file tree
Hide file tree
Showing 8 changed files with 12,918 additions and 304 deletions.
3 changes: 1 addition & 2 deletions book/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,4 @@ parts:
title: ConvLSTM
sections:
- file: notebooks/CHL_prediction_ConvLSTM_.ipynb
title: - Fit ConvLSTM

title: - Fit ConvLSTM
624 changes: 322 additions & 302 deletions book/notebooks/Data_Prep.ipynb

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions book/notebooks/convlstm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# ConvLSTM

Our data are a time series of images and it would be good to use that time information and prior days' observations of Chlorophyll-a to help use make predictions. The idea is similar to the simple CNN except that we add the prior days. Mathematically it is more complicated since we do not include the prior days as independent variables; we take into account that the information in consecutive days is correlated.

This type of model is what we will want to use to make predictions when we have the day from prior days available. We want to take that data into account since today is likely to be similar to yesterday.

![](images/convlstm.jpg)

## Prepping the data


## Modeling fitting, validation and testing

The model steps are the same as for the Simple CNN example.

Once we have the data in the right form, we pass our model fitting function the training data sets `X_train` (predictors) and `y_train` (response or what we are trying to learn). During training, we learn the parameters.

During the validation step, we will run a loop to improve our hyperparameters (structure of our model) using the `X_val` and `y_val` that were not used in training. The result is our 'best' model.

Finally, during the test step, we use our best model to make predictions for the days that it has never 'seen' (the test data). It will use the predictors for these test days (`X_test`) to make predictions and then we will compare the predictions to the true values (`y_test`).
Binary file added book/notebooks/images/simple_cnn.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions book/notebooks/simple_cnn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Simple CNN

In this example, we will attempt to use a Convolutional Neural Network trained on sea surface temperature (sst) and salinity to predict Chlorophyl-a. This is a toy example and won't work very well since sst and salinity do not predict chlorphyll-a all that well. But it will show you the steps involved: prep data into xarray objects used for training, validation and testing.

![](images/simple_cnn.jpg)

## Prepping the data

There are many data formats you could use, but we are going to use xarrays (a type of data cube). Technically, it is a numpy array with some meta data. Our arrays with have a bounding box (lat/lon), a time dimension, and variables.

We want to create an xarray for the training, validation, and test data:

- `X_train, X_val, X_test`: the predictor variables of the train/validation/test data
- `y_train, y_val, y_test`: the response variables of the train/validation/test data

All the xarrays will have the same lat/lon grid. The `_train` sets will have the same days, the `_val` will have the same days, and the `_test` will have the same days.

## Modeling fitting, validation and testing

Once we have the data in the right form, we pass our model fitting function the training data sets `X_train` (predictors) and `y_train` (response or what we are trying to learn). During training, we learn the parameters.

During the validation step, we will run a loop to improve our hyperparameters (structure of our model) using the `X_val` and `y_val` that were not used in training. The result is our 'best' model.

Finally, during the test step, we use our best model to make predictions for the days that it has never 'seen' (the test data). It will use the predictors for these test days (`X_test`) to make predictions and then we will compare the predictions to the true values (`y_test`).
Loading

0 comments on commit d6c7285

Please sign in to comment.