百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
S

skits

> 编程语言
开源

受 scikit-learn 启发的时间序列

199 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

受 scikit-learn 启发的时间序列

skits

A library for SciKit-learn-Inspired Time Series models.

The primary goal of this library is to allow one to train time series prediction models using a similar API to scikit-learn. Consequently, similar to scikit-learn, this library consists of preprocessors, feature_extractors, and pipelines.

Installation

Install with pip:

commandline
pip install skits

Preprocessors

The preprocessors expect to receive time series data, and then end up storing some data about the time series such that they can fully invert a transform. The following example shows how to create a DifferenceTransformer transform data, and then invert it back to its original form. The DifferenceTransformer subtracts the point shifted by period away from each point.

python
import numpy as np
from skits.preprocessing import DifferenceTransformer

y = np.random.random(10)
# scikit-learn expects 2D design matrices,
# so we duplicate the time series.
X = y[:, np.newaxis] 

dt = DifferenceTransformer(period=2)

Xt = dt.fit_transform(X,y)
X_inv = dt.inverse_transform(Xt)

assert np.allclose(X, X_inv)

Feature Extractors

After all preprocessing transformations are completed, multiple features may be built out of the time series. These can be built via feature extractors, which one should combine together into a large FeatureUnion. Current features include autoregressive, seasonal, and integrated features (covering the AR and I of ARIMA models).

Pipelines

There are two types of pipelines. The ForecasterPipeline is for forecasting time series (duh). Specifically, one should build this pipeline with a regressor as the final step such that one can make appropriate predictions. The functionality is similar to a regular scikit-learn pipeline. Differences include the addition of a forecast() method along with a to_scale keyword argument to predict() such that one can make sure that their prediction is on the same scale as the original data.

These classes are likely subject to change as they are fairly hacky right now. For example, one must transform both X and y for all transformations before the introduction of a DifferenceTransformer. While the pipeline handles this, one must prefix all of these transformations with pre_ in the step names.

Anywho, here's an example:

…

And this ends up looking like:

python
import matplotlib.pyplot as plt

plt.plot(y, lw=2)
plt.plot(y_pred, lw=2)
plt.legend(['y_true', 'y_pred'], bbox_to_anchor=(1, 1));

And forecasting looks like

python
start_idx = 70
plt.plot(y, lw=2);
plt.plot(pipeline.forecast(y[:, np.newaxis], start_idx=start_idx), lw=2);
ax = plt.gca();
ylim = ax.get_ylim();
plt.plot((start_idx, start_idx), ylim, lw=4);
plt.ylim(ylim);
plt.legend(['y_true', 'y_pred', 'forecast start'], bbox_to_anchor=(1, 1));

Issues· 5 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Pythonmachine-learningtime-series

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言