<jupyter_start><jupyter_text>Experiments 2:  1. Slider to fine tune parametres:<jupyter_code>from persistent.persistent import Persistent
import dionysus as dn
import matplotlib.pyplot as plt
from IPython.html.widgets import *
import numpy as np
from   matplotlib.colors import LogNorm, Normalize
%matplotlib inline
def pltpersist(min_count, window, size):
    
    plt.figure(figsize=(15, 10))
    
    bins = 200
    
    a = Persistent(path='texts/mashenka.txt', min_count=min_count, window=window, size=size)
    dgms = a.persistent()
    
    dgm = dgms[1]
    
    norm = LogNorm()

    inf = float('inf')
    min_birth = min(p.birth for p in dgm if p.birth != inf)
    #max_birth = max(p.birth for p in dgm if p.birth != inf)
    #min_death = min(p.death for p in dgm if p.death != inf)
    max_death = max(p.death for p in dgm if p.death != inf)

    plt.hist2d([p.birth for p in dgm if p.birth != inf and p.death != inf], 
               [p.death for p in dgm if p.birth != inf and p.death != inf], 
               bins = bins, norm = norm)
    
    plt.axes().set_aspect('equal', 'datalim')

    plt.plot([min_birth, max_death], [min_birth, max_death])        # diagonal

    ## clip the view
    #plt.axes().set_xlim([min_birth, max_birth])
    #plt.axes().set_ylim([min_death, max_death])

    plt.colorbar()
    
    print('calculated for min_c: {}, window: {}, size: {}'.format(min_count, window, size))

    plt.show()


interact(pltpersist, min_count=(1,100,1), window=(1,20,1), size=(0, 1000, 100));<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13583441138421734, 'fraction_numerical': 0.018111254851228976, 'mean_word_length': 3.169811320754717, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '78144', 'license': 'MIT', 'n_tokens_mistral': 626, 'n_tokens_neox': 555, 'n_words': 146, 'path': 'example2.ipynb', 'repo_name': 'alexeykosh/persistent_JA', 'size': '1546'}