Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SDSTK — Swift Data Science Toolkit

An open-source, MLX-native Swift reimplementation of the Python data-science stack.

Python's data-science ecosystem (NumPy, pandas, SciPy, scikit-learn, …) is the default toolkit for the world's data work, but it pays a tax: interpreted glue, the CPython GIL, and a hard boundary between "fast C/Fortran core" and "slow Python." On Apple Silicon, MLX removes that tax — a unified-memory, lazily-evaluated, GPU-accelerated array framework with autodiff built in. SDSTK is the ecosystem on top of MLX that nobody has ported yet: one clean Swift codebase, no Python.

Why this can be fast

The Python stack sits on NumPy. Its Swift/MLX equivalent — MLXArray — already exists. So SDSTK does not start at zero; it starts one layer up and builds the ecosystem above it, wrapping Apple's native accelerated primitives (Accelerate/vDSP/LAPACK, Vision, NaturalLanguage) where they already beat a from-scratch rewrite.

Modules

Each module is its own independently-releasable Swift package (its own folder + Package.swift).

Folder Replaces Status
Frame pandas columns, group-by (parallelized), joins (inner/left/right/outer), windows, nulls, CSV + binary + Arrow/Parquet IO
Sci SciPy LinAlg + Stats
Learn scikit-learn linear/logistic regression, trees, ensembles, KMeans, PCA, Pipeline, GridSearch
Neural PyTorch (training loop) MLP + compiled train() on top of MLXNN (Conv/RNN/LSTM/Transformer/Quantized all reachable via re-export)
Plot matplotlib / seaborn headless SVG: line/scatter/bar/histogram
Signal SciPy.signal FFT/STFT, windowing, FIR filter design, convolution, peak detection, Welch PSD
Text spaCy/NLTK-lite tokenizer, vocabulary, CountVectorizer, TF-IDF, cosine similarity, Levenshtein distance
Optimize SciPy.optimize gradient descent, L-BFGS-B, Nelder-Mead, Brent, Levenberg-Marquardt
TimeSeries statsmodels.tsa rolling stats, ACF/PACF, seasonal decomposition, AR/MA/ARIMA, ETS
Formulas — (equation reference) physics/chemistry/biology/geo/astro closed-form equations — mechanics, thermo, EM, waves/optics, kinetics, population dynamics, haversine, orbital mechanics
Graph NetworkX Dijkstra, A*, BFS/DFS, connected components, topological sort, Kruskal's MST
DataScience — (umbrella) re-exports everything + the DataFrame bridge
(NumPy) numpy provided by MLXArray upstream

import DataScience gives the whole stack in one line, and lets you run stats, fit models, and plot straight from a DataFrame. Plus Benchmarks/Frame-vs-pandas, Learn-vs-sklearn, and Neural-vs-MLX-Python comparisons.

277 tests, all green across the 12 packages. Frame's suite defaults to its portable CPU backend and also passes on the MLX/GPU backend (FRAME_BACKEND=mlx, after Tools/fetch-metallib.sh); Sci/Learn/Signal/Text/Optimize/TimeSeries/Formulas/ Graph use Accelerate/pure-Swift and need no GPU; Neural needs a compiled mlx.metallib regardless of backend (see Neural/scripts/build-metallib.sh).

Build order rationale

Frame (pandas) came first: the most-used library in the stack and the first real gap above NumPy. Then Sci + Learn — because pandas + scikit-learn is what "data science in Python" means, and that trio is a complete, credible v1.0 story on its own. Neural followed once the array/DataFrame layer was solid, adding MLX-native training. The remaining modules (Plot, Signal, Text, Optimize, TimeSeries, Formulas, Graph) came demand-driven.

Building

Requires Swift 6+ and Apple Silicon (macOS 14+). Each module builds independently:

cd Frame
swift build
swift test

License

MIT — see LICENSE.

About

Swift Implementation of Pandas and SciKitLearn ++

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages