Metadata-Version: 2.4
Name: PyGlimmerMDS
Version: 0.0.2
Summary: Python Implementation of the Glimmer algorithm for multidimensional scaling
Author: David Hägele
License: MIT License
        
        Copyright (c) 2025 David Hägele
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/hageldave/PyGlimmerMDS
Project-URL: Bug Tracker, https://github.com/hageldave/PyGlimmerMDS/issues
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Requires-Dist: numba
Dynamic: license-file

# PyGlimmerMDS
A python implementation of the [Glimmer algorithm](https://doi.org/10.1109/TVCG.2008.85) for multidimensional scaling (MDS).

Glimmer performs dimensionality reduction on high-dimensional data sets of many instances, 
avoiding the quadratic runtime behavior of naive MDS implementations by employing a multilevel (coarse to fine) approach.
This implementation does **not** utilize the GPU, but gives considerable speedup nonetheless and makes MDS on large data
sets feasible.

Glimmer is a metric MDS and uses Euclidean distance in the high-dimensional space as the dissimilarity measure.


## Installation
```
pip install PyGlimmerMDS
```
or if you want to install a specific commit use
```
pip install git+https://github.com/hageldave/PyGlimmerMDS@<commit_hash>
```

## How to use
Jittering the Iris data set to produce a data set of 38,400 points. Performing Glimmer on this data set.

```python
from pyglimmermds import Glimmer, execute_glimmer
from sklearn import preprocessing as prep
from sklearn import datasets
import numpy as np
import matplotlib.pyplot as plt

# get iris data
dataset = datasets.load_iris()
data = dataset.data
labels = dataset.target
# duplicate data with added noise
for _ in range(8):
  data = np.vstack((data,data+(np.random.rand(data.shape[0], data.shape[1])*0.2-.1)))
  labels = np.append(labels,labels)
print(data.shape)
print(labels.shape)
# perform MDS
data = prep.StandardScaler().fit_transform(data)
mds = Glimmer(decimation_factor=2, stress_ratio_tol=1 - 1e-5)
projection = mds.fit_transform(data) # alternative: execute_glimmer(data)
# show scatter plot
fig, ax = plt.subplots()
scatter = ax.scatter(projection[:, 0], projection[:, 1], c=labels, s=1)
ax.axis('equal')
plt.show(fig)
```
![glimmer_iris](https://github.com/user-attachments/assets/8dad7f6b-0f08-4088-b76f-edd572a7f886)
