Skip to main content

t-Distributed Stochastic Neighbor Embedding with Particle Swarm Optimization

Project description

TSNE-PSO

t-Distributed Stochastic Neighbor Embedding with Particle Swarm Optimization (TSNE-PSO) is an enhanced version of t-SNE that uses Particle Swarm Optimization instead of gradient descent for the optimization step.

Installation

pip install tsne-pso

Usage

from tsne_pso import TSNEPSO
import numpy as np
from sklearn.datasets import load_iris

# Load data
iris = load_iris()
X = iris.data

# Apply TSNE-PSO
tsne_pso = TSNEPSO(
    n_components=2,
    perplexity=30.0,
    n_particles=10,
    n_iter=500,
    random_state=42
)
X_embedded = tsne_pso.fit_transform(X)

# Visualize results
import matplotlib.pyplot as plt
plt.figure(figsize=(10, 8))
scatter = plt.scatter(X_embedded[:, 0], X_embedded[:, 1], c=iris.target)
plt.legend(handles=scatter.legend_elements()[0], labels=iris.target_names)
plt.title('TSNE-PSO visualization of Iris dataset')
plt.show()

Features

  • Uses Particle Swarm Optimization for better optimization
  • Supports multiple initialization strategies (PCA, UMAP, t-SNE)
  • Optional hybrid approach using both PSO and gradient descent
  • Customizable parameters for optimization (particles, inertia, cognitive/social weights)

Dependencies

  • numpy
  • scipy
  • scikit-learn
  • umap-learn (optional)
  • tqdm (optional, for progress bars)

Citation

If you use this package in your research, please cite the following paper:

@article{allaoui2025t,
  title={t-SNE-PSO: Optimizing t-SNE using particle swarm optimization},
  author={Allaoui, Mebarka and Belhaouari, Samir Brahim and Hedjam, Rachid and Bouanane, Khadra and Kherfi, Mohammed Lamine},
  journal={Expert Systems with Applications},
  volume={269},
  pages={126398},
  year={2025},
  publisher={Elsevier}
}

License

BSD-3-Clause License (same as scikit-learn)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tsne_pso-1.1.0.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tsne_pso-1.1.0-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

Details for the file tsne_pso-1.1.0.tar.gz.

File metadata

  • Download URL: tsne_pso-1.1.0.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for tsne_pso-1.1.0.tar.gz
Algorithm Hash digest
SHA256 f438271245fbbf4ccbad42b9fac349f7f49fb1b7b970f9fb8fb9a5e3fef9687c
MD5 8550d9f167a9bfbbadc0b46b6c05af01
BLAKE2b-256 86c49d9e8598e175935779ddce67a2ef3d509d39f994452b6cc8bffd3309e94a

See more details on using hashes here.

File details

Details for the file tsne_pso-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: tsne_pso-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for tsne_pso-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 06e6019512cd3ca6e4f8ca9201dc9406d115a07e353592bf530fc5fc850bf3f3
MD5 e60ff92ce61f9e995525698bc7ccbc68
BLAKE2b-256 a4e3f7bfd4c4e53737aea0dbca765b9467fa46cf71c18582d4b8aa30903825a7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page