Fix for handling very small floating point numbers

This commit is contained in:
JoshuaArking 2019-08-29 09:56:22 -04:00
parent 907c3c0567
commit e90bfd3979
1 changed files with 2 additions and 2 deletions

View File

@ -1,5 +1,5 @@
from pandas import concat, DataFrame, read_csv
from numpy import ndarray, zeros
from numpy import ndarray, zeros, clip
from os import path, remove
from pickle import load, dump
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 = 1 - corr_matrix
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 = linkage(Y, method='single', optimal_ordering=True)
fclus = fcluster(Z, t=threshold, criterion='distance')