<jupyter_start><jupyter_text>Table of Contents1&nbsp;&nbsp;calculating ratio of fan OR blotch markings to ALL markings  calculating ratio of fan OR blotch markings to ALL markings<jupyter_code>from planet4 import io
db = io.DBManager()
db.dbname
image_ids = db.image_ids
len(image_ids)
chosen = np.random.choice(image_ids, 10000)
def get_fan_and_blotch_nunique_cids(data):
    f1 = data.marking == 'fan'
    f2 = data.marking == 'blotch'
    return data[f1 | f2].classification_id.nunique()
from ipyparallel import Client
c = Client()
lbview = c.load_balanced_view()
dview = c[:]
dview.push({'db': db,
            'get_fan_and_blotch_nunique_cids':get_fan_and_blotch_nunique_cids})
def get_ratio(image_id):
    data = db.get_image_id_markings(image_id)
    n_classifications = data.classification_id.nunique()
    n_class_fb = get_fan_and_blotch_nunique_cids(data)
    ratio = (n_class_fb / n_classifications)
    d = {'image_id':image_id, 'ratio':ratio}
    return d
results = lbview.map_async(get_ratio, chosen)
from nbtools import display_multi_progress
display_multi_progress(results, chosen)
df = pd.DataFrame(results.result())
%matplotlib inline
df.ratio.hist(bins=30)
import seaborn as sns
sns.distplot(df.ratio)
t0 = pd.Timestamp('2016-07-01 12:00:00')
delta = pd.Timedelta('114h')
t0 + delta<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10902255639097744, 'fraction_numerical': 0.02406015037593985, 'mean_word_length': 5.756345177664975, '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': '110403', 'license': '0BSD', 'n_tokens_mistral': 524, 'n_tokens_neox': 494, 'n_words': 100, 'path': 'notebooks/2016-07-04 Stats.ipynb', 'repo_name': 'CitizenScienceInAstronomyWorkshop/P4_sandbox', 'size': '1330'}