Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if not (hasattr(self, '_tsne') and not refit):
self._tsne = feature_extraction.learn_tsne(features, **kwargs)
if plot_type == 'clusters':
if kwargs.get('cmethod') is not None:
kwargs['method'] = kwargs.pop('cmethod')
old_targs = targets.copy()
targets = self.get_clusters(plot_type=None, **kwargs)
elif plot_type == 'targets':
targets = self._tsne_targets
else:
return self._tsne
if proj_type == '3d':
plot.tsne_3d(
self._obj,
clustering.aggregate_cl(targets, 7) if kwargs.get('method') == 'dbscan' else targets,
old_targs,
**kwargs
)
else:
plot.cluster_tsne(
self._obj,
clustering.aggregate_cl(targets, 7) if kwargs.get('method') == 'dbscan' else targets,
targets,
**kwargs
)
return self._tsne
self.clusters, self._metrics = clusterer(features, **kwargs)
self._create_cluster_mapping(features.index.values)
if hasattr(self, 'datatype') and self.datatype == 'features':
target = kwargs.pop('target')
else:
target = self.get_positive_users(**kwargs)
target = features.index.isin(target)
self._metrics['homogen'] = clustering.homogeneity_score(target, self.clusters)
if hasattr(self, '_tsne'):
features.retention._tsne = self._tsne
if plot_type:
func = getattr(plot, plot_type)
res = func(
features,
clustering.aggregate_cl(self.clusters, 7) if method == 'dbscan' else self.clusters,
target,
metrics=self._metrics,
**kwargs
)
if res is not None:
self._tsne = res
return self.clusters