{"id":15040618,"url":"https://github.com/khaledsharif/sklearn2docker","last_synced_at":"2025-09-04T01:40:42.418Z","repository":{"id":57468091,"uuid":"120635118","full_name":"KhaledSharif/sklearn2docker","owner":"KhaledSharif","description":"Convert your trained scikit-learn classifier to a Docker container with a pre-configured API","archived":false,"fork":false,"pushed_at":"2018-03-05T10:43:02.000Z","size":30,"stargazers_count":5,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-14T18:50:15.925Z","etag":null,"topics":["api","classification","docker","docker-container","machine-learning","scikit-learn"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KhaledSharif.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}},"created_at":"2018-02-07T15:45:02.000Z","updated_at":"2022-11-17T05:10:45.000Z","dependencies_parsed_at":"2022-09-19T08:20:45.828Z","dependency_job_id":null,"html_url":"https://github.com/KhaledSharif/sklearn2docker","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/KhaledSharif/sklearn2docker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KhaledSharif%2Fsklearn2docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KhaledSharif%2Fsklearn2docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KhaledSharif%2Fsklearn2docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KhaledSharif%2Fsklearn2docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KhaledSharif","download_url":"https://codeload.github.com/KhaledSharif/sklearn2docker/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KhaledSharif%2Fsklearn2docker/sbom","scorecard":{"id":78304,"data":{"date":"2025-08-11","repo":{"name":"github.com/KhaledSharif/sklearn2docker","commit":"39d6cc7d9632be4c62f41954d2a4ee8ce347b57b"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":0,"reason":"Found 0/12 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: GNU Lesser General Public License v3.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-15T05:17:14.879Z","repository_id":57468091,"created_at":"2025-08-15T05:17:14.879Z","updated_at":"2025-08-15T05:17:14.879Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273539293,"owners_count":25123499,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-03T02:00:09.631Z","response_time":76,"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":["api","classification","docker","docker-container","machine-learning","scikit-learn"],"created_at":"2024-09-24T20:44:49.784Z","updated_at":"2025-09-04T01:40:42.389Z","avatar_url":"https://github.com/KhaledSharif.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sklearn2docker\n#### Convert your trained scikit-learn classifier to a Docker container with a pre-configured API\n\n[![License: LGPL v3](https://img.shields.io/badge/License-LGPL%20v3-blue.svg)](http://www.gnu.org/licenses/lgpl-3.0)\n\n## Installation\n\nThe easiest way to install `sklearn2docker` with all its dependencies is through `pip`:\n\n```bash\npip install git+git://github.com/KhaledSharif/sklearn2docker.git\n```\n\n## Getting started\n\nFirst, create your `sklearn` classifier. In this example we will use the [Iris dataset](http://scikit-learn.org/stable/auto_examples/datasets/plot_iris_dataset.html).\n\n```python\nfrom pandas import DataFrame\nfrom sklearn.datasets import load_iris\nfrom sklearn.tree import DecisionTreeClassifier\n\niris = load_iris()\ninput_df = DataFrame(data=iris['data'], columns=iris['feature_names'])\nclf = DecisionTreeClassifier(max_depth=2)\nclf.fit(input_df.values, iris['target'])\n```\n\nSecond, import the `Sklearn2Docker` class and use it to build your container.\n\n```python\nfrom sklearn2docker.constructor import Sklearn2Docker\n\ns2d = Sklearn2Docker(\n    classifier=clf,\n    feature_names=iris['feature_names'],\n    class_names=iris['target_names'].tolist()\n)\ns2d.save(name=\"classifier\", tag=\"iris\")\n```\n\nThe name and tag arguments we passed to the `save` function are the name and tag of the Docker container we just built ([see: `docker tag`](https://docs.docker.com/engine/reference/commandline/tag/)). Below is an example of the output of the `s2d.save()` line we executed above.\n\n```\nNow attempting to run the command: \n[docker build --file /tmp/tmpywbu3_ad/Dockerfile \n --tag classifier:iris /tmp/tmpywbu3_ad]\n=====================================================================\n\u003e Sending build context to Docker daemon\n\u003e Step 1/6 : FROM python:3.6\n\u003e ---\u003e c1e459c00dc3\n... output truncated ...\n\u003e Step 6/6 : ENTRYPOINT python /code/api.py\n\u003e ---\u003e Running in bd61983358d9\n\u003e Removing intermediate container bd61983358d9\n\u003e ---\u003e fa2041ac6d60\n\u003e Successfully built fa2041ac6d60\n\u003e Successfully tagged classifier:iris\n=====================================================================\nSuccess! You can now run your Docker container using the following command:\n\t docker run -d -p 5000:5000 classifier:iris\n```\n\nYou can now test your container by asking it to predict the same Iris dataset and return the predicted probabilities ([see: `predict_proba`](http://scikit-learn.org/stable/modules/generated/sklearn.tree.DecisionTreeClassifier.html#sklearn.tree.DecisionTreeClassifier.predict_proba)) as a DataFrame.\n\n```python\nfrom os import system\nsystem(\"docker run -d -p 5000:5000 classifier:iris \u0026\u0026 sleep 5\")\n\nfrom requests import post\nfrom pandas import read_json\nrequest = post(\"http://localhost:5000/predict_proba/split\", json=input_df.to_json(orient=\"split\"))\nresult = read_json(request.content.decode(), orient=\"split\")\nprint(result.head())\n```\n\n```\n   setosa  versicolor  virginica\n0       1         0.0        0.0\n1       1         0.0        0.0\n2       1         0.0        0.0\n3       1         0.0        0.0\n4       1         0.0        0.0\n```\n\nYou can also request regular classification ([see: `predict`](http://scikit-learn.org/stable/modules/generated/sklearn.tree.DecisionTreeClassifier.html#sklearn.tree.DecisionTreeClassifier.predict)). The format for the URL for your Docker container is as so:\n\n```\nhttp://[a]:[b]/[c]/[d]\n\na: the hostname of the container, defaults to `localhost`\nb: the port of the container, defaults to 5000\nc: one of `predict` or `predict_proba`, similar to the scikit-learn api\nd: defaults to `split`; orient of the Pandas DataFrame JSON conversion*\n```\n\n(*: see [this documentation article](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.to_json.html) for more information about Pandas orients, and [this Github issue](https://github.com/pandas-dev/pandas/issues/18912#issuecomment-354430046) for a comparison; most of the time, setting the orient to `split` should do just fine)\n\n```python\nrequest = post(\n    \"http://localhost:5000/predict/split\", \n    json=input_df.to_json(orient=\"split\")\n)\n```\n\n```\n  prediction\n0     setosa\n1     setosa\n2     setosa\n3     setosa\n4     setosa\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkhaledsharif%2Fsklearn2docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkhaledsharif%2Fsklearn2docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkhaledsharif%2Fsklearn2docker/lists"}