Implements the USL Technique for embeddings of any data, be it text, image, etc.
Project description
Unsupervised Learning for Embedding (USL)
This project implements the USL and USL-t methods for unsupervised learning with embeddings, allowing the use of embeddings to form clusters and potentially improve learning outcomes in unsupervised settings.
Installation
Clone the repository and install the required packages:
git clone [URL_to_this_repo]
cd [repo_name]
pip install -r requirements.txt
Usage
The usl_for_embedding function is designed to process embedding arrays for clustering. It can be used directly by importing from the selective_labeling.py:
from selective_labeling import usl_for_embedding
# Generate 10 embeddings, each with 10 random floating-point numbers
data = {'embedding': [list(np.random.rand(10)) for _ in range(10)]}
# method is 'usl' or 'usl-t'
# n_clusters is the number of samples that should be selected for labeling
selected_indices = usl_for_embedding(data['embedding'],method='usl',n_clusters=2,
learning_rate=0.001,batch_size=64,n_init=10,m_reg=0.9,k=10,lambda_=0.5,
epsilon=1e-5,alpha=0.75,num_epochs_cluster=100,num_heads=3)
print(selected_indices)
Parameters
- embeddings (array-like): Input data, embeddings to be clustered.
- method (str): The clustering method to use ('usl' or 'usl-t').
- n_clusters (int): Number of clusters to form.
- Additional parameters include learning rate, batch size, initialization runs, regularization term, and more described in
main.py.
Project Structure
project_root/
│
├── methods/ # Module for clustering algorithms
│ ├── usl.py # Contains the density regulation based USL
│ └── usl_t.py # Contains the transformer based USL-t
│
├── models/ # Models used in USL-t
│ └── ssl_t_models/
│ └── clustering_model.py # Clustering model for USL-t
│
└── main.py # Main script to use USL methods
Main Files and Their Roles
- main.py: Contains the primary functions used to interface with the USL methods and demonstrates an example usage.
- usl.py and usl_t.py: Implementation of the USL and USL-t methods, respectively.
- clustering_model.py: Defines the neural network models used in the USL-t method.
Contributing
Contributions to this project are welcome. Please fork the repository and submit a pull request with your features or fixes.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Replace `[URL_to_this_repo]` and `[repo_name]` with your actual repository URL and name. This README provides a clear overview of how to set up and use the project, and details the files and their functions within the project structure.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file usl_embedding-0.1.1.tar.gz.
File metadata
- Download URL: usl_embedding-0.1.1.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3937be805c4a2116fc2bd3095f6456383b8447a84433931eac49232bd8b052b7
|
|
| MD5 |
0150e6f797fdb27f2d188091591605ae
|
|
| BLAKE2b-256 |
1bf78fe0054d3fd6438eac83215880881ee40685973b1a60ba58d5ec911cdefb
|
File details
Details for the file usl_embedding-0.1.1-py3-none-any.whl.
File metadata
- Download URL: usl_embedding-0.1.1-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71081833c9394d6c1a23c90131d431f98f0b1088542a2fbd4f0a51805791f2de
|
|
| MD5 |
96dc11080bcfe40e8b59864a3cb5ba2f
|
|
| BLAKE2b-256 |
c08a2a94a99746c67cb6a32053146d1517dc6fae0fd71e452c099ecb8a79230f
|