{"id":51546586,"url":"https://github.com/kVeyra/sklearn-java","last_synced_at":"2026-07-12T19:00:29.795Z","repository":{"id":368783902,"uuid":"1284795735","full_name":"kVeyra/sklearn-java","owner":"kVeyra","description":"Java reimplementation of Python's scikit-learn with behavioral compatibility, numerical accuracy, and idiomatic Java design","archived":false,"fork":false,"pushed_at":"2026-07-02T08:08:24.000Z","size":447,"stargazers_count":0,"open_issues_count":11,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-07-02T08:15:35.991Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/kVeyra/sklearn-java","language":"Java","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/kVeyra.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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},"funding":{"github":"kundanjan"}},"created_at":"2026-06-30T07:49:50.000Z","updated_at":"2026-07-02T08:07:55.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/kVeyra/sklearn-java","commit_stats":null,"previous_names":["kveyra/sklearn-java"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/kVeyra/sklearn-java","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kVeyra%2Fsklearn-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kVeyra%2Fsklearn-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kVeyra%2Fsklearn-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kVeyra%2Fsklearn-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kVeyra","download_url":"https://codeload.github.com/kVeyra/sklearn-java/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kVeyra%2Fsklearn-java/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35400291,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-12T02:00:06.386Z","response_time":87,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2026-07-09T19:00:23.369Z","updated_at":"2026-07-12T19:00:29.770Z","avatar_url":"https://github.com/kVeyra.png","language":"Java","funding_links":["https://github.com/sponsors/kundanjan"],"categories":["Projects"],"sub_categories":["Machine Learning"],"readme":"# sklearn-java\n\n[![Build](https://github.com/kVeyra/sklearn-java/actions/workflows/ci.yml/badge.svg)](https://github.com/kVeyra/sklearn-java/actions/workflows/ci.yml)\n[![Coverage](https://codecov.io/gh/kVeyra/sklearn-java/branch/develop/graph/badge.svg)](https://codecov.io/gh/kVeyra/sklearn-java)\n[![Javadoc](https://img.shields.io/badge/docs-GitHub%20Pages-blue)](https://kVeyra.github.io/sklearn-java)\n[![Java](https://img.shields.io/badge/Java-21-blue)](https://openjdk.org/projects/jdk/21/)\n[![License](https://img.shields.io/badge/License-Apache%202.0-green)](LICENSE)\n[![GitHub Discussions](https://img.shields.io/badge/Ask%20us-anything-blue.svg)](https://github.com/kVeyra/sklearn-java/discussions)\n[![GitHub stars](https://img.shields.io/github/stars/kVeyra/sklearn-java?style=social)](https://github.com/kVeyra/sklearn-java)\n\n**A production-quality Java reimplementation of Python's scikit-learn.** Covers the core ML API surface (in progress) with behavioral compatibility, numerical accuracy to 1e-8, and pure Java — no Python, JNI, or NumPy.\n\n## Why sklearn-java?\n\n- **Drop-in replacement mindset** — API mirrors sklearn exactly: `.fit()`, `.predict()`, `.transform()`, `.score()`\n- **Numerical accuracy** — every algorithm validated against Python sklearn with 1e-8 tolerance\n- **Pure Java** — zero Python dependencies, zero JNI, zero external native libs\n- **Modern Java** — Java 21, sealed interfaces, records, pattern matching\n- **100% coverage goal** — targeting 400+ public classes matching sklearn's API surface\n\n## Modules\n\n| Module | Status | Coverage |\n|--------|--------|----------|\n| `math` | ✅ Complete | Vectors, dense matrices, random generators |\n| `core` | ✅ Complete | Estimator/Predictor/Transformer interfaces, Pipeline |\n| `preprocessing` | ✅ Complete | StandardScaler, MinMaxScaler, Normalizer, RobustScaler, MaxAbsScaler, OneHotEncoder, LabelEncoder, OrdinalEncoder, PolynomialFeatures, Binarizer, KBinsDiscretizer, FunctionTransformer |\n| `linear_model` | ✅ Complete | LinearRegression, Ridge, Lasso, ElasticNet, LogisticRegression, SGDClassifier, SGDRegressor, RidgeCV, BayesianRidge, HuberRegressor, Perceptron, PassiveAggressiveClassifier/Regressor, LassoCV, ElasticNetCV, RidgeClassifier, RidgeClassifierCV |\n| `tree` | ✅ Complete | DecisionTreeClassifier/Regressor, ExtraTreeClassifier/Regressor (random thresholds) |\n| `ensemble` | ✅ Complete | RandomForest, AdaBoost, GradientBoosting, Bagging, Voting, Stacking, IsolationForest, ExtraTrees, ExtraTreesEmbedding, HistGradientBoosting |\n| `svm` | ✅ Complete | SVC (one-vs-one), SVR, LinearSVC, linear/poly/RBF/sigmoid kernels |\n| `naive_bayes` | ✅ Complete | GaussianNB, MultinomialNB, BernoulliNB |\n| `neighbors` | ✅ Complete | KNeighborsClassifier, KNeighborsRegressor, NearestNeighbors, RadiusNeighborsClassifier/Regressor, LocalOutlierFactor, KernelDensity |\n| `cluster` | ✅ Complete | KMeans (Lloyd's + k-means++), DBSCAN |\n| `feature_selection` | ✅ Complete | VarianceThreshold, SelectKBest, SelectPercentile, GenericUnivariateSelect, RFE, SelectFromModel, FScoring (f_classif, f_regression, r_regression) |\n| `neural_network` | ✅ Complete | MLPClassifier, MLPRegressor (ReLU/tanh/logistic, SGD/Adam, backprop) |\n| `dummy` | ✅ Complete | DummyClassifier, DummyRegressor |\n| `impute` | ✅ Complete | SimpleImputer (mean/median/most_frequent/constant) |\n| `decomposition` | ✅ Complete | PCA |\n| `metrics` | ✅ Complete | ClassificationMetrics, RegressionMetrics, RankingMetrics, PairwiseMetrics, ClusteringMetrics |\n| `model_selection` | ✅ Complete | KFold, StratifiedKFold, LeaveOneOut, RepeatedKFold, CrossValidation, GridSearchCV, TrainTestSplit |\n| `pipeline` | ✅ Complete | Pipeline, FeatureUnion, make_pipeline |\n| `utils` | ✅ Complete | Validation, matrix/vector utilities |\n| `datasets` | ❌ Not started | Toy datasets will be added in Phase C |\n\n## Quick Start\n\n```java\n// Standardize features\nStandardScaler scaler = new StandardScaler();\nMatrix X_scaled = scaler.fitTransform(X_train);\n\n// Train a classifier\nRandomForestClassifier rf = new RandomForestClassifier(100, 5);\nrf.fit(X_scaled, y_train);\n\n// Predict \u0026 evaluate\nVector preds = rf.predict(scaler.transform(X_test));\ndouble acc = ClassificationMetrics.accuracy(y_test, preds);\n```\n\n```java\n// Grid search with cross-validation\nGridSearchCV grid = new GridSearchCV(\n    new SVC(),\n    Map.of(\"C\", new double[]{0.1, 1.0, 10.0}, \"kernel\", new String[]{\"rbf\", \"linear\"}),\n    5\n);\ngrid.fit(X_train, y_train);\nSystem.out.println(\"Best params: \" + grid.bestParams());\n```\n\n```java\n// Neural network classifier\nMLPClassifier mlp = new MLPClassifier(new int[]{64, 32}, \"relu\", \"adam\", 200);\nmlp.fit(X_train, y_train);\nVector preds = mlp.predict(X_test);\ndouble acc = ClassificationMetrics.accuracy(y_test, preds);\n```\n\n## Building\n\n```bash\nexport JAVA_HOME=/opt/homebrew/opt/openjdk@21\n./gradlew build\n```\n\n## Testing\n\n```bash\n./gradlew test\n./gradlew jacocoTestReport  # coverage report at build/reports/\n```\n\n## Contributing\n\nWe welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for:\n\n- Branch strategy (feature branches → develop → main)\n- Coding standards (Java 21, Google Java Format)\n- Validation requirements (1e-8 tolerance against sklearn)\n- PR checklist\n\n**Looking for good first issues?** Check the [issue tracker](https://github.com/kVeyra/sklearn-java/issues) and the [COVERAGE_PLAN.md](COVERAGE_PLAN.md) for remaining algorithms.\n\n## Roadmap\n\n| Phase | Focus | Status |\n|-------|-------|--------|\n| Phase A1 | Metrics + Model Selection | ✅ Complete |\n| Phase A2 | Ensemble Methods | ✅ Complete |\n| Phase A3 | Linear Models (SGD, RidgeCV, Bayesian, Huber, Perceptron, PA, CV variants) | ✅ Complete |\n| Phase A4 | Naive Bayes + Neighbors (full: Multinomial/Bernoulli, NearestNeighbors, RadiusNeighbors, LOF, KernelDensity) | ✅ Complete |\n| Phase A5 | Neural Network (MLP) + Feature Selection (SelectKBest, RFE, SelectFromModel) | 🔜 Written, testing pending |\n| Phase B | Manifold, Impute, Pipeline (full) | 📋 Planned |\n| Phase C | Decomposition, Covariance, Cross-decomposition | 📋 Planned |\n| Phase D | Semi-supervised, Multi-output, Niche estimators | 📋 Planned |\n\nSee [COVERAGE_PLAN.md](COVERAGE_PLAN.md) for full 400+ item breakdown.\n\n## License\n\nApache 2.0 — see [LICENSE](LICENSE).\n\n## Stats\n\n![Alt](https://repobeats.axiom.co/api/placeholder.svg \"Repo stats\")\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FkVeyra%2Fsklearn-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FkVeyra%2Fsklearn-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FkVeyra%2Fsklearn-java/lists"}