{"id":26997190,"url":"https://github.com/adityalab/samay","last_synced_at":"2025-04-04T02:17:09.736Z","repository":{"id":266327813,"uuid":"874416767","full_name":"AdityaLab/Samay","owner":"AdityaLab","description":"State-of-art Foundational Time-series models","archived":false,"fork":false,"pushed_at":"2025-03-31T15:26:54.000Z","size":21000,"stargazers_count":16,"open_issues_count":7,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-31T16:56:39.691Z","etag":null,"topics":["deep-learning","foundation-models","machine-learning","neural-networks","pytorch","time-series","time-series-analysis"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AdityaLab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-17T19:38:43.000Z","updated_at":"2025-03-29T10:49:00.000Z","dependencies_parsed_at":"2024-12-03T18:38:13.462Z","dependency_job_id":"503cf0f5-1a33-413e-ae87-b0fee28bf794","html_url":"https://github.com/AdityaLab/Samay","commit_stats":null,"previous_names":["adityalab/samay"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdityaLab%2FSamay","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdityaLab%2FSamay/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdityaLab%2FSamay/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdityaLab%2FSamay/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AdityaLab","download_url":"https://codeload.github.com/AdityaLab/Samay/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247107827,"owners_count":20884797,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deep-learning","foundation-models","machine-learning","neural-networks","pytorch","time-series","time-series-analysis"],"created_at":"2025-04-04T02:17:09.151Z","updated_at":"2025-04-04T02:17:09.714Z","avatar_url":"https://github.com/AdityaLab.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Samay: Time-series Foundational Models Library\n\nPackage for training and evaluating time-series foundational models.\n\nCurrent repository contains the following models:\n\n1. [LPTM](https://arxiv.org/abs/2311.11413)\n2. [MOMENT](https://arxiv.org/abs/2402.03885)\n3. [TimesFM](https://arxiv.org/html/2310.10688v2)\n4. [Chronos](https://arxiv.org/abs/2403.07815)\n5. [MOIRAI](https://arxiv.org/abs/2402.02592)\n6. [TinytTimeMixers](https://arxiv.org/abs/2401.03955)\n\nMore models will be added soon...\n\n## Installation\n\nYou can add the package to your project by running the following command:\n\n```bash\npip install git+https://github.com/AdityaLab/Samay.git\n```\n\n**Note:** If the installation fails because rust is missing run:\n\nFor MacOS:\n\n```bash\nbrew install rustup\nrustup-init\nsource ~/.cargo/env\n```\n\nFor Linux:\n\n```bash\ncurl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh\nsource ~/.cargo/env\n```\n\n### Development workflow\n\nTo develop on the project, you can clone the repository and install the package in editable mode:\n\n```bash\n\n## Clone repo\ngit clone https://github.com/AdityaLab/Samay.git\n\n## Install uv\ncurl -LsSf https://astral.sh/uv/install.sh | sh\n\n## Install dependencies\nuv sync --reinstall\n```\n\n## Usage Examples\n\nCheck out example notebooks at `examples/` for more detailed examples. We also have google colab notebooks at `examples/colab/`.\n\n### LPTM\n\n#### Loading Model\n\n```python\nfrom samay.model import LPTMModel\n\nconfig = {\n    \"task_name\": \"forecasting\",\n    \"forecast_horizon\": 192,\n    \"freeze_encoder\": True,  # Freeze the patch embedding layer\n    \"freeze_embedder\": True,  # Freeze the transformer encoder\n    \"freeze_head\": False,  # The linear forecasting head must be trained\n}\nmodel = LPTMModel(config)\n```\n\n#### Loading Dataset\n\n```python\nfrom samay.dataset import LPTMDataset\n\ntrain_dataset = LPTMDataset(\n    name=\"ett\",\n    datetime_col=\"date\",\n    path=\"./data/data/ETTh1.csv\",\n    mode=\"train\",\n    horizon=192,\n)\n\nfinetuned_model = model.finetune(train_dataset)\n```\n\n#### Zero-Forecasting\n\n```python\navg_loss, trues, preds, histories = lptm.evaluate(val_dataset)\n```\n\n### TimesFM\n\n#### Loading Model\n\n```python\nfrom samay.model import TimesfmModel\nfrom samay.dataset import TimesfmDataset\n\nrepo = \"google/timesfm-1.0-200m-pytorch\"\nconfig = {\n    \"context_len\": 512,\n    \"horizon_len\": 192,\n    \"backend\": \"gpu\",\n    \"per_core_batch_size\": 32,\n    \"input_patch_len\": 32,\n    \"output_patch_len\": 128,\n    \"num_layers\": 20,\n    \"model_dims\": 1280,\n    \"quantiles\": [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9],\n}\n\ntfm = TimesfmModel(config=config, repo=repo)\n```\n\n#### Loading Dataset\n\n```python\ntrain_dataset = TimesfmDataset(name=\"ett\", datetime_col='date', path='data/ETTh1.csv', \n                              mode='train', context_len=config[\"context_len\"], horizon_len=128)\nval_dataset = TimesfmDataset(name=\"ett\", datetime_col='date', path='data/ETTh1.csv',\n                              mode='test', context_len=config[\"context_len\"], horizon_len=config[\"horizon_len\"])\n```\n\n#### Zero-Forecasting\n\n```python\navg_loss, trues, preds, histories = tfm.evaluate(val_dataset)\n```\n\n### MOIRAI\n\n#### Loading  Model\n\n```python\nfrom samay.dataset import MoiraiDataset\nfrom samay.model import MoiraiTSModel\n\nrepo = \"Salesforce/moirai-moe-1.0-R-small\"\nconfig = {\n        \"context_len\": 128,\n        \"horizon_len\": 64,\n        \"num_layers\": 100,\n        \"model_type\": \"moirai-moe\",\n        \"model_size\": \"small\"\n    }\n\nmoirai_model = MoiraiTSModel(repo=repo, config=config)\n```\n\n#### Loading Dataset\n\n```python\n\ntrain_dataset = MoiraiDataset(name=\"ett\", mode=\"train\", path=\"data/ETTh1.csv\", datetime_col=\"date\", freq=\"h\",\n                            context_len=config['context_len'], horizon_len=config['horizon_len'])\n\ntest_dataset = MoiraiDataset(name=\"ett\", mode=\"test\", path=\"data/ETTh1.csv\", datetime_col=\"date\", freq=\"h\",\n                            context_len=config['context_len'], horizon_len=config['horizon_len'])\n```\n\n#### Zero-Forecasting\n\n```python\neval_results, trues, preds, histories = moirai_model.evaluate(test_dataset, metrics=[\"MSE\", \"MASE\"])\n```\n\n### Support\n\nTested on Python 3.11-3.13 on Linux (CPU + GPU) and MacOS (CPU). Supports NVIDIA GPUs.\nSupport for Windows and Apple Silicon GPUs is planned.\n\n## Citation\n\nIf you use this code in your research, please cite the following paper:\n\n```bibtex\n@inproceedings{\nkamarthi2024large,\ntitle={Large Pre-trained time series models for cross-domain Time series analysis tasks},\nauthor={Harshavardhan Kamarthi and B. Aditya Prakash},\nbooktitle={The Thirty-eighth Annual Conference on Neural Information Processing Systems},\nyear={2024},\nurl={https://openreview.net/forum?id=vMMzjCr5Zj}\n}\n```\n\n## Contact\n\nIf you have any feedback or questions, you can contact us via email: \u003chkamarthi3@gatech.edu\u003e, \u003cbadityap@cc.gatech.edu\u003e.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadityalab%2Fsamay","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadityalab%2Fsamay","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadityalab%2Fsamay/lists"}