(data, perplexity, multiscale, exaggeration)
return manifold.TSNE(
        n_components=2,
        perplexity=perplexity,
        multiscale=multiscale,
        early_exaggeration_iter=early_exagg_iter,
        n_iter=n_iter,
        exaggeration=exaggeration,
        neighbors=neighbor_method,
        negative_gradient_method=gradient_method,
        theta=0.8,
        random_state=0,
    )
Automatically determine the best parameters for the given data set.
Automatically determine the best parameters for the given data set.
Automatically determine the best parameters for the given data set .
def prepare_tsne_obj(data, perplexity, multiscale, exaggeration):
    # type: (Table, float, bool, float) -> manifold.TSNE
    """Automatically determine the best parameters for the given data set."""
    # Compute perplexity settings for multiscale
    n_samples = data.X.shape[0]
    if multiscale:
        perplexity = min((n_samples - 1) / 3, 50), min((n_samples - 1) / 3, 500)
    else:
        perplexity = perplexity

    # Determine whether to use settings for large data sets
    if n_samples > 10_000:
        neighbor_method, gradient_method = "approx", "fft"
    else:
        neighbor_method, gradient_method = "exact", "bh"

    # Larger data sets need a larger number of iterations
    if n_samples > 100_000:
        early_exagg_iter, n_iter = 500, 1000
    else:
        early_exagg_iter, n_iter = 250, 750

    return manifold.TSNE(
        n_components=2,
        perplexity=perplexity,
        multiscale=multiscale,
        early_exaggeration_iter=early_exagg_iter,
        n_iter=n_iter,
        exaggeration=exaggeration,
        neighbors=neighbor_method,
        negative_gradient_method=gradient_method,
        theta=0.8,
        random_state=0,
    )
def prepare_tsne_obj ( data , perplexity , multiscale , exaggeration ) : # type: (Table, float, bool, float) -> manifold.TSNE # Compute perplexity settings for multiscale n_samples = data . X . shape [ 0 ] if multiscale : perplexity = min ( ( n_samples - 1 ) / 3 , 50 ) , min ( ( n_samples - 1 ) / 3 , 500 ) else : perplexity = perplexity # Determine whether to use settings for large data sets if n_samples > 10_000 : neighbor_method , gradient_method = "approx" , "fft" else : neighbor_method , gradient_method = "exact" , "bh" # Larger data sets need a larger number of iterations if n_samples > 100_000 : early_exagg_iter , n_iter = 500 , 1000 else : early_exagg_iter , n_iter = 250 , 750 return manifold . TSNE ( n_components = 2 , perplexity = perplexity , multiscale = multiscale , early_exaggeration_iter = early_exagg_iter , n_iter = n_iter , exaggeration = exaggeration , neighbors = neighbor_method , negative_gradient_method = gradient_method , theta = 0.8 , random_state = 0 , )