Metadata-Version: 2.4
Name: skjson
Version: 0.1.1
Summary: Export scikit-learn models to JSON for cross-language inference
License-Expression: MIT
Requires-Python: >=3.9
Requires-Dist: numpy>=1.21
Requires-Dist: scikit-learn>=1.0
Provides-Extra: dev
Requires-Dist: pytest-cov; extra == 'dev'
Requires-Dist: pytest>=7.0; extra == 'dev'
Description-Content-Type: text/markdown

# skjson

Export scikit-learn models to JSON for cross-language inference.

## Installation

```bash
pip install skjson
```

## Quick Start

Check out the [demo notebook](demo.ipynb) for an example training a Random Forest on the Iris dataset:

```python
from sklearn.datasets import load_iris
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
import skjson

# Load the Iris dataset and split
X, y = load_iris(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Train a Random Forest classifier
clf = RandomForestClassifier(random_state=42)
clf.fit(X_train, y_train)

# Export the trained model to JSON
skjson.save(clf, 'demo.json')

# Load and reuse the model
predictor = skjson.load("demo.json")
```

## Support models for conversion

**Linear Models (`sklearn.linear_model`)**
- `LinearRegression`, `Ridge`, `Lasso`, `ElasticNet`
- `LogisticRegression`

**Tree-based Models (`sklearn.tree`, `sklearn.ensemble`)**
- `DecisionTreeClassifier`, `DecisionTreeRegressor`
- `RandomForestClassifier`, `RandomForestRegressor`
- `GradientBoostingClassifier`, `GradientBoostingRegressor`

**Support Vector Machines (`sklearn.svm`)**
- `SVC`, `SVR`, `LinearSVC`

**Neighbors (`sklearn.neighbors`)**
- `KNeighborsClassifier`, `KNeighborsRegressor`

**Naive Bayes (`sklearn.naive_bayes`)**
- `GaussianNB`

**Preprocessing (`sklearn.preprocessing`)**
- `StandardScaler`, `MinMaxScaler`, `LabelEncoder`

## Future Directions

- Support for scikit-learn `Pipeline` objects and feature unions.
- npm package for inference using our json models
- Support for sklearn.neural_network models

## Note
- This project built with Google Gemini and Claude Opus.
- If you wish to contribute, please contact me. 