{"id":37071840,"url":"https://github.com/runopti/stg","last_synced_at":"2026-01-14T08:26:12.735Z","repository":{"id":50490117,"uuid":"278746516","full_name":"runopti/stg","owner":"runopti","description":"Python/R library for feature selection in neural nets. (\"Feature selection using Stochastic Gates\", ICML 2020) ","archived":false,"fork":false,"pushed_at":"2022-02-18T16:44:06.000Z","size":3889,"stargazers_count":108,"open_issues_count":8,"forks_count":24,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-09-22T04:38:48.508Z","etag":null,"topics":["classification","cox-model","feature-selection","neural-networks","regression"],"latest_commit_sha":null,"homepage":"https://runopti.github.io/stg/","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/runopti.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":"2020-07-10T22:40:55.000Z","updated_at":"2025-07-17T22:53:05.000Z","dependencies_parsed_at":"2022-09-26T18:00:58.753Z","dependency_job_id":null,"html_url":"https://github.com/runopti/stg","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/runopti/stg","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/runopti%2Fstg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/runopti%2Fstg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/runopti%2Fstg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/runopti%2Fstg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/runopti","download_url":"https://codeload.github.com/runopti/stg/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/runopti%2Fstg/sbom","scorecard":{"id":789906,"data":{"date":"2025-08-11","repo":{"name":"github.com/runopti/stg","commit":"8b60e349a70d2f392b13d2505c316cdd8868a067"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"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/30 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":"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":"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":"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":"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":"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":"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: MIT License: 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"}},{"name":"Vulnerabilities","score":0,"reason":"22 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: PYSEC-2018-34 / GHSA-2fc2-6r4j-p65h","Warn: Project is vulnerable to: PYSEC-2021-856 / GHSA-5545-2q6w-2gh6","Warn: Project is vulnerable to: PYSEC-2019-108 / GHSA-9fq2-x9r6-wfmf","Warn: Project is vulnerable to: PYSEC-2018-33 / GHSA-cw6w-4rcx-xphc","Warn: Project is vulnerable to: PYSEC-2021-857 / GHSA-f7c7-j99h-c22f","Warn: Project is vulnerable to: GHSA-fpfv-jqm9-f5jm","Warn: Project is vulnerable to: PYSEC-2017-1 / GHSA-frgw-fgh6-9g52","Warn: Project is vulnerable to: PYSEC-2020-73","Warn: Project is vulnerable to: PYSEC-2020-107 / GHSA-jjw5-xxj6-pcv5","Warn: Project is vulnerable to: PYSEC-2024-110 / GHSA-jw8x-6495-233v","Warn: Project is vulnerable to: PYSEC-2020-108","Warn: Project is vulnerable to: PYSEC-2019-156 / GHSA-xp76-357g-9wqq","Warn: Project is vulnerable to: PYSEC-2023-102","Warn: Project is vulnerable to: PYSEC-2023-114","Warn: Project is vulnerable to: GHSA-3749-ghw9-m3mg","Warn: Project is vulnerable to: PYSEC-2022-43015 / GHSA-47fc-vmwq-366v","Warn: Project is vulnerable to: PYSEC-2025-41 / GHSA-53q9-r3pm-6pq6","Warn: Project is vulnerable to: PYSEC-2024-252 / GHSA-5pcm-hx3q-hm94","Warn: Project is vulnerable to: GHSA-887c-mr87-cxwp","Warn: Project is vulnerable to: PYSEC-2024-251 / GHSA-pg7h-5qx3-wjr3","Warn: Project is vulnerable to: PYSEC-2024-250","Warn: Project is vulnerable to: PYSEC-2024-259"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-23T07:13:06.451Z","repository_id":50490117,"created_at":"2025-08-23T07:13:06.451Z","updated_at":"2025-08-23T07:13:06.451Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28413952,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T08:16:59.381Z","status":"ssl_error","status_checked_at":"2026-01-14T08:13:45.490Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["classification","cox-model","feature-selection","neural-networks","regression"],"created_at":"2026-01-14T08:26:12.068Z","updated_at":"2026-01-14T08:26:12.726Z","avatar_url":"https://github.com/runopti.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Feature Selection using Stochastic Gates (STG) \n\n[Project Page](https://runopti.github.io/stg/)|[Paper](https://proceedings.icml.cc/static/paper_files/icml/2020/5085-Paper.pdf)\n\nFeature Selection using Stochastic Gates (STG) is a method for feature selection in neural network estimation problems. \nThe new procedure is based on probabilistic relaxation of\nthe l0 norm of features, or the count of the number of selected features.\nThe proposed framework simultaneously learns either a nonlinear regression or classification function while selecting a small subset of features.\n\n|![stg_image](docs/assets/stg_figure1_left.png)|\n|:--:|\n|Top: Each stochastic gate z_d is drawn from the STG approximation of the Bernoulli distribution (shown as the blue histogram on the right). Specifically, z_d is obtained by applying the hard-sigmoid function to a mean-shifted Gaussian random variable. Bottom: The z_d stochastic gate is attached to the x_d input feature, where the trainable parameter µ_d controls the probability of the gate being active|\n\n## Python \n\n### Installation\n\n#### Installation with pip\n\nTo install with `pip`, run the following command:\n```\npip install --user stg\n```\n\n#### Installation from GitHub\n\nYou can also clone the repository and install manually:\n```\ngit clone \ncd stg/python\npython setup.py install --user\n```\n\n### Usage\n\nOnce you install the library, you can import `STG` to create a model instance:\n```\nfrom stg import STG\nmodel = STG(task_type='regression',input_dim=X_train.shape[1], output_dim=1, hidden_dims=[500, 50, 10], activation='tanh', optimizer='SGD', learning_rate=0.1, batch_size=X_train.shape[0], feature_selection=True, sigma=0.5, lam=0.1, random_state=1, device=\"cpu\") \n\nmodel.fit(X_train, y_train, nr_epochs=3000, valid_X=X_valid, valid_y=y_valid, print_interval=1000)\n# Start training...\n```\n\nFor more details, please see our Colab notebooks:\n- [Regression example](https://colab.research.google.com/github/runopti/stg/blob/master/python/examples/Regression-example.ipynb)\n- [Classification example](https://colab.research.google.com/github/runopti/stg/blob/master/python/examples/Classification-example.ipynb)\n- [Cox example](https://colab.research.google.com/github/runopti/stg/blob/master/python/examples/Cox-example.ipynb)\n\n## R\n\n### Installation \n\nYou first need to install the python package. \n\n#### Installation from CRAN\n\nRun the following command in your R console:\n```\ninstall.packages(\"Rstg\")\n```\n\n#### Installation from Github\n\n```\ngit clone git://github.com/runopti/stg.git\ncd stg/python\npython setup.py install --user\ncd ../Rstg\nR CMD INSTALL .\n```\n\n### Usage\n\nPlease set the python path for `reticulate` to the python environment that you install the python stg package via this command in your R console or at the beginning of your R script. \n```\nreticulate::use_python(\"path_to_your_python_env_with_stg\")\n```\n\nThen you can instantiate a trainer:\n```\nstg_trainer \u003c- stg(task_type='regression', input_dim=100L, output_dim=1L, hidden_dims = c(500,50, 10), activation='tanh', optimizer='SGD', learning_rate=0.1, batch_size=100L, feature_selection=TRUE, sigma=0.5, lam=0.1, random_state=0.1)\n```\n\nYou can then fit the model to data as follows:\n```\n# After preparing `X_train`, `y_train`, `X_valid`, and `y_valid'\nstg_trainer$fit(X_train, y_train, nr_epochs=5000L, valid_X=X_valid, valid_y=y_valid, print_interval=1000L)\n```\n\nYou can save your trained model \n```\nstg_trainer$save_checkpoint('r_test_model.pth')\n```\nand load the model\n```\nstg_trainer$load_checkpoint('r_test_mode.pth')\n```\n\n### Acknowledgements and References\n\nWe thank Junchen Yang for his help to develop the R wrapper.\nSome of our codebase and its structure is inspired by https://github.com/vacancy/Jacinle. \n\nIf you find our library useful in your research, please consider citing us:\n```\n@incollection{icml2020_5085,\n author = {Yamada, Yutaro and Lindenbaum, Ofir and Negahban, Sahand and Kluger, Yuval},\n booktitle = {Proceedings of Machine Learning and Systems 2020},\n pages = {8952--8963},\n title = {Feature Selection using Stochastic Gates},\n year = {2020}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frunopti%2Fstg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frunopti%2Fstg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frunopti%2Fstg/lists"}