Below is a list of some commonly used functions,and class available in the GRFlood Python package.
Flood(file_name)
Class to defined your project instance and initialize your data to train several popular statistical models to predict regional flooding.
- Parametres :
Name |
Type |
Description |
Default |
|---|---|---|---|
| file_name | path object or file-like object | Any valid string path is acceptable. The string could be a URL. Valid URL schemes include http, ftp, s3, gs, and file. For file URLs, a host is expected. A local file could be: file://localhost/path/to/table.csv.If you want to pass in a path object, pandas accepts any os.PathLike.By file-like object, we refer to objects with a read() method, such as a file handle (e.g. via builtin open function) or StringIO. | required |
instance.data(file_name)
Method to upload your data and visualize them.
- Parametres :
Name |
Type |
Description |
Default |
|---|---|---|---|
| file_name | path object or file-like object | Any valid string path is acceptable. The string could be a URL.A local file could be: file://localhost/path/to/table.csv.If you want to pass in a path object,we refer to objects with a read() method, or StringIO. | required |
instance.normalized_features(data)
Refers to rescaling real-valued numeric attributes into a 0 to 1 range.
Data normalization is used to make model training less sensitive to the scale of features. This allows our model to converge to better weights and, in turn, leads to a more accurate model.
* Parametres :
Name |
Type |
Description |
Default |
|---|---|---|---|
| data | ndarray, DataFrame | can contain Series, arrays get from instande.data(file_name), constants, dataclass or list-like objects. | required |
instance.split(dataset, ratio)
Split your data into train data and test data.
- Parametres :
Name |
Type |
Description |
Default |
|---|---|---|---|
| dataset | ndarray, DataFrame | can contain Series, arrays get from instande.data(file_name), constants, dataclass or list-like objects. | required |
| ratio | float | the ratio of your train data to train your model | 75 |
instance.test_stationarity(timeseries)
Checking stationarity, we’ll be using the rolling statistics plots along with Dickey-Fuller test results.
- Parametres :
Name |
Type |
Description |
Default |
|---|---|---|---|
| timeseries | array_like, 1d | Any scalar or sequence that can be interpreted as an ndarray to test stationarity. | required |
instance.ANN_model(train, test, train_size, data ,look_back = 1 )
Artificial Neural Network model.
- Parametres :
Name |
Type |
Description |
Default |
|---|---|---|---|
| train | array_like | contain ndarray of your train data (it can be extract from instance.train derived from split method). | required |
| test | array_like | contain ndarray of your test data (it can be extracted from instance.train derived from split method). | required |
| train_size | int | size of train data | required |
| data | ndarray, DataFrame | can contain Series, arrays get from instande.data(file_name), constants, dataclass or list-like objects. | required |
| look_back | float | window size | 1 |
instance.LSTM_model(train, test, train_size, data ,look_back = 1 )
Long Short-Term Memory model.
- Parametres :
Name |
Type |
Description |
Default |
|---|---|---|---|
| train | array_like | contain ndarray of your train data (it can be extract from instance.train derived from split method). | required |
| test | array_like | contain ndarray of your test data (it can be extracted from instance.train derived from split method). | required |
| train_size | int | size of train data | required |
| data | ndarray, DataFrame | can contain Series, arrays get from instande.data(file_name), constants, dataclass or list-like objects. | required |
| look_back | float | window size | 1 |
instance.RNN_model(train, test, train_size, data ,look_back = 1 )
Recurrent Neural Network model.
- Parametres :
Name |
Type |
Description |
Default |
|---|---|---|---|
| train | array_like | contain ndarray of your train data (it can be extract from instance.train derived from split method). | required |
| test | array_like | contain ndarray of your test data (it can be extracted from instance.train derived from split method). | required |
| train_size | int | size of train data | required |
| data | ndarray, DataFrame | can contain Series, arrays get from instande.data(file_name), constants, dataclass or list-like objects. | required |
| look_back | float | window size | 1 |
differencing(data, periods = 1 )
This mostly works well in improving stationarity.One of the most common methods of dealing with both trend(variation in the mean over time) and seasonality is differencing. In this technique, we take the difference of the observation at a particular instant with that at the previous instant.
- Parametres :
Name |
Type |
Description |
Default |
|---|---|---|---|
| data | ndarray, DataFrame | can contain Series, arrays get from instande.data(file_name), constants, dataclass or list-like objects. | required |
| periods | int | Number of periods to shift. Can be positive or negative. | 1 |
moving_average(timeseries, window)
In this approach, we take average of ‘k’ consecutive values depending on the frequency of time series,to deal with trend(variation in the mean over time)
- Parametres :
Name |
Type |
Description |
Default |
|---|---|---|---|
| timeseries | array_like, 1d | Any scalar or sequence that can be interpreted as an ndarray to test stationarity. | required |
| window | int | Size of the moving window. This is the number of observations used for calculating the statistic. Each window will be a fixed size. | required |