{"id":48667144,"url":"https://github.com/animagram-jp/flair","last_synced_at":"2026-04-10T11:07:32.773Z","repository":{"id":349559650,"uuid":"1200933934","full_name":"animagram-jp/flair","owner":"animagram-jp","description":"This is a Rust implement oss of FLAIR by Takato Honda.","archived":false,"fork":false,"pushed_at":"2026-04-06T14:56:43.000Z","size":118,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-06T15:38:15.450Z","etag":null,"topics":["apache-2-0","oss","time-series-forecasting"],"latest_commit_sha":null,"homepage":"https://github.com/TakatoHonda/FLAIR","language":"Rust","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/animagram-jp.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-04T02:13:41.000Z","updated_at":"2026-04-06T14:56:50.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/animagram-jp/flair","commit_stats":null,"previous_names":["animagram-jp/flair"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/animagram-jp/flair","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/animagram-jp%2Fflair","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/animagram-jp%2Fflair/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/animagram-jp%2Fflair/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/animagram-jp%2Fflair/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/animagram-jp","download_url":"https://codeload.github.com/animagram-jp/flair/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/animagram-jp%2Fflair/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31579058,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T14:31:17.711Z","status":"ssl_error","status_checked_at":"2026-04-08T14:31:17.202Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["apache-2-0","oss","time-series-forecasting"],"created_at":"2026-04-10T11:07:28.181Z","updated_at":"2026-04-10T11:07:32.767Z","avatar_url":"https://github.com/animagram-jp.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# flair\n\nRust implement of time series forecasting FLAIR by Takato Honda\n\n## Version\n\n| Version | Status    | Date      | Description |\n|---------|-----------|-----------|-------------|\n| 0.1.0   | Released  | 2026-4-09 | initial     |\n\n## Provided Functions\n\n**Common arguments**\n\n- **`y: \u0026[f64]`** — Observed values as a flat, equally-spaced 1-D array. No timestamps; the interval is given separately via `freq`. NaN is treated as 0.0.\n- **`freq: \u0026str`** — Observation interval: `\"H\"` (hourly), `\"D\"` (daily), `\"W\"` (weekly), `\"M\"` (monthly), `\"Q\"` (quarterly), `\"A\"` / `\"Y\"` (annual), etc.\n\n| Mod     | Fn | Input | Output | Description |\n|---------|----|-------|--------|-------------|\n| `flair` | `confidence` | `y: \u0026[f64]`, `freq: \u0026str` | `Confidence` | Evaluates how well FLAIR's assumptions fit the input without running a forecast. Returns four fields: `rank1` (seasonal rank-1 strength), `gamma` (seasonal structure above random baseline), `gcv` (Ridge LOO error on the Level series), `impl_ok` (numerical sanity check). Use before forecasting to assess data suitability. |\n|         | `forecast` | `y: \u0026[f64]`, `horizon: usize`, `freq: \u0026str`, `n_samples: usize`, `seed: u64` | `Result\u003cVec\u003cVec\u003cf64\u003e\u003e\u003e` `[n_samples][horizon]` | Generates Monte-Carlo sample paths. Each row is one forecast path. Use when the full uncertainty distribution is needed. |\n|         | `forecast_mean` | `y: \u0026[f64]`, `horizon: usize`, `freq: \u0026str`, `n_samples: usize`, `seed: u64` | `Result\u003cVec\u003cf64\u003e\u003e` `[horizon]` | Returns the mean over all sample paths as a single point forecast. The simplest option for a single-line prediction. |\n|         | `forecast_quantiles` | `y: \u0026[f64]`, `horizon: usize`, `freq: \u0026str`, `n_samples: usize`, `seed: u64`, `quantiles: \u0026[f64]` | `Result\u003cVec\u003cVec\u003cf64\u003e\u003e\u003e` `[quantile][horizon]` | Aggregates sample paths into quantiles. Pass e.g. `\u0026[0.1, 0.5, 0.9]` to get pessimistic / median / optimistic forecast bands. |\n|         | `seed_from_time` *(std only)* | — | `u64` | Returns a non-deterministic seed from the system clock. Pass to any forecast function when reproducibility is not needed. |\n\n## Performance\n\nMeasured on release build (`cargo build --release`), WSL2 / Linux x86-64.\n\n| target | library size (rlib) |\n|--------|---------------------|\n| x86-64 | 612 KB |\n| wasm32 | 371 KB |\n\n### Datasets\n\n80/20 train-test split. MASE \u003c 1.0 means better than naive 1-step forecast.  \nRun: `cargo run --example forecast_validation --release`\n\n| dataset | freq | obs | horizon | rank1 | gamma | MAE | RMSE | MAPE | MASE |\n|---------|------|-----|---------|-------|-------|-----|------|------|------|\n| air_passengers | M | 144 | 12 | — | — | 16.83 | 20.31 | 4.21% | 0.80 |\n| nottem | M | 240 | 12 | — | — | 1.49 | 1.93 | 3.49% | 0.34 |\n| noaa_temp_monthly | M | 1,740 | 12 | — | — | 0.07 | 0.08 | 21.35% | 0.76 |\n| sunspot_year | A | 289 | 10 | — | — | 36.49 | 41.00 | 96.32% | 2.27 |\n| noaa_temp_annual | A | 145 | 10 | — | — | 0.24 | 0.26 | 43.20% | 2.79 |\n| japan_demand_tokyo | H | 70,128 | 24 | 0.996 | 0.996 | 1736.82 | 2083.10 | 4.99% | 1.38 |\n| elec_japan | A | 34 | 5 | n/a | n/a | 238.75 | 283.17 | 3.05% | 1.44 |\n| elec_usa | A | 34 | 5 | n/a | n/a | 331.93 | 374.81 | 2.65% | 1.56 |\n| elec_germany | A | 34 | 5 | n/a | n/a | 437.62 | 501.66 | 6.69% | 4.44 |\n| elec_china | A | 34 | 5 | n/a | n/a | 466.77 | 549.63 | 8.75% | 3.26 |\n\nrank1/gamma: `n/a` = annual series (period=1, no intra-period structure); `—` = not computed for this run.\n\n### Test\n\n```sh\n# unit tests\ncargo test\n\n# integration tests (confidence + forecast + determinism)\ncargo run --example integration_tests --release\n\n# forecast accuracy (80/20 train-test split, all datasets)\ncargo run --example forecast_validation --release\n```\n\n`japan_demand_tokyo.csv` is excluded from the repository (see [Datasets](#datasets)).  \nTests skip it automatically if the file is not present.\n\n### confidence\n\n`confidence(y, freq)` — self-evaluation from only input\n\n| field | description |\n|---|---|\n| `rank1` | `s[0]²/Σs²` of seasonal matrix. 1.0 = pure rank-1 seasonality. `n/a` when period=1 (e.g. annual) or series too short — not an error |\n| `gamma` | seasonal strength above random-matrix baseline, [0, 1]. 1.0 = strong clean seasonality |\n| `gcv` | Ridge LOO error on Level series. lower = Level more predictable. scale depends on Box-Cox transform |\n| `impl_ok` | Box-Cox round-trip and Ridge in-sample sanity check on synthetic data. `false` indicates a build or platform numerical issue |\n\n**japan_demand_tokyo** (hourly, strong seasonality):\n```\n  rank1   : 0.996   ← near-perfect rank-1 fit\n  gamma   : 0.996   ← strong seasonal structure\n  gcv     : 0.0044  ← Level highly predictable\n  impl_ok : true\n```\n\n**elec_per_capita** (annual, no intra-period structure):\n```\n             rank1   gamma   gcv\n  Japan      n/a     n/a     41186\n  USA        n/a     n/a     82624\n  Germany    n/a     n/a     27033\n  China      n/a     n/a      9059\n  impl_ok : true\n```\n\n### determinism\n\nSame seed → bit-identical output. Different seeds → different output.  \nFor non-deterministic output, pass `flair::seed_from_time()` (requires `std` feature, enabled by default).\n\n```\n  [OK] determinism (same seed identical; different seed differs)\n```\n\n## Reference\n\n- https://github.com/TakatoHonda/FLAIR\n- https://zenn.dev/t_honda/articles/flair-time-series-forecasting\n\n### Datasets\n\n| file | variable | freq | range | obs | source |\n|------|----------|------|-------|-----|--------|\n| `air_passengers.csv` | Monthly airline passengers | M | 1949–1960 | 144 | R built-in `AirPassengers`; originally Box \u0026 Jenkins (1976) *Time Series Analysis* |\n| `nottem.csv` | Nottingham Castle mean air temperature (°F) | M | 1920–1939 | 240 | R built-in `nottem` |\n| `sunspot_year.csv` | Yearly sunspot numbers | A | 1700–1988 | 289 | R built-in `sunspot.year`; source: WDC-SILSO, Royal Observatory of Belgium |\n| `noaa_temp_annual.csv` | Global surface temperature anomaly (°C) | A | 1880–2024 | 145 | NOAA Global Surface Temperature (NOAAGlobalTemp) |\n| `noaa_temp_monthly.csv` | Global surface temperature anomaly (°C) | M | 1880–2024 | 1,740 | NOAA Global Surface Temperature (NOAAGlobalTemp) |\n| `japan_demand_tokyo.csv` ⚠️ | Tokyo electricity demand (MW) | H | 2016–2024 | 70,128 | [japanesepower.org](https://japanesepower.org/) — informational use only, not redistributed |\n| `elec_per_capita.csv` | Electric power consumption (kWh per capita) — Japan, USA, Germany, China | A | 1990–2023 | 34 | World Bank WDI — EG.USE.ELEC.KH.PC |\n\n⚠️ `japan_demand_tokyo.csv` is not included in this repository. To use it, download the demand CSV from [japanesepower.org](https://japanesepower.org/), extract the Tokyo column, and place it at `examples/dataset/japan_demand_tokyo.csv`.\n\n## License\n\n```\nApache-2.0\nOriginal: \"FLAIR: Factored Level And Interleaved Ridge - single-equation time series forecasting\"\n  https://github.com/TakatoHonda/FLAIR\n  Copyright (c) Takato Honda\nChanges: Reimplemented in Rust; linear algebra from scratch; adapted for WASM deployment\nAuthor: Andyou \u003candyou@animagram.jp\u003e\n```\n\n## Original Texts (ja)\n\n### 共通引数\n\n- **`y: \u0026[f64]`** — 時系列の観測値のみを等間隔で並べた1次元配列。日時情報は含まない。間隔は `freq` で別途指定する。NaN は 0.0 として扱われる。\n- **`freq: \u0026str`** — 観測間隔を表す文字列。`\"H\"`（時次）・`\"D\"`（日次）・`\"W\"`（週次）・`\"M\"`（月次）・`\"Q\"`（四半期）・`\"A\"` / `\"Y\"`（年次）など。\n\n### 提供ポート\n\n| Mod     | Fn | Input | Output | Description |\n|---------|----|-------|--------|-------------|\n| `flair` | `confidence` | `y: \u0026[f64]`, `freq: \u0026str` | `Confidence` | 予測を実行せずに入力データの適合度を評価する。`rank1`（季節性の強さ）・`gamma`（季節構造の純粋さ）・`gcv`（レベル系列の予測しやすさ）・`impl_ok`（数値実装の健全性）の4フィールドを返す。予測前のデータ確認用。 |\n|         | `forecast` | `y: \u0026[f64]`, `horizon: usize`, `freq: \u0026str`, `n_samples: usize`, `seed: u64` | `Result\u003cVec\u003cVec\u003cf64\u003e\u003e\u003e` `[n_samples][horizon]` | モンテカルロサンプルパスを生成する。各行が1本の予測パス。不確実性の全分布が必要な場合に使う。 |\n|         | `forecast_mean` | `y: \u0026[f64]`, `horizon: usize`, `freq: \u0026str`, `n_samples: usize`, `seed: u64` | `Result\u003cVec\u003cf64\u003e\u003e` `[horizon]` | サンプルパスを平均した点予測を返す。最もシンプルな予測用途向け。 |\n|         | `forecast_quantiles` | `y: \u0026[f64]`, `horizon: usize`, `freq: \u0026str`, `n_samples: usize`, `seed: u64`, `quantiles: \u0026[f64]` | `Result\u003cVec\u003cVec\u003cf64\u003e\u003e\u003e` `[quantile][horizon]` | サンプルパスから指定パーセンタイルを集計する。`\u0026[0.1, 0.5, 0.9]` を渡すと悲観・中央値・楽観の予測帯域を得られる。 |\n|         | `seed_from_time` *（std のみ）* | — | `u64` | システム時刻からシードを生成する。再現性が不要な場合に各予測関数へ渡す。 |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanimagram-jp%2Fflair","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanimagram-jp%2Fflair","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanimagram-jp%2Fflair/lists"}