Skip to content

Commit e633e3a

Browse files
committed
z score data
1 parent a1f3ad8 commit e633e3a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/flowsom/models/consensus_cluster.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from itertools import combinations
1313

1414
import numpy as np
15+
from scipy.stats import zscore
1516
from sklearn.cluster import AgglomerativeClustering
1617

1718
from . import BaseClusterEstimator
@@ -62,6 +63,9 @@ def fit(self, data):
6263
Args:
6364
* data -> (examples,attributes) format
6465
"""
66+
# zscore and clip
67+
data = zscore(data, axis=0)
68+
data = np.clip(data, a_min=-3, a_max=3)
6569
Mk = np.zeros((data.shape[0], data.shape[0]))
6670
Is = np.zeros((data.shape[0],) * 2)
6771
for _ in range(self.H):
@@ -89,4 +93,6 @@ def fit(self, data):
8993

9094
def fit_predict(self, data):
9195
"""Predicts on the consensus matrix, for best found cluster number."""
96+
data = zscore(data, axis=0)
97+
data = np.clip(data, a_min=-3, a_max=3)
9298
return self.cluster(n_clusters=self.n_clusters, linkage=self.linkage).fit_predict(data)

0 commit comments

Comments
 (0)