File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212from itertools import combinations
1313
1414import numpy as np
15+ from scipy .stats import zscore
1516from sklearn .cluster import AgglomerativeClustering
1617
1718from . 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 )
You can’t perform that action at this time.
0 commit comments