{"id":13528701,"url":"https://github.com/cerlymarco/tsmoothie","last_synced_at":"2025-12-25T00:57:08.794Z","repository":{"id":40341572,"uuid":"289688313","full_name":"cerlymarco/tsmoothie","owner":"cerlymarco","description":"A python library for time-series smoothing and outlier detection in a vectorized way.","archived":false,"fork":false,"pushed_at":"2023-11-23T08:06:43.000Z","size":3035,"stargazers_count":700,"open_issues_count":1,"forks_count":95,"subscribers_count":17,"default_branch":"master","last_synced_at":"2024-04-28T12:43:13.072Z","etag":null,"topics":["bootstrap","bootstrapping-statistics","outlier-detection","outlier-removal","series-smoothing","smoothing","time-series","timeseries"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cerlymarco.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}},"created_at":"2020-08-23T13:09:27.000Z","updated_at":"2024-04-18T14:17:59.000Z","dependencies_parsed_at":"2024-01-18T17:44:11.469Z","dependency_job_id":"fc1cc6f5-0e8f-4591-8d98-d46a3132dcfe","html_url":"https://github.com/cerlymarco/tsmoothie","commit_stats":{"total_commits":38,"total_committers":2,"mean_commits":19.0,"dds":0.02631578947368418,"last_synced_commit":"8703fb931bf7ca5e5f6a97070f298f32364e053e"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cerlymarco%2Ftsmoothie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cerlymarco%2Ftsmoothie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cerlymarco%2Ftsmoothie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cerlymarco%2Ftsmoothie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cerlymarco","download_url":"https://codeload.github.com/cerlymarco/tsmoothie/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246655216,"owners_count":20812600,"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":["bootstrap","bootstrapping-statistics","outlier-detection","outlier-removal","series-smoothing","smoothing","time-series","timeseries"],"created_at":"2024-08-01T07:00:22.972Z","updated_at":"2025-12-25T00:57:08.782Z","avatar_url":"https://github.com/cerlymarco.png","language":"Jupyter Notebook","funding_links":[],"categories":["Libraries","Time Series Analysis","\u003cspan id=\"head75\"\u003e Outlier Detection\u003c/span\u003e","Python","📦 Packages","Python：量化金融第一生态"],"sub_categories":["Specialized Machine Learning Libraries","Time Series","Python","六、时间序列分析与预测"],"readme":"# tsmoothie\n\nA python library for time-series smoothing and outlier detection in a vectorized way.\n\n## Overview\n\ntsmoothie computes, in a fast and efficient way, the smoothing of single or multiple time-series. \n\nThe smoothing techniques available are:\n\n- Exponential Smoothing\n- Convolutional Smoothing with various window types (constant, hanning, hamming, bartlett, blackman)\n- Spectral Smoothing with Fourier Transform\n- Polynomial Smoothing \n- Spline Smoothing of various kind (linear, cubic, natural cubic) \n- Gaussian Smoothing \n- Binner Smoothing \n- LOWESS \n- Seasonal Decompose Smoothing of various kind (convolution, lowess, natural cubic spline)\n- Kalman Smoothing with customizable components (level, trend, seasonality, long seasonality) \n\ntsmoothie provides the calculation of intervals as result of the smoothing process. This can be useful to identify outliers and anomalies in time-series.\n\nIn relation to the smoothing method used, the interval types available are:\n\n- sigma intervals\n- confidence intervals\n- predictions intervals\n- kalman intervals\n\ntsmoothie can carry out a sliding smoothing approach to simulate an online usage. This is possible splitting the time-series into equal sized pieces and smoothing them independently. As always, this functionality is implemented in a vectorized way through the **WindowWrapper** class.\n\ntsmoothie can operate time-series bootstrap through the **BootstrappingWrapper** class.\n\nThe supported bootstrap algorithms are:\n\n- none overlapping block bootstrap\n- moving block bootstrap\n- circular block bootstrap\n- stationary bootstrap\n\n## Media\n\nBlog Posts:\n\n- [Time Series Smoothing for better Clustering](https://towardsdatascience.com/time-series-smoothing-for-better-clustering-121b98f308e8)\n- [Time Series Smoothing for better Forecasting](https://towardsdatascience.com/time-series-smoothing-for-better-forecasting-7fbf10428b2)\n- [Real-Time Time Series Anomaly Detection](https://towardsdatascience.com/real-time-time-series-anomaly-detection-981cf1e1ca13)\n- [Extreme Event Time Series Preprocessing](https://towardsdatascience.com/extreme-event-time-series-preprocessing-90aa59d5630c)\n- [Time Series Bootstrap in the age of Deep Learning](https://towardsdatascience.com/time-series-bootstrap-in-the-age-of-deep-learning-b98aa2aa32c4)\n\n## Installation\n\n```shell\npip install --upgrade tsmoothie\n```\n\nThe module depends only on NumPy, SciPy and simdkalman. Python 3.6 or above is supported.\n\n## Usage: _smoothing_\n\nBelow a couple of examples of how tsmoothie works. Full examples are available in the [notebooks folder](https://github.com/cerlymarco/tsmoothie/tree/master/notebooks).\n\n```python\n# import libraries\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom tsmoothie.utils_func import sim_randomwalk\nfrom tsmoothie.smoother import LowessSmoother\n\n# generate 3 randomwalks of lenght 200\nnp.random.seed(123)\ndata = sim_randomwalk(n_series=3, timesteps=200, \n                      process_noise=10, measure_noise=30)\n\n# operate smoothing\nsmoother = LowessSmoother(smooth_fraction=0.1, iterations=1)\nsmoother.smooth(data)\n\n# generate intervals\nlow, up = smoother.get_intervals('prediction_interval')\n\n# plot the smoothed timeseries with intervals\nplt.figure(figsize=(18,5))\n\nfor i in range(3):\n    \n    plt.subplot(1,3,i+1)\n    plt.plot(smoother.smooth_data[i], linewidth=3, color='blue')\n    plt.plot(smoother.data[i], '.k')\n    plt.title(f\"timeseries {i+1}\"); plt.xlabel('time')\n\n    plt.fill_between(range(len(smoother.data[i])), low[i], up[i], alpha=0.3)\n```\n\n![Randomwalk Smoothing](https://raw.githubusercontent.com/cerlymarco/tsmoothie/master/imgs/randomwalk_smoothing.png)\n\n```python\n# import libraries\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom tsmoothie.utils_func import sim_seasonal_data\nfrom tsmoothie.smoother import DecomposeSmoother\n\n# generate 3 periodic timeseries of lenght 300\nnp.random.seed(123)\ndata = sim_seasonal_data(n_series=3, timesteps=300, \n                         freq=24, measure_noise=30)\n\n# operate smoothing\nsmoother = DecomposeSmoother(smooth_type='lowess', periods=24,\n                             smooth_fraction=0.3)\nsmoother.smooth(data)\n\n# generate intervals\nlow, up = smoother.get_intervals('sigma_interval')\n\n# plot the smoothed timeseries with intervals\nplt.figure(figsize=(18,5))\n\nfor i in range(3):\n    \n    plt.subplot(1,3,i+1)\n    plt.plot(smoother.smooth_data[i], linewidth=3, color='blue')\n    plt.plot(smoother.data[i], '.k')\n    plt.title(f\"timeseries {i+1}\"); plt.xlabel('time')\n\n    plt.fill_between(range(len(smoother.data[i])), low[i], up[i], alpha=0.3)\n```\n\n![Sinusoidal Smoothing](https://raw.githubusercontent.com/cerlymarco/tsmoothie/master/imgs/sinusoidal_smoothing.png)\n\n**All the available smoothers are fully integrable with sklearn (see [here](https://github.com/cerlymarco/tsmoothie/blob/master/notebooks/sklearn-wrapper.ipynb)).**\n\n## Usage: _bootstrap_\n\n```python\n# import libraries\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom tsmoothie.utils_func import sim_seasonal_data\nfrom tsmoothie.smoother import ConvolutionSmoother\nfrom tsmoothie.bootstrap import BootstrappingWrapper\n\n# generate a periodic timeseries of lenght 300\nnp.random.seed(123)\ndata = sim_seasonal_data(n_series=1, timesteps=300, \n                         freq=24, measure_noise=15)\n\n# operate bootstrap\nbts = BootstrappingWrapper(ConvolutionSmoother(window_len=8, window_type='ones'), \n                           bootstrap_type='mbb', block_length=24)\nbts_samples = bts.sample(data, n_samples=100)\n\n# plot the bootstrapped timeseries\nplt.figure(figsize=(13,5))\nplt.plot(bts_samples.T, alpha=0.3, c='orange')\nplt.plot(data[0], c='blue', linewidth=2)\n```\n\n![Sinusoidal Bootstrap](https://raw.githubusercontent.com/cerlymarco/tsmoothie/master/imgs/sinusoidal_bootstrap.png)\n\n## References\n\n- Polynomial, Spline, Gaussian and Binner smoothing are carried out building a regression on custom basis expansions. These implementations are based on the amazing intuitions of Matthew Drury available [here](https://github.com/madrury/basis-expansions/blob/master/examples/comparison-of-smoothing-methods.ipynb)\n- Time Series Modelling with Unobserved Components, Matteo M. Pelagatti\n- Bootstrap Methods in Time Series Analysis, Fanny Bergström, Stockholms universitet\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcerlymarco%2Ftsmoothie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcerlymarco%2Ftsmoothie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcerlymarco%2Ftsmoothie/lists"}