Skip to content

v1.2.0 — SwiftSci Package Rename, Joseph Form Kalman Filter & UTF-8 BPE Tokenizer

Choose a tag to compare

@Nodibell Nodibell released this 22 Jul 13:18

SwiftSci v1.2.0

📦 What's Changed

🏷️ Package Rename & Branding

  • SwiftSci Rename: Main Swift Package renamed from SwiftAnalytics to SwiftSci (name: "SwiftSci") for cleaner ecosystem branding while preserving target module names (SwiftDataFrame, SwiftStats, SwiftML, SwiftForecast, etc.).

📐 Numerical Stabilization & Core Upgrades

  • Joseph Form Kalman Filter (SwiftForecast): Updated covariance matrix updates in filter() and smooth() to the numerically stable Joseph form P = (I - KH) P_pred (I - KH)^T + K R K^T, preserving symmetry and positive-definiteness under long filtering runs.
  • UTF-8 Byte BPE Tokenizer (SwiftNLP): Refactored BPETokenizer bpe() algorithm to operate directly on word.utf8 bytes with GPT-2 byte-to-unicode character encoding (makeByteEncoder), fixing incorrect tokenization for non-ASCII input.

📊 DataFrame Enhancements (SwiftDataFrame)

  • DataFrame.addColumn(_:as:using:): Added row-closure builder for computing new columns per-row over DataFrameRow, delegating to withColumn.
  • DataFrameError.partialCastFailure: Added explicit error case thrown when partial element casting fails in castColumn (failed out of total), preventing silent data loss.
  • DataFrame Invariant Diagnostics: Refactored DataFrame.gathered(at:) to trap with preconditionFailure on internal length invariant violations instead of returning an empty DataFrame. Removed duplicate private rows(at:).
  • DataFrame.sample Randomization: Updated sample(n:seed:ordered:) to return randomly shuffled rows by default (ordered: false) while allowing index order preservation via ordered: true.

📊 Benchmark Performance Summary (SwiftSci vs Python)

Benchmark Test Swift (ms) Python (ms) Speedup Winner
Mean (vDSP, 1M elements) 0.082 ms 0.121 ms 1.47x 🟢 Swift
Pearson Correlation (500k elements) 0.868 ms 1.256 ms 1.45x 🟢 Swift
ARIMA(1,1,1) Fit (50k pts) 2.323 ms 215.527 ms 92.78x 🟢 Swift
ARIMA Forecast Horizon=24 2.456 ms 211.880 ms 86.26x 🟢 Swift
Holt-Winters Fit (50k pts, period=12) 6.841 ms 148.627 ms 21.73x 🟢 Swift
Random Forest Fit (1k×4, 50 trees) 5.025 ms 25.475 ms 5.07x 🟢 Swift
KernelSHAP Explain (5 feats, 100 coalitions) 0.192 ms 0.426 ms 2.22x 🟢 Swift
Kalman Filter 1D (10k obs, Joseph Form) 62.349 ms 85.547 ms 1.37x 🟢 Swift
LLM Forward Pass (seqLen=64) 0.636 ms 0.528 ms 0.83x 🔴 PyTorch
CSV Read (100k rows, 5 cols) 177.509 ms 19.340 ms 0.11x 🔴 Pandas
CSV Stream Read (chunk=10k) 238.699 ms 22.525 ms 0.09x 🔴 Pandas
  • CI Gate Status: PASSED ✅ (0 gated regressions detected).

Full Changelog: v1.1.0...v1.2.0