Modified Dimensionality Reduction (moddr) is a Python package for combining dimensionality reduction techniques with community detection and visualization capabilities. This package presents a method for automatically modifying the positions of data points in low-dimensional spaces based on a feature selection to preserve both global structure and feature-driven similarity. The provided workflow uses graph theory concepts and layout methods to change the arrangement of a given DR-positioning in such a way that an additional similarity measure – based on selected features, for example – is integrated into the distance structure.
Full documentation is available at: https://moddr.readthedocs.io
The package is published on PyPI: https://pypi.python.org/pypi/moddr
Install it via:
pip install moddror, if you are using the uv package manager:
uv add moddrThe package was developed with the uv package manager, which is required for local development. After cloning the repository, run the following commands to create a working development environment (if not inside an existing workspace):
uv init project-name
uv sync
uv pip install -e . # needed to make the package functions available locallyYou can test the correct local installation by running:
uv run pytestThe package consists of three modules:
processing– computing modified embeddingsevaluation– computing metrics for evaluationvisualization– visualizing embeddings
An instance of the EmbeddingState-class allows you to access all computed information. Examples are available under ./examples as jupyter-notebooks. A minimal example can be implemented as follows. The parameters may have to be adjusted for the used data set, as the default parameters may not be suited.
import moddr
# Run the full moddr pipeline
embeddings = moddr.processing.run_pipeline(
data=your_data,
sim_features=your_feature_selection
verbose=True
)
# Visualize the embeddings
moddr.visualization.display_embeddings(embeddings)