module mlmodel.predictable_tsne#

Inheritance diagram of mlinsights.mlmodel.predictable_tsne

Short summary#

module mlinsights.mlmodel.predictable_tsne

Implements a predicatable t-SNE.

source on GitHub

Classes#

class

truncated documentation

PredictableTSNE

t-SNE is an interesting transform which can only be used to study data as there is no way to reproduce the …

Properties#

property

truncated documentation

_repr_html_

HTML representation of estimator. This is redundant with the logic of _repr_mimebundle_. The latter should …

Methods#

method

truncated documentation

__init__

fit

Trains a TSNE then trains an estimator to approximate its outputs.

transform

Runs the predictions.

Documentation#

Implements a predicatable t-SNE.

source on GitHub

class mlinsights.mlmodel.predictable_tsne.PredictableTSNE(normalizer=None, transformer=None, estimator=None, normalize=True, keep_tsne_outputs=False)#

Bases: sklearn.base.BaseEstimator, sklearn.base.TransformerMixin

t-SNE is an interesting transform which can only be used to study data as there is no way to reproduce the result once it was fitted. That’s why the class TSNE does not have any method transform, only fit_transform. This example proposes a way to train a machine learned model which approximates the outputs of a TSNE transformer. Notebooks Predictable t-SNE gives an example on how to use this class.

Parameters
  • normalizer – None by default

  • transformersklearn.manifold.TSNE by default

  • estimatorsklearn.neural_network.MLPRegressor by default

  • normalize – normalizes the outputs, centers and normalizes the output of the t-SNE and applies that same normalization to he prediction of the estimator

  • keep_tsne_output – if True, keep raw outputs of TSNE is stored in member tsne_outputs_

source on GitHub

__init__(normalizer=None, transformer=None, estimator=None, normalize=True, keep_tsne_outputs=False)#
fit(X, y, sample_weight=None)#

Trains a TSNE then trains an estimator to approximate its outputs.

Parameters
  • X – numpy array or sparse matrix of shape [n_samples,n_features] Training data

  • y – numpy array of shape [n_samples, n_targets] Target values. Will be cast to X’s dtype if necessary

  • sample_weight – numpy array of shape [n_samples] Individual weights for each sample

Returns

self, returns an instance of self.

Fitted attributes:

  • normalizer_: trained normalier

  • transformer_: trained transformeer

  • estimator_: trained regressor

  • tsne_outputs_: t-SNE outputs if keep_tsne_outputs is True

  • mean_: average of the t-SNE output on each dimension

  • inv_std_: inverse of the standard deviation of the t-SNE

    output on each dimension

  • loss_: loss (sklearn.metrics.mean_squared_error) between the predictions

    and the outputs of t-SNE

source on GitHub

transform(X)#

Runs the predictions.

Parameters

X – numpy array or sparse matrix of shape [n_samples,n_features] Training data

Returns

tranformed X

source on GitHub