{"id":18029464,"url":"https://github.com/hyiltiz/info","last_synced_at":"2025-04-04T21:12:57.483Z","repository":{"id":151363299,"uuid":"342828422","full_name":"hyiltiz/info","owner":"hyiltiz","description":"Correctly computed entropy, mutual information, surprisal, KL divergence, all-in-one module.","archived":false,"fork":false,"pushed_at":"2021-08-16T17:58:27.000Z","size":17,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-10T05:41:52.644Z","etag":null,"topics":["approximation","entropy","information-theory","logical-fallacies","model-selection","probabilistic-models","python3","statistical-learning","toolbox"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hyiltiz.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}},"created_at":"2021-02-27T10:23:14.000Z","updated_at":"2021-04-09T02:39:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"be55a52d-89c7-4550-b99f-98f41253c248","html_url":"https://github.com/hyiltiz/info","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyiltiz%2Finfo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyiltiz%2Finfo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyiltiz%2Finfo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyiltiz%2Finfo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hyiltiz","download_url":"https://codeload.github.com/hyiltiz/info/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247249549,"owners_count":20908212,"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":["approximation","entropy","information-theory","logical-fallacies","model-selection","probabilistic-models","python3","statistical-learning","toolbox"],"created_at":"2024-10-30T09:09:43.164Z","updated_at":"2025-04-04T21:12:57.448Z","avatar_url":"https://github.com/hyiltiz.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Quick start\nDownload the module `info.py` into your project directory, and do:\n```\nfrom info import compute as compute_mutual_information\n\nX = [1, 2, 3, 4, 5]\nY = [4, 1, 3, 4, 2]\nX_range = (1, 5)\nY_range = (1, 5)  # 5 did not occur in the sample Y yet\n\n[mi_XY, mi_XY_normalized, everything] = compute_mutual_information(X, Y, [X_range, Y_range])\n\n# `everything` is a nested dictionary that contains other normalized variants\n# of mutual information, as well as some commonly used information theoretic\n# metrics such as entropy, conditional entropy, self-information (also known as\n# information content or surprisal). known as information content or\n# surprisal), relative entropy (also known as KL-divergence or information\n# gain). Joint and marginal probability mass functions and contingency tables\n# are also included for convenience. Note the example output is computed using\n# 1000 samples.\n\neverything = {\n 'N': 1000,\n 'entropy': {'X':         2.3168095633619847,\n             'Y':         2.3199539124456714,\n             'XY':        4.625700518983682,\n             'X-given-Y': 2.3088909556216985,\n             'Y-given-X': 2.305746606538012},\n 'mutual-information': {\n             'standard':                        0.01106295682397285,\n              # normalize by entropy (asymmetric), ranges from [0, 1]\n             'normalized-by-HX':                0.0047750825095521,\n             'normalized-by-HY':                0.0047750825095521,\n              # other normalization variants (symmetric)\n             'symmetric':                       0.004771844361565519,\n             'redundancy':                      0.0023859221807827594,\n             'generalized-pearson-correlation': 0.004771845458771204,\n             'generalized-total-correlation':   0.0047750825095521,\n             'information-quality-ratio':       0.0023916284200784154,\n             'adjusted-mutual-information':     'TODO'},\n 'self-information': {'X': array([2.35845397, 2.41119543, 2.23786383, 2.48196851, 2.14560532]),\n                      'Y': array([2.29335894, 2.42662547, 2.32192809, 2.20423305, 2.37332725]),\n                      'XY': array([[4.83650127, 4.50635267, 4.57346686, 4.68038207, 4.50635267],\n                                   [4.53951953, 5.01158797, 4.83650127, 4.87832144, 4.53951953],\n                                   [4.57346686, 4.96578428, 4.60823228, 5.15842936, 4.13289427],\n                                   [4.64385619, 4.44222233, 4.21089678, 4.79585928, 4.60823228],\n                                   [4.83650127, 4.83650127, 4.64385619, 4.57346686, 4.60823228]])}\n 'count': {'X': array([[195, 188, 212, 179, 226],\n                       [195, 188, 212, 179, 226],\n                       [195, 188, 212, 179, 226],\n                       [195, 188, 212, 179, 226],\n                       [195, 188, 212, 179, 226]]),\n           'Y': array([[204, 204, 204, 204, 204],\n                       [186, 186, 186, 186, 186],\n                       [200, 200, 200, 200, 200],\n                       [217, 217, 217, 217, 217],\n                       [193, 193, 193, 193, 193]])},\n           'XY': array([[35, 44, 42, 39, 44],\n                        [43, 31, 35, 34, 43],\n                        [42, 32, 41, 28, 57],\n                        [40, 46, 54, 36, 41],\n                        [35, 35, 40, 42, 41]]),\n 'p': {'X': array([[0.195, 0.188, 0.212, 0.179, 0.226],\n                   [0.195, 0.188, 0.212, 0.179, 0.226],\n                   [0.195, 0.188, 0.212, 0.179, 0.226],\n                   [0.195, 0.188, 0.212, 0.179, 0.226],\n                   [0.195, 0.188, 0.212, 0.179, 0.226]]),\n       'Y': array([[0.204, 0.204, 0.204, 0.204, 0.204],\n                   [0.186, 0.186, 0.186, 0.186, 0.186],\n                   [0.2  , 0.2  , 0.2  , 0.2  , 0.2  ],\n                   [0.217, 0.217, 0.217, 0.217, 0.217],\n                   [0.193, 0.193, 0.193, 0.193, 0.193]])}\n       'XY': array([[0.035, 0.044, 0.042, 0.039, 0.044],\n                    [0.043, 0.031, 0.035, 0.034, 0.043],\n                    [0.042, 0.032, 0.041, 0.028, 0.057],\n                    [0.04 , 0.046, 0.054, 0.036, 0.041],\n                    [0.035, 0.035, 0.04 , 0.042, 0.041]]),\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyiltiz%2Finfo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhyiltiz%2Finfo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyiltiz%2Finfo/lists"}