module mlmodel.predictable_tsne
#
Short summary#
module mlinsights.mlmodel.predictable_tsne
Implements a predicatable t-SNE.
Classes#
class |
truncated documentation |
---|---|
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 |
---|---|
|
HTML representation of estimator. This is redundant with the logic of _repr_mimebundle_. The latter should … |
Methods#
method |
truncated documentation |
---|---|
Trains a TSNE then trains an estimator to approximate its outputs. |
|
Runs the predictions. |
Documentation#
Implements a predicatable t-SNE.
- class mlinsights.mlmodel.predictable_tsne.PredictableTSNE(normalizer=None, transformer=None, estimator=None, normalize=True, keep_tsne_outputs=False)#
Bases:
BaseEstimator
,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
transformer – sklearn.manifold.TSNE by default
estimator – sklearn.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_
- __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
- transform(X)#
Runs the predictions.
- Parameters:
X – numpy array or sparse matrix of shape [n_samples,n_features] Training data
- Returns:
tranformed X