How to use the retentioneering.visualization.plot.___FigureWrapper__ function in retentioneering

To help you get started, we’ve selected a few retentioneering 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 retentioneering / retentioneering-tools / retentioneering / visualization / plot.py View on Github external
tmp.index = tmp.target
        if plot_cnt <= 2:
            ax[i].pie(tmp.target_dist.reindex(targets).fillna(0).values, labels=targets, autopct='%1.1f%%')
            ax[i].set_title('Class {}\nCluster volume {}%\nMean dist from center {:.2f}'.format(
                i, round(volumes[i], 1), metrics['mean_fc'][j] if (metrics or {}).get('mean_fc') is not None else 0))
        else:
            ax[i // 2][i % 2].pie(tmp.target_dist.reindex(targets).fillna(0).values, labels=targets, autopct='%1.1f%%')
            ax[i // 2][i % 2].set_title('Class {}\nCluster volume {}%\nMean dist from center {:.2f}'.format(
                i, round(volumes[i], 1), metrics['mean_fc'][j] if (metrics or {}).get('mean_fc') is not None else 0))
    if plot_cnt % 2 == 1:
        fig.delaxes(ax[plot_cnt // 2, 1])

    plot_name = plot_name if plot_name is not None else 'clusters_pie_{}.svg'.format(
        datetime.now()).replace(':', '_').replace('.', '_')
    plot_name = data.retention.retention_config['experiments_folder'] + '/' + plot_name
    return ___FigureWrapper__(fig), plot_name, None, data.retention.retention_config
github retentioneering / retentioneering-tools / retentioneering / visualization / plot.py View on Github external
Return type
    -------
    PNG
    """

    if hasattr(data.retention, '_tsne'):
        tsne2 = data.retention._tsne.copy()
    else:
        tsne2 = data.retention.learn_tsne(clusters, **kwargs)
    tsne = tsne2.values
    if np.unique(clusters).shape[0] > 10:
        f, ax = sns.mpl.pyplot.subplots()
        points = ax.scatter(tsne[:, 0], tsne[:, 1], c=clusters, cmap="BrBG")
        f.colorbar(points)
        scatter = ___FigureWrapper__(f)
    else:
        scatter = sns.scatterplot(tsne[:, 0], tsne[:, 1], hue=clusters, legend='full', palette="BrBG")
    plot_name = plot_name if plot_name is not None else 'clusters_tsne_{}.svg'.format(
        datetime.now()).replace(':', '_').replace('.', '_')
    plot_name = data.retention.retention_config['experiments_folder'] + '/' + plot_name
    return scatter, plot_name, tsne2, data.retention.retention_config
github retentioneering / retentioneering-tools / retentioneering / visualization / plot.py View on Github external
ax = fig.add_subplot(111, projection='3d')

    if target is not None:
        scatter = ax.scatter(tsne[:, 0], tsne[:, 1], target, c=['C{}'.format(i) for i in clusters])
        lgs = []
        for i in set(clusters):
            lgs.append(sns.mpl.lines.Line2D([0], [0], linestyle="none", c='C{}'.format(i), marker='o'))
        ax.legend(lgs, set(clusters), numpoints=1)
    else:
        scatter = ax.scatter(tsne[:, 0], tsne[:, 1], clusters)

    ax.set_xlabel('TSNE 0')
    ax.set_ylabel('TSNE 1')
    ax.set_zlabel('Target')

    scatter = ___FigureWrapper__(fig)
    plot_name = plot_name if plot_name is not None else 'clusters_3d_tsne_{}.svg'.format(
        datetime.now()).replace(':', '_').replace('.', '_')
    plot_name = data.retention.retention_config['experiments_folder'] + '/' + plot_name
    return scatter, plot_name, None, data.retention.retention_config