Merge pull request #2 from JoshuaArking/master

Fix for very small floating point numbers causing ValueError
This commit is contained in:
brent-stone 2019-09-10 18:24:31 -05:00 committed by GitHub
commit 99f55ced91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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')