{"id":16928298,"url":"https://github.com/maartengr/vlac","last_synced_at":"2026-02-27T09:43:31.580Z","repository":{"id":62587190,"uuid":"179710668","full_name":"MaartenGr/VLAC","owner":"MaartenGr","description":"Vectors of Locally Aggregated Concepts","archived":false,"fork":false,"pushed_at":"2024-06-17T23:01:24.000Z","size":28727,"stargazers_count":11,"open_issues_count":2,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-14T20:36:16.089Z","etag":null,"topics":["fasttext","kmeans","machine-learning","nlp","word-embeddings","word2vec"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","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/MaartenGr.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":"2019-04-05T15:44:58.000Z","updated_at":"2023-08-16T23:30:21.000Z","dependencies_parsed_at":"2022-11-03T22:35:40.804Z","dependency_job_id":null,"html_url":"https://github.com/MaartenGr/VLAC","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaartenGr%2FVLAC","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaartenGr%2FVLAC/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaartenGr%2FVLAC/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaartenGr%2FVLAC/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MaartenGr","download_url":"https://codeload.github.com/MaartenGr/VLAC/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221674103,"owners_count":16861769,"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":["fasttext","kmeans","machine-learning","nlp","word-embeddings","word2vec"],"created_at":"2024-10-13T20:36:24.226Z","updated_at":"2026-02-27T09:43:31.528Z","avatar_url":"https://github.com/MaartenGr.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Vectors of Locally Aggregated Concepts (VLAC)\n\n[![PyPI - Status](https://img.shields.io/badge/status-beta-yellow.svg)](https://pypi.org/project/vlac/)\n[![PyPI - Python](https://img.shields.io/badge/python-3.4%20%7C%203.5%20%7C%203.6-blue.svg)](https://pypi.org/project/vlac/)\n[![PyPI - License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/MaartenGr/VLAC/blob/master/LICENSE)\n[![PyPI - PyPi](https://img.shields.io/badge/pypi-0.1.2.5-blue.svg)](https://pypi.org/project/vlac/)\n\nGrootendorst, M., \u0026 Vanschoren, J. (2019, September). Beyond Bag-of-Concepts: Vectors of Locally Aggregated Concepts. *In Joint European Conference on Machine Learning and Knowledge Discovery in Databases* (pp. 681-696). Springer, Cham.\n\nArticle can be found [here](https://www.ecmlpkdd2019.org/downloads/paper/489.pdf). \n\n## Installation\n\nInstallation can be done using [pypi](https://pypi.org/project/vlac/)\n\n``pip install vlac``\n\n## Purpose\nAs illustrated in the Figure below, VLAC clusters word embeddings to create *k* concepts. Due to the high dimensionality of word embeddings (i.e., 300) spherical k-means is used to perform the clustering as applying euclidean distance will result in little difference in the distances between samples. The method works as follows. Let *w\u003csub\u003ei\u003c/sub\u003e* be a word embedding of size *D* assigned to cluster center *c\u003csub\u003ek\u003c/sub\u003e*. Then, for each word in a document, VLAC computes the element-wise sum of residuals of each word embedding to its assigned cluster center. This results in *k* feature vectors, one for each concept, and all of size *D*. All feature vectors are then concatenated, power normalized, and finally, l2 normalization is applied. For example, if 10 concepts were to be created out of word embeddings of size 300 then the resulting document vector would contain 10 x 300 values. \n\n\u003cimg src=\"https://github.com/MaartenGr/VLAC/blob/master/Images/vlac.png?raw=true\" width=\"70%\"/\u003e\n\n## Usage / Example\nBelow is an example of how to use the model. The example mirrors the Reuters R8 dataset \n\n```python\nfrom vlac import VLAC\nimport pickle\n\n# Contains embeddings for Reuters R8\nwith open('Data/r8_glove_1f.pickle', 'rb') as handle:\n    model = pickle.load(handle)\n\n# Load data\nwith open('Data/r8_docs.txt', \"r\") as f:\n    docs = f.readlines()\n\n# Train model and transform collection of documents\nvlac_model = VLAC(documents=docs, model=model, oov=False)\nvlac_features, kmeans = vlac_model.fit_transform(num_concepts=30)\n\n# Create features for new documents\nvlac_model = VLAC(documents=docs, model=model, oov=False)\nvlac_features = vlac_model.transform(kmeans=kmeans)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaartengr%2Fvlac","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaartengr%2Fvlac","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaartengr%2Fvlac/lists"}