{"id":21911698,"url":"https://github.com/stepicorg/submissions-clustering","last_synced_at":"2026-05-19T03:11:42.452Z","repository":{"id":142906048,"uuid":"96335182","full_name":"StepicOrg/submissions-clustering","owner":"StepicOrg","description":null,"archived":false,"fork":false,"pushed_at":"2018-11-13T15:31:26.000Z","size":7311,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-22T08:30:05.454Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/StepicOrg.png","metadata":{"files":{"readme":"README.rst","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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-07-05T15:38:36.000Z","updated_at":"2019-06-11T11:53:35.000Z","dependencies_parsed_at":"2023-04-12T07:17:11.022Z","dependency_job_id":null,"html_url":"https://github.com/StepicOrg/submissions-clustering","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/StepicOrg/submissions-clustering","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StepicOrg%2Fsubmissions-clustering","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StepicOrg%2Fsubmissions-clustering/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StepicOrg%2Fsubmissions-clustering/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StepicOrg%2Fsubmissions-clustering/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StepicOrg","download_url":"https://codeload.github.com/StepicOrg/submissions-clustering/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StepicOrg%2Fsubmissions-clustering/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266058481,"owners_count":23870157,"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","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-11-28T18:07:20.003Z","updated_at":"2026-05-19T03:11:42.425Z","avatar_url":"https://github.com/StepicOrg.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"======================\nsubmissions-clustering\n======================\n\nFine tool to split code submissions into clusters.\n\n------------\nInstallation\n------------\n\nDependencies\n============\n\n1. **make**\n2. **python** of version *3.4* or more.\n3. **pip**\n\nPip\n===\n\n``pip install git+https://github.com/StepicOrg/submissions-clustering.git``\n\nLocally\n=======\n\n1. ``git clone https://github.com/StepicOrg/submissions-clustering``\n2. ``make reqs``\n3. ``make build``\n\nYou can run ``make help`` for list of avialible deps. Some of them provided just for convinience. For example, you can\nrun ``make run`` to execute **main.py** script or run ``make check`` to run python static code checkers.\n\n-----\nUsage\n-----\n\nSetting Up\n==========\n\nAt first, we need to set things up. Customize your logger behavior:\n\n\u003e\u003e\u003e import logging\n\u003e\u003e\u003e logging.basicConfig(\n...     level=logging.INFO,\n...     format=\"%(asctime)s - %(name)s - %(levelname)s - %(message)s\"\n... )\n\nTraining\n========\n\nSimple example of usage. Firstly, we read our submissions as iterable *(code : str, status : str)* for some source. Then\nwe create a model from specification (langauge and approach). Then, we feed submission into model (the training goes\nhere). Lastly, we predict ids of first 5 neighbors for first code sample:\n\n\u003e\u003e\u003e import subsclu as sc\n\u003e\u003e\u003e from subsclu.utils import read as read_utils\n\u003e\u003e\u003e submissions = list(read_utils.from_sl3(\"data/subs.sl3\", nrows=3000))\n\u003e\u003e\u003e model = sc.SubmissionsClustering.outof(\"python\", \"ast\")\n\u003e\u003e\u003e model.fit(submissions)\n\u003e\u003e\u003e model.neighbors([submissions[0][0]])[0][:5]\narray([   0, 2308, 1686,  460,  643])\n\nSaving \u0026 Restoring\n==================\n\nModel class provide save and static load methods for faster and efficient model saving and loading:\n\n\u003e\u003e\u003e model.save(\"data/model.dump\")\n\u003e\u003e\u003e del model\n\u003e\u003e\u003e model = sc.SubmissionsClustering.load(\"data/model.dump\")\n\nDefault serializing machinery provided by joblib package from sklearn (for faster work with numpy matricies). Since\nmodel is pickable object, you can use methods from pickle package (and also use with `django-picklefield`_):\n\n.. _`django-picklefield`: https://pypi.python.org/pypi/django-picklefield\n\n\u003e\u003e\u003e from subsclu.utils import dump as dump_utils\n\u003e\u003e\u003e dump_utils.pickle_save(model, \"data/model.dump\")\n\u003e\u003e\u003e del model\n\u003e\u003e\u003e model = dump_utils.pickle_load(\"data/model.dump\")\n\nEvaluating\n==========\n\nOf course, we need to somehow evaluate performance of our model. For this purpose we gonna use scorers. Here we create\non of them from specification (language and testing approach). Scorer instance has *score(model, submissions, **kwargs)*\nmethod to calculate of how good model (unfitted) perform on given submissions:\n\n\u003e\u003e\u003e from subsclu.scorers import Scorer\n\u003e\u003e\u003e scorer = Scorer.outof(\"python\", \"diff\")\n\u003e\u003e\u003e hasattr(scorer, \"score\")\nTrue\n\nScorer uses metric isntance inside, that measure of how close one code to another. The overall score is computed as mean\nof diff between best metric and local best metric (within neighbors). Metric evaluate how close is one code to another.\nWe can speed-up the calculating using predefined array of best scores:\n\n\u003e\u003e\u003e scorer.score(model, submissions, presaved_score_path=\"data/best_metrics.dump\")\n0.013940358468805102\n\nSpec and creating custom\n========================\n\nTo see list of languages run:\n\n\u003e\u003e\u003e from subsclu.languages.spec import VALID_NAMES\n\u003e\u003e\u003e VALID_NAMES\n('python',)\n\nSame goes for approaches and other stuff:\n\n\u003e\u003e\u003e from subsclu.spec import VALID_APPROACHES\n\u003e\u003e\u003e VALID_APPROACHES\n('diff', 'token', 'ast', 'test')\n\nIf you dont satisfied with predefined in spec set of things, you can define you own. See **subsclu** package subpackages\nfor more info on that.\n\n----\nTest\n----\n\nRun ``make test`` to start full build-test cycle in separate py34 venv using **tox**.\n\n---\nDoc\n---\n\nRun ``make doc`` to get pdf file of full package documentation.\n\n------------\nUseful Links\n------------\n\nNode embedding tensorboard\n==========================\n\n`Here \u003chttps://goo.gl/vUDr5U\u003e`_ you can find embedding for AST nodes visualization in tensorboard.\n\nArticles\n========\n\nThe entire project idea is based on `this article \u003chttp://dl.acm.org/citation.cfm?id=3053985\u003e`_.\n\nI am also use `this \u003chttps://arxiv.org/pdf/1409.3358.pdf\u003e`_,\n`this \u003chttp://www.cs.cornell.edu/~kilian/papers/wmd_metric.pdf\u003e`_, and\n`that \u003chttps://pdfs.semanticscholar.org/5260/66e8c1007dd526eb4a7b89a925b95c6564f5.pdf\u003e`_.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstepicorg%2Fsubmissions-clustering","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstepicorg%2Fsubmissions-clustering","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstepicorg%2Fsubmissions-clustering/lists"}