python package for generating calendars for machine learning timeseries analysis.
Project description
lilio: Calendar generator for machine learning with timeseries data
A python package for generating calendars to resample timeseries into training and target data for machine learning.
Installation
To install the in-development version from the GitHub repository, do:
python3 -m pip install git+https://github.com/AI4S2S/lilio.git
Configure the package for development and testing
The testing framework used here is pytest. Before running the test, we get a local copy of the source code and install lilio
via the command:
git clone https://github.com/AI4S2S/lilio.git
cd lilio
python3 -m pip install -e .
Then, run tests:
python3 -m pytest
How the lilio calendars work
In a typical ML-based timeseries analysis, the first step is always data processing. A calendar-based datetime module time
is implemented for time operations. For instance, a user is looking for predictors for winter climate at seasonal timescales (~180 days). First, a calendar
object is created using AdventCalendar
:
>>> calendar = s2spy.time.AdventCalendar(anchor="11-30", freq='180d')
>>> calendar = calendar.map_years(2020, 2021)
>>> calendar.show()
i_interval -1 1
anchor_year
2021 [2021-06-03, 2021-11-30) [2021-11-30, 2022-05-29)
2020 [2020-06-03, 2020-11-30) [2020-11-30, 2021-05-29)
Now, the user can load the data input_data
(e.g. pandas
DataFrame
) and resample it to the desired timescales configured in the calendar:
>>> calendar = calendar.map_to_data(input_data)
>>> bins = s2spy.time.resample(calendar, input_data)
>>> bins
anchor_year i_interval interval mean_data target
0 2020 -1 [2020-06-03, 2020-11-30) 275.5 True
1 2020 1 [2020-11-30, 2021-05-29) 95.5 False
2 2021 -1 [2021-06-03, 2021-11-30) 640.5 True
3 2021 1 [2021-11-30, 2022-05-29) 460.5 False
Depending on data preparations, we can choose different types of calendars e.g. MonthlyCalendar
and WeeklyCalendar
.
Contributing
If you want to contribute to the development of lilio, have a look at the contribution guidelines.
Credits
This package was created with Cookiecutter and the NLeSC/python-template.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.