{"id":23159598,"url":"https://github.com/skblaz/san","last_synced_at":"2025-07-23T16:07:47.184Z","repository":{"id":86487817,"uuid":"255638142","full_name":"SkBlaz/san","owner":"SkBlaz","description":"Attention-based feature ranking for propositional data.","archived":false,"fork":false,"pushed_at":"2023-10-15T09:43:20.000Z","size":725,"stargazers_count":28,"open_issues_count":2,"forks_count":10,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-05T17:35:24.659Z","etag":null,"topics":["attention-mechanism","deep-neural-networks","feature-ranking","machine-learning"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SkBlaz.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-14T14:50:23.000Z","updated_at":"2025-03-28T05:43:12.000Z","dependencies_parsed_at":"2023-10-16T02:33:22.501Z","dependency_job_id":"d76d7032-d092-44d0-9e56-cb3597742b98","html_url":"https://github.com/SkBlaz/san","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/SkBlaz/san","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SkBlaz%2Fsan","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SkBlaz%2Fsan/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SkBlaz%2Fsan/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SkBlaz%2Fsan/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SkBlaz","download_url":"https://codeload.github.com/SkBlaz/san/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SkBlaz%2Fsan/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266708513,"owners_count":23971944,"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-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"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":["attention-mechanism","deep-neural-networks","feature-ranking","machine-learning"],"created_at":"2024-12-17T22:41:13.530Z","updated_at":"2025-07-23T16:07:47.158Z","avatar_url":"https://github.com/SkBlaz.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Feature ranking with self-attention networks\nThis is the repository of the SAN paper, found here:\n\n```\n@inproceedings{DBLP:conf/ecai/SkrljDLP20,\n  author    = {Blaz Skrlj and\n               Saso Dzeroski and\n               Nada Lavrac and\n               Matej Petkovic},\n  editor    = {Giuseppe De Giacomo and\n               Alejandro Catal{\\'{a}} and\n               Bistra Dilkina and\n               Michela Milano and\n               Sen{\\'{e}}n Barro and\n               Alberto Bugar{\\'{\\i}}n and\n               J{\\'{e}}r{\\^{o}}me Lang},\n  title     = {Feature Importance Estimation with Self-Attention Networks},\n  booktitle = {{ECAI} 2020 - 24th European Conference on Artificial Intelligence,\n               29 August-8 September 2020, Santiago de Compostela, Spain, August\n               29 - September 8, 2020 - Including 10th Conference on Prestigious\n               Applications of Artificial Intelligence {(PAIS} 2020)},\n  series    = {Frontiers in Artificial Intelligence and Applications},\n  volume    = {325},\n  pages     = {1491--1498},\n  publisher = {{IOS} Press},\n  year      = {2020},\n  url       = {https://doi.org/10.3233/FAIA200256},\n  doi       = {10.3233/FAIA200256},\n  timestamp = {Tue, 15 Sep 2020 15:08:42 +0200},\n  biburl    = {https://dblp.org/rec/conf/ecai/SkrljDLP20.bib},\n  bibsource = {dblp computer science bibliography, https://dblp.org}\n}\n```\n\nhttp://ecai2020.eu/papers/1721_paper.pdf\n(please, cite if you are using it!).\nNote that the full code with datasets to reproduce the paper can be found here: https://gitlab.com/skblaz/attentionrank (the code is in benchmark-ready form). The purpose of this repository is to provide all functionality in a user-friendly way. Disclaimer: this code was not extensively benchmarked and can contain bugs. If you find one, please open an issue.\n\n# Installing SANs\n```\npython setup.py install\n```\n\nor\n\n```\npip install git+https://github.com/SkBlaz/san\n```\n# Using SANs\nA simple usecase is given next:\n\n\n```\nfrom scipy import sparse\nimport numpy as np\nfrom sklearn.datasets import load_breast_cancer\nimport san\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nfrom sklearn.feature_selection import chi2,f_classif,mutual_info_classif\nfrom sklearn.ensemble import RandomForestClassifier\n\nsns.set_style(\"whitegrid\")\ndataobj = load_breast_cancer()\nX = dataobj['data']\nY = dataobj['target']\nnames = dataobj['feature_names']\n\n# let's overfit, just for demo purposes\nclf = san.SAN(num_epochs = 32, num_heads = 2, batch_size = 8, dropout = 0.2, hidden_layer_size = 32)\nX = sparse.csr_matrix(X)\nclf.fit(X, Y)\npreds = clf.predict(X)\nglobal_attention_weights = clf.get_mean_attention_weights()\nlocal_attention_matrix = clf.get_instance_attention(X)\nmutual_information = mutual_info_classif(X,Y)\nrf = RandomForestClassifier().fit(X,Y).feature_importances_\n\nplt.plot(names, global_attention_weights, label = \"Global attention\", marker = \"x\")\nplt.plot(names, np.mean(local_attention_matrix, axis = 0), label = \"Local attention - mean\", marker = \"x\")\n\nplt.plot(names, np.max(local_attention_matrix, axis = 0), label = \"Local attention - max\", marker = \"x\")\n\nplt.plot(names, mutual_information, label = \"Mutual information\", marker = \".\")\n\nplt.plot(names, rf, label = \"RandomForest\", marker = \".\")\n\nplt.legend(loc = 1)\nplt.xticks(rotation = 90)\nplt.tight_layout()\nplt.show()\n\n```\n\n![Example](images/example.png)\n\n\nExample mock evaluation is shown below (examples/example_benchmark.py):\n![Example](images/example1.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskblaz%2Fsan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskblaz%2Fsan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskblaz%2Fsan/lists"}