Skip to main content

A general purpose stepshifting algorithm for tabular data, based on BaseEstimator.

Project description

StepShifter3 🛠️:

A general purpose Python package for time series analysis of tabular data

Official Website VIEWS Forecasting Website GitHub Repo stars Twitter Follow LinkedIn Unit Tests

StepShifter3 is a Python package designed to facilitate time series analysis of tabular data. It is developed and maintained by the Peace Research Institute Oslo (PRIO) as part of the VIEWS project.

📚 Table of Contents

  1. 🛠 Installation
  2. 📝 Usage
  3. 🤝 Contributing
  4. 🔖 License
  5. ❓ FAQs
  6. 🙏 Credits
  7. 📚 References

🛠 Installation

To install StepShifter3, you have two options:

  1. Using pip: 📦

    pip install StepShifter3
    
  2. From GitHub: 🐱‍💻

    git clone https://github.com/YourUsername/StepShifter3.git
    cd StepShifter3
    python setup.py install
    

📖 More Details

📝 Usage

The Stepshifter class is the main class of the package. It handles all models which is herited from the sklearn BaseEstimator class.

Basic Usage with XGBRegressor and dummy data from synthetic data generator

from StepShifter3 import StepShifter, SyntheticDataGenerator
from xgboost import XGBRegressor 

# generates a pandas multiindex dataframe with dummy data Indexes: month_id, country_id
df = SyntheticDataGenerator("cm", 516, 60000, 242).generate_dataframe()

#initialize the StepShifter3 object with the relevant parameters:
# define some XGBRegressor parameters:
params_xgb_reg = {
    'objective': 'reg:squarederror',
    'n_estimators': 500,
    'max_depth': 3,
    'learning_rate': 0.1,
    'n_jobs': -1,
    'eval_metric': 'rmse',
    'early_stopping_rounds': 30
}

stepshifter_config_xgb_reg = { "target_column" : "ln_ged_sb_dep",
                       "ID_columns" : ["month_id","country_id"],
                       "time_column" : "month_id",
                       "run_name" : 'xgb_reg_test_run_0',
                       "experiment_name" : 'xgb_reg_experiment_0',
                       "mlflow_tracking_uri" : 'http://127.0.0.1:5000',
                       "tau^e_0" : 121, # training period start
                       "tau^e_t" : 141, # training period end
                       "tau^e_c" : 146, # calibration period end
                       "tau^e_f" : 468, # forecast period end
                       "tau_f" : 516,   # Test Forfecast end 
                       "k": 13,
                       "S": 5,
                       "metrics_report": True,
                       "combine_method": 'mean_of_all',
                       }

# initialize class
stepshifter = StepShifter(XGBRegressor(**params_xgb_reg),df, stepshifter_config_xgb_reg)

# fit and predict
models = stepshifter.fit(stepshifter_config_xgb_reg['tau^e_0'],stepshifter_config_xgb_reg['tau^e_t'])
predictions = stepshifter.predict(stepshifter_config_xgb_reg['tau^e_t'],stepshifter_config_xgb_reg['tau^e_c'])

# Make model ensamble from training models and predict with a blended mean algorithm:

M_ssa = stepshifter.stepcombine()

X_test = stepshifter.X.loc[slice(136,136),slice(None),:]

# Make predictions for 1 and 3 months ahead of time:
blended_predictions = stepshifter.predict_ansamble(X_test,steps=[1,3])

Contributing

Contributions are welcome! To contribute:

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Please read our Contributing Guidelines for more information.

References

  1. Hegre et.al: Partitioning and time-shifting in VIEWS, fatalities002∗†

License

Distributed under the MIT License. See LICENSE for more information.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stepshifter3-0.0.1.tar.gz (12.7 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

stepshifter3-0.0.1-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

stepshifter3-0.0.1-py2.py3-none-any.whl (12.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file stepshifter3-0.0.1.tar.gz.

File metadata

  • Download URL: stepshifter3-0.0.1.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for stepshifter3-0.0.1.tar.gz
Algorithm Hash digest
SHA256 b107b466a4e01d735aab746b7edaf761d60d72594b0cef5c119324ddfe778a5f
MD5 e98b6611c93b28c1f13de08c65106936
BLAKE2b-256 9d3e8034b6613e3a9c01814353e2ca20ac4fe916f649745f691c78c8bff98644

See more details on using hashes here.

File details

Details for the file stepshifter3-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: stepshifter3-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for stepshifter3-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 45ef2dd7cdd033e9ffd10525b123a5c79933456adb46f62c2ed73b028275cd3e
MD5 6823dd90117cd1f469f67840c5064bd9
BLAKE2b-256 a8f7b2901be0cfd46a32d23a4d581d73ffbf2277e3b39493b18fae6386b54738

See more details on using hashes here.

File details

Details for the file stepshifter3-0.0.1-py2.py3-none-any.whl.

File metadata

  • Download URL: stepshifter3-0.0.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.6

File hashes

Hashes for stepshifter3-0.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d173e8ecded87decbb26ae8c6e88785876564cac6075d3eeafb9172fdbd83944
MD5 4452040e076c5175a2c035f5eb7f52e7
BLAKE2b-256 c1a424f8bec828aedbfb315fd58d8c6e19326aa702bd3f895f751a02c30fbe3d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page