Пример #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_steps():
    steps = [('embedding', ts.SingleTakensEmbedding()),
             ('window', ts.SlidingWindow(size=6, stride=1)),
             ('diagram', hl.VietorisRipsPersistence()),
             ('rescaler', diag.Scaler()),
             ('filter', diag.Filtering(epsilon=0.1)),
             ('entropy', diag.PersistenceEntropy(nan_fill_value=0.)),
             ('scaling', skprep.MinMaxScaler(copy=True))]
    return steps
Пример #3
0
def get_diag2(diagramas):
    homology_dimensions = (0, 1)
    #Vietoris Rips filter applied
    VR = hl.VietorisRipsPersistence(homology_dimensions = [0,1], n_jobs=1)

    diagrams = VR.fit_transform(diagramas)

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

    diagramas.append(diagrams)


    return diagramas
Пример #4
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