Fix for handling very small floating point numbers
This commit is contained in:
parent
907c3c0567
commit
e90bfd3979
|
@ -1,5 +1,5 @@
|
||||||
from pandas import concat, DataFrame, read_csv
|
from pandas import concat, DataFrame, read_csv
|
||||||
from numpy import ndarray, zeros
|
from numpy import ndarray, zeros, clip
|
||||||
from os import path, remove
|
from os import path, remove
|
||||||
from pickle import load, dump
|
from pickle import load, dump
|
||||||
from ast import literal_eval
|
from ast import literal_eval
|
||||||
|
@ -77,7 +77,7 @@ def signal_clustering(corr_matrix: DataFrame,
|
||||||
corr_matrix.where(corr_matrix > 0, 0, inplace=True)
|
corr_matrix.where(corr_matrix > 0, 0, inplace=True)
|
||||||
corr_matrix = 1 - corr_matrix
|
corr_matrix = 1 - corr_matrix
|
||||||
X = corr_matrix.values # type: ndarray
|
X = corr_matrix.values # type: ndarray
|
||||||
Y = ssd.squareform(X)
|
Y = clip(ssd.squareform(X), 0, None)
|
||||||
# Z is the linkage matrix. This can serve as input to the scipy.cluster.hierarchy.dendrogram method
|
# Z is the linkage matrix. This can serve as input to the scipy.cluster.hierarchy.dendrogram method
|
||||||
Z = linkage(Y, method='single', optimal_ordering=True)
|
Z = linkage(Y, method='single', optimal_ordering=True)
|
||||||
fclus = fcluster(Z, t=threshold, criterion='distance')
|
fclus = fcluster(Z, t=threshold, criterion='distance')
|
||||||
|
|
Loading…
Reference in New Issue