{"id":22976460,"url":"https://github.com/interviewstreet/spark-stratifier","last_synced_at":"2025-08-01T14:08:33.520Z","repository":{"id":57469607,"uuid":"107725708","full_name":"interviewstreet/spark-stratifier","owner":"interviewstreet","description":"Stratified Cross Validator for Spark","archived":false,"fork":false,"pushed_at":"2019-03-06T00:22:56.000Z","size":8,"stargazers_count":15,"open_issues_count":3,"forks_count":9,"subscribers_count":52,"default_branch":"master","last_synced_at":"2025-07-09T07:50:51.789Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/interviewstreet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-20T20:55:39.000Z","updated_at":"2023-06-21T05:28:37.000Z","dependencies_parsed_at":"2022-09-19T10:12:07.062Z","dependency_job_id":null,"html_url":"https://github.com/interviewstreet/spark-stratifier","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/interviewstreet/spark-stratifier","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interviewstreet%2Fspark-stratifier","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interviewstreet%2Fspark-stratifier/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interviewstreet%2Fspark-stratifier/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interviewstreet%2Fspark-stratifier/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/interviewstreet","download_url":"https://codeload.github.com/interviewstreet/spark-stratifier/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interviewstreet%2Fspark-stratifier/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268240580,"owners_count":24218363,"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-08-01T02:00:08.611Z","response_time":67,"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":"2024-12-15T00:51:17.423Z","updated_at":"2025-08-01T14:08:33.460Z","avatar_url":"https://github.com/interviewstreet.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# spark-stratifier\n[![PyPI version](https://img.shields.io/pypi/v/spark-stratifier.svg)](https://img.shields.io/pypi/v/spark-stratifier)\n[![Start with Why](https://img.shields.io/badge/start%20with-why%3F-brightgreen.svg?style=flat)](http://www.ted.com/talks/simon_sinek_how_great_leaders_inspire_action)\n\nWhen we first started working Spark at HackerRank, we realized that within our dataset, the size of our outcome sets varied in size by quite a bit. This led to inconsistent model cross validation and training. However, with [**stratified sampling**](https://en.wikipedia.org/wiki/Stratified_sampling), we were able to eliminate these inconsistencies and improve overall model predictions. The goal of `spark-stratifier` is to provide a tool to stratify datasets for cross validation in `PySpark`. This class extends the current `CrossValidator` class in Spark.\n\nCurrently, the stratified cross validator works with binary classification problems using labels `0` and `1`.\n\nRead more at [engineering.hackerrank.com](https://engineering.hackerrank.com/)\n\nRequirements\n------------\nThis tool is 100% Python and the only primary requirements are [`numpy`](https://github.com/numpy/numpy) and [`pyspark`](https://github.com/apache/spark/tree/master/python/pyspark).\n\nInstallation\n------------\n```\n$ pip install spark-stratifier\n```\n\nExample\n-------\nYou basically use this the exact same way you would with the Spark `CrossValidator`... except this time, your data will be stratified.\n\n```py\nfrom spark_stratifier import StratifiedCrossValidator\n\nscv = StratifiedCrossValidator(\n        estimator=pipeline,\n        estimatorParamMaps=paramGrid,\n        evaluator=evaluator,\n        numFolds=8\n      )\n\nmodel = scv.fit(matrix)\n```\n\nContributing\n------------\n[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg)](https://github.com/interviewstreet/spark-stratifier/issues)\n\nIf you want to write some code and contribute to this project, go ahead and start a pull request. We hope this tool is useful for the community and we'd love to hear about how this helps solve your problems!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finterviewstreet%2Fspark-stratifier","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finterviewstreet%2Fspark-stratifier","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finterviewstreet%2Fspark-stratifier/lists"}