//  [python]
def predict_labels(self):
        """
        predict labels from training set
        using K-Means algorithm on the node activities,
        using only nodes linked to survival
        """
        if self.verbose:
            print('performing clustering on the omic model with the following key:{0}'.format(
                self.training_omic_list))

        if hasattr(self.cluster_method, 'fit_predict'):
            self.clustering = self.cluster_method(n_clusters=self.nb_clusters)
            self.cluster_method == 'custom'

        elif self.cluster_method == 'kmeans':
            self.clustering = KMeans(n_clusters=self.nb_clusters, n_init=100)

        elif self.cluster_method == 'mixture':
            self.clustering = GaussianMixture(
                n_components=self.nb_clusters,
                **self.mixture_params
            )

        elif self.cluster_method == "coxPH":
            nbdays, isdead = self.dataset.survival.T.tolist()

            self.clustering = ClusterWithSurvival(
                n_clusters=self.nb_clusters,
                isdead=isdead,
                nbdays=nbdays)

        elif self.cluster_method == "coxPHMixture":
            nbdays, isdead = self.dataset.survival.T.tolist()

            self.clustering = ClusterWithSurvival(
                n_clusters=self.nb_clusters,
                use_gaussian_to_dichotomize=True,
                isdead=isdead,
                nbdays=nbdays)

        else:
            raise(Exception("No method fit and predict found for: {0}".format(
                self.cluster_method)))

        if not self.activities_train.any():
            raise Exception('No components linked to survival!'\
                            ' cannot perform clustering')

        if self.cluster_array and len(self.cluster_array) > 1:
            self._predict_best_k_for_cluster()

        if hasattr(self.clustering, 'predict'):
            self.clustering.fit(self.activities_train)
            labels = self.clustering.predict(self.activities_train)
        else:
            labels = self.clustering.fit_predict(self.activities_train)

        labels = self._order_labels_according_to_survival(labels)

        self.labels = labels

        if hasattr(self.clustering, 'predict_proba'):
            self.labels_proba = self.clustering.predict_proba(self.activities_train)
        else:
            self.labels_proba = np.array([self.labels, self.labels]).T

        if len(self.labels_proba.shape) == 1:
            self.labels_proba = self.labels_proba.reshape((
                self.labels_proba.shape[0], 1))

        if self.labels_proba.shape[1] < self.nb_clusters:
            missing_columns = self.nb_clusters - self.labels_proba.shape[1]

            for i in range(missing_columns):
                self.labels_proba = hstack([
                    self.labels_proba, np.zeros(
                        shape=(self.labels_proba.shape[0], 1))])

        if self.verbose:
            print("clustering done, labels ordered according to survival:")
            for key, value in Counter(labels).items():
                print('cluster label: {0}\t number of samples:{1}'.format(key, value))
            print('\n')

        nbdays, isdead = self.dataset.survival.T.tolist()

        if self.metadata_usage in ['all', 'labels'] and \
           self.dataset.metadata_mat is not None:
            metadata_mat = self.dataset.metadata_mat
        else:
            metadata_mat = None

        pvalue = coxph(self.labels, isdead, nbdays,
                       isfactor=False,
                       do_KM_plot=self.do_KM_plot,
                       png_path=self.path_results,
                       seed=self.seed,
                       use_r_packages=self.use_r_packages,
                       metadata_mat=metadata_mat,
                       fig_name='{0}_KM_plot_training_dataset'.format(self.project_name))

        pvalue_proba = coxph(self.labels_proba.T[0],
                             isdead, nbdays,
                             seed=self.seed,
                             use_r_packages=self.use_r_packages,
                             metadata_mat=metadata_mat,
                             isfactor=False)

        if not self._isboosting:
            self._write_labels(self.dataset.sample_ids, self.labels,
                               labels_proba=self.labels_proba.T[0],
                               fname='{0}_training_set_labels'.format(self.project_name))

        if self.verbose:
            print('Cox-PH p-value (Log-Rank) for the cluster labels: {0}'.format(pvalue))

        self.train_pvalue = pvalue
        self.train_pvalue_proba = pvalue_proba