時系列機械学習の専門ツールキット。分類、回帰、クラスタリング、予測、異常検出に対応。aeonライブラリをベース。
統合スキル: このスキルは aeon をベースにした時系列機械学習ツールキットです。
時系列データの機械学習に特化したツールキット。分類、回帰、クラスタリング、予測、異常検出、セグメンテーションをscikit-learn互換APIで提供。
主な機能:
# aeon本體
uv pip install aeon
# 追加機能
uv pip install aeon[all_extras]
# 可視化
uv pip install matplotlib seaborn
| タスク | 使用場面 |
|---|---|
| 分類 | 時系列パターンの識別 |
| 回帰 |
| 時系列からの値予測 |
| クラスタリング | 類似時系列のグループ化 |
| 予測 | 将来値の予測 |
| 異常検出 | 外れ値・異常パターン検出 |
from aeon.classification.interval_based import CanonicalIntervalForestClassifier
from aeon.datasets import load_basic_motions
# データ読み込み
X_train, y_train = load_basic_motions(split="train")
X_test, y_test = load_basic_motions(split="test")
# 分類器訓練
clf = CanonicalIntervalForestClassifier()
clf.fit(X_train, y_train)
# 予測
y_pred = clf.predict(X_test)
# 評価
from sklearn.metrics import accuracy_score
accuracy = accuracy_score(y_test, y_pred)
print(f"Accuracy: {accuracy:.3f}")
from aeon.clustering import TimeSeriesKMeans
from aeon.datasets import load_arrow_head
# データ
X, y = load_arrow_head()
# k-means クラスタリング
kmeans = TimeSeriesKMeans(n_clusters=3, metric="dtw")
kmeans.fit(X)
# クラスタ割り当て
clusters = kmeans.predict(X)
from aeon.forecasting import ARIMA, ExponentialSmoothing
from aeon.datasets import load_airline
# データ
y = load_airline()
# ARIMA モデル
forecaster = ARIMA(order=(1, 1, 1))
forecaster.fit(y)
# 予測
predictions = forecaster.predict(fh=[1, 2, 3, 4, 5])
from aeon.anomaly_detection import IsolationForest
# 異常検出器
detector = IsolationForest(contamination=0.1)
detector.fit(X_train)
# 異常スコア
scores = detector.predict_proba(X_test)
| アルゴリズム | 特徴 | 推奨用途 |
|---|---|---|
| CanonicalIntervalForest | 区間ベース | 汎用 |
| ROCKET | ランダムカーネル | 高速 |
| InceptionTime | ディープラーニング | 複雑パターン |
| HIVE-COTE | アンサンブル | 最高精度 |
| アルゴリズム | 特徴 | 推奨用途 |
|---|---|---|
| TimeSeriesKMeans | DTW距離 | ベースライン |
| KShape | シェープベース | 類似形状 |
| KMedoids | メドイドベース | 外れ値に強い |
| アルゴリズム | 特徴 | 推奨用途 |
|---|---|---|
| ARIMA | 統計的 | 定常時系列 |
| ExponentialSmoothing | 統計的 | トレンド・季節性 |
| Prophet | 加法モデル | 実務データ |
| N-BEATS | ニューラル | 高精度 |
# 単変量時系列: (n_samples, n_timepoints)
X_univariate = np.random.rand(100, 50)
# 多変量時系列: (n_samples, n_channels, n_timepoints)
X_multivariate = np.random.rand(100, 3, 50)
# 不等長時系列: list of arrays
X_unequal = [np.random.rand(30), np.random.rand(45), np.random.rand(35)]
from aeon.transformations.collection import Normalizer, Resizer
# 正規化
normalizer = Normalizer()
X_normalized = normalizer.fit_transform(X)
# リサイズ(等長化)
resizer = Resizer(length=100)
X_resized = resizer.fit_transform(X)
from aeon.classification import DummyClassifier
from aeon.classification.distance_based import KNeighborsTimeSeriesClassifier
from aeon.classification.dictionary_based import WEASEL
# ベースライン
dummy = DummyClassifier()
# k-NN(DTW)
knn = KNeighborsTimeSeriesClassifier(distance="dtw")
# 辞書ベース
weasel = WEASEL()
from sklearn.model_selection import cross_val_score
from aeon.classification.interval_based import TimeSeriesForestClassifier
clf = TimeSeriesForestClassifier()
scores = cross_val_score(clf, X, y, cv=5)
print(f"CV Accuracy: {scores.mean():.3f} (+/- {scores.std():.3f})")
| 問題 | 原因 | 解決策 |
|---|---|---|
| 遅い訓練 | DTWの計算コスト | 近似DTW、サンプリング |
| メモリエラー | 大きなデータセット | バッチ処理 |
| 過学習 | 複雑なモデル | 正則化、簡素なモデル |
| 不等長エラー | 形式不一致 | Resizerで等長化 |
このスキルは時系列機械学習の専門ツールキットを提供します。 ベース: aeon