giotto-ai / giotto-tda

A high-performance topological machine learning toolbox in Python
https://giotto-ai.github.io/gtda-docs
Other
858 stars 175 forks source link

Scaled color_variable in plot_static_mapper #403

Closed miltminz closed 4 years ago

miltminz commented 4 years ago

Describe the problem

When giving an input to color_variable parameter in plot_static_mapper, the resulting variable results scaled in the interval [0, 1]

To reproduce

import pandas as pd
import numpy as np
from sklearn.cluster import DBSCAN
from gtda.mapper import (
    CubicalCover,
    make_mapper_pipeline,
    Projection,
    plot_static_mapper_graph
)

# Create df
df = pd.DataFrame(
    {'A': np.random.randint(low=1, high=1000, size=500),
     'B': np.random.normal(size=500),
     'C': np.random.uniform(size=500)})

# Make mapper pipeline
pipe = make_mapper_pipeline(
    filter_func=Projection(columns=["A", "B"]),
    cover=CubicalCover(n_intervals=10, overlap_frac=0.3),
    clusterer=DBSCAN(),
    verbose=False,
    n_jobs=1)

# Plot static mapper
fig = plot_static_mapper_graph(pipe, df, color_by_columns_dropdown=True,
    color_variable=df['A'])
fig.show(config={'scrollZoom': True})

Proposed solution Show the color_variable unscaled as for the other variables of the dataframe (as one can see in the dropdown menu) or add a boolean parameter to let choose between a scaled version or an unscaled one.

ulupo commented 4 years ago

Thanks for reporting this @miltminz!