示例#1
0
def get_diag(embbeded, diagramas):
    homology_dimensions = (0, 1)
    VR = hl.VietorisRipsPersistence(homology_dimensions=[0, 1], n_jobs=1)

    sliding_window = ts.SlidingWindow(embbeded.shape[1] - 1, 4)
    embedded_window = sliding_window.fit_transform(embbeded.T)
    #sliding_window3 = ts.SlidingWindow(embbeded3.shape[1] - 1, 4)
    #embedded_window3 = sliding_window3.fit_transform(embbeded3.T)
    diagrams = VR.fit_transform(embedded_window)
    #diagrams3 = VR.fit_transform(embedded_window3)

    diagrams = diagrams[:, :, :-1]
    #diagrams3 = diagrams3[:, :, :-1]
    diagrams = [clean_ceros(item) for item in diagrams]

    #diagrams3 = [clean_ceros(item) for item in diagrams3]
    entropy = persistent_entropy.persistent_entropy(diagrams,
                                                    keep_inf=False,
                                                    val_inf=None,
                                                    normalize=False)
    #z = np.zeros((len(diagrams[0]), 1), dtype=int)

    #diagrams[0] = np.append(diagrams[0], z, 1)
    #diagrams = [list(diagrams[0][item]) for item in range(len(diagrams[0]))]

    diagramas.append(diagrams)
    #entropy3 = persistent_entropy.persistent_entropy(diagrams3, keep_inf=False, val_inf=None, normalize=False)
    entropy = pd.DataFrame(entropy)
    #entropy3 = pd.DataFrame(entropy3)
    return entropy, diagramas
示例#2
0
def get_diag(embbeded, diagramas):
    homology_dimensions = (0, 1)
    #Vietoris Rips filter applied
    VR = hl.VietorisRipsPersistence(homology_dimensions = [0,1], n_jobs=1)

    sliding_window = ts.SlidingWindow(embbeded.shape[1]-1, 4)
    embedded_window = sliding_window.fit_transform(embbeded.T)

    diagrams = VR.fit_transform(embedded_window)

    diagrams = diagrams[:, :, :-1]
    #clean ceros elements
    diagrams = [clean_ceros(item) for item in diagrams]

    entropy = persistent_entropy.persistent_entropy(diagrams, keep_inf=False, val_inf=None, normalize=False)

    diagramas.append(diagrams)

    entropy = pd.DataFrame(entropy)

    return entropy, diagramas
示例#3
0
 def test_one_diagram(self):
     dgm = np.array([[0,1],[0,3],[2,4]])
     p = pe.persistent_entropy(dgm)
     
     # An upper bound of persistent entropy is the logarithm of the number of bars.
     assert p < np.log(len(dgm))
示例#4
0
 def test_diagram_one_bar(self):
     dgm = np.array([[-1,2]])
     p = pe.persistent_entropy(dgm)
     assert all(p==0)
示例#5
0
 def test_diagrams_inf(self):
     dgms = [np.array([[0,1],[0,3],[2,4]]),np.array([[2,5],[3,8]]),np.array([[0,np.inf]])]
     p = pe.persistent_entropy(dgms, keep_inf = True, val_inf = 10)
     # An upper bound of persistent entropy is the logarithm of the number of bars.
     assert all(p < np.log(3))
示例#6
0
 def test_diagrams(self):
     dgms = [np.array([[0,1],[0,3],[2,4]]),np.array([[2,5],[3,8]]),np.array([[0,10]])]
     p = pe.persistent_entropy(dgms)
     # An upper bound of persistent entropy is the logarithm of the number of bars.
     assert all(p < np.log(3))