time series model for training sequence dataset
Project description
sequence-model-train
Sequence-model-train is a Python library for implementing Long Short-Term Memory (LSTM) models on time-series data. It takes a CSV file as input and allows you to specify various hyperparameters for the model.
Github:
https://github.com/ZhangLe59151/price_forecast
PyPi:
https://pypi.org/project/sequence-model-train/
Document:
https://zhanglenus.gitbook.io/sequence-model-train-library-document/
Example on the notebook:
https://zhanglenus.gitbook.io/sequence-model-train-library-document/notebook-demo
Installation
To install Library Sequence-model-train, run the following command in your terminal:
pip install sequence-model-train
Usage
To use Library Sequence-model-train, follow these steps:
- Import the library:
from sequence_model_train import train_model
- Create an instance of the TrainModel class and pass in the path to your training data CSV file:
train = train_model.TrainModel('/path/to/data.csv')
- Update the hyperparameters for the model by calling the
update_params()
method:
train.update_params(n_in=30, n_out=7, batch_size=128, hidden_size=128, num_epochs=100)
- Train the model by calling the train() method:
train.train()
API Reference
TrainModel
Parameters:
- data_path: a string that specifies the path to the training data CSV file. When creating an instance of the TrainModel class, you can provide the 'data_path' parameter to load your data. It is important to note that the last column in the CSV file should be the labels.
Methods:
- update_params: After creating an instance of the TrainModel class, you can update the following hyperparameters:
- data_path: The data path to your training dataset in CSV format.
- n_in: The number of time steps to use as input. The default value is 3.
- n_out: The number of future time steps to predict. The default value is 5.
- batch_size: The batch size to use during training. The default value is 32.
- hidden_size: The number of units in the LSTM layer. The default value is 32.
- num_layers: The number of the LSTM layer. The default value is 3.
- num_epochs: The number of epochs to train the model for. The default value is 10.
- train: Train the model. Training the model involves several steps, including data processing, normalization, and splitting into training and validation sets. Once trained, the model's performance is evaluated on the validation set using metrics such as loss, mean absolute error (MAE), and mean absolute percentage error (MAPE).
Example
# train the model
from sequence_model_train import train_model
train = train_model.TrainModel('./train.csv')
train.update_params(n_in=30, n_out=7, batch_size=128, hidden_size=128, num_epochs=100)
train.train()
# the result
{
'model': 'lstm',
'valid_result':
{
'valid_loss': 61.97545757072,
'valid_mae': 21.2288062782732,
'valid_mape': 0.1061233304225267
}
}
Conclusion
Sequence-model-train is a powerful tool for training LSTM models on time-series data. Its easy-to-use interface and comprehensive API make it a great choice for both beginners and advanced users. Hope you find this library useful and welcome your feedback and suggestions for improvement.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for sequence_model_train-0.1.20.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d860ff3aaa82c82d8c41a3a7035fbe002d4723376c4d42bc2b5beb9d4cc740c1 |
|
MD5 | 4c48dec0bffa85a40b3f238b20cd77e9 |
|
BLAKE2b-256 | b8b1ce225e73f1baaa3582b99b0b82bfbb59694ffff066515419daa23d69a756 |
Hashes for sequence_model_train-0.1.20-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b7c39068d270344cf0f028b092236ca9f118b60d645abc72e21ade63e313f638 |
|
MD5 | 86dfb7675ff5d88fe9b820f5fc7d24a8 |
|
BLAKE2b-256 | e023d1f734073d2fdfdbe8e2225e47b37fada81119509cd42b127f4c000ee450 |