How to use the kmapper.visuals.format_meta function in kmapper

To help you get started, we’ve selected a few kmapper examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github scikit-tda / kepler-mapper / test / test_visuals.py View on Github external
def test_format_meta(self):
        mapper = KeplerMapper()
        data = np.random.rand(1000, 10)
        lens = mapper.fit_transform(data, projection=[0])
        graph = mapper.map(lens, data)

        fmt = format_meta(graph)
        assert fmt["n_nodes"] == len(graph["nodes"])

        assert "n_edges" in fmt.keys()
        assert "n_total" in fmt.keys()

        del fmt["custom_meta"]
        vals = fmt.values()
        for v in vals:
            assert isinstance(v, numbers.Number)
github scikit-tda / kepler-mapper / test / test_visuals.py View on Github external
def test_format_meta_with_meta(self):
        mapper = KeplerMapper()
        data = np.random.rand(1000, 10)
        lens = mapper.fit_transform(data, projection=[0])
        graph = mapper.map(lens, data)

        cm = "My custom_meta"
        fmt = format_meta(graph, cm)
        assert fmt["custom_meta"] == cm
github scikit-tda / kepler-mapper / kmapper / plotlyviz.py View on Github external
color_function = init_color_function(simplicial_complex, color_function)

    json_graph = scomplex_to_graph(
        simplicial_complex,
        color_function,
        X,
        X_names,
        lens,
        lens_names,
        custom_tooltips,
        colorscale=colorscale,
    )
    colorf_distribution = graph_data_distribution(
        simplicial_complex, color_function, colorscale
    )
    mapper_summary = format_meta(
        simplicial_complex,
        color_function_name=color_function_name,
        custom_meta=custom_meta,
    )

    return json_graph, mapper_summary, colorf_distribution
github scikit-tda / kepler-mapper / kmapper / kmapper.py View on Github external
graph,
            color_function,
            X,
            X_names,
            lens,
            lens_names,
            custom_tooltips,
            env,
            nbins,
        )

        colorscale = colorscale_default

        histogram = graph_data_distribution(graph, color_function, colorscale)

        mapper_summary = format_meta(graph, custom_meta)

        # Find the absolute module path and the static files
        js_path = os.path.join(os.path.dirname(__file__), "static", "kmapper.js")
        with open(js_path, "r") as f:
            js_text = f.read()

        css_path = os.path.join(os.path.dirname(__file__), "static", "style.css")
        with open(css_path, "r") as f:
            css_text = f.read()

        # Render the Jinja template, filling fields as appropriate
        template = env.get_template("base.html").render(
            title=title,
            mapper_summary=mapper_summary,
            histogram=histogram,
            dist_label="Node",