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 …

Methods

method

truncated documentation

__init__

fit

Trains a TSNE then trains an estimator to approximate its outputs. Parameters ———- …

transform

Runs the predictions. Parameters ———- X : numpy array or sparse matrix of shape [n_samples,n_features] …

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)[source]

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.

source on GitHub

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)[source]
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

fit(X, y, sample_weight=None)[source]

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

Return type

returns an instance of self.

normalizer_
Type

trained normalier

transformer_
Type

trained transformeer

estimator_
Type

trained regressor

tsne_outputs_
Type

t-SNE outputs if keep_tsne_outputs is True

mean_
Type

average of the t-SNE output on each dimension

inv_std_

output on each dimension

Type

inverse of the standard deviation of the t-SNE

loss_

and the outputs of t-SNE

Type

loss (sklearn.metrics.mean_squared_error) between the predictions

source on GitHub

transform(X)[source]

Runs the predictions.

Parameters

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

Returns

Return type

tranformed X

source on GitHub