Gutenberg Children Books agglomerative clustering 2018-12-11_

Link Grammar 5.5.1, test_grammar updated 2018-10-19.
This notebook not is shared as static Gutenberg-Children-Books-2018-12-11.html.
Output data shared via Gutenberg-Children-Books-2018-12-11 directory.

Basic settings

In [1]:
import os, sys, time
module_path = os.path.abspath(os.path.join('..'))
if module_path not in sys.path: sys.path.append(module_path)
from src.grammar_learner.utl import UTC
from src.grammar_learner.read_files import check_dir, check_corpus
from src.grammar_learner.write_files import list2file
from src.grammar_learner.widgets import html_table
from src.grammar_learner.pqa_table import table_rows, params, wide_rows
tmpath = module_path + '/tmp/'
check_dir(tmpath, True, 'none')
start = time.time()
runs = (1,1)
#print(UTC(), ':: module_path =', module_path)

Corpus test settings

In [2]:
corpus = 'GCB' # 2018-12-11 copy of 'Gutenberg-Children-Books-Caps'
dataset = 'LG-English'
kwargs = {
    'left_wall'     :   ''          ,
    'period'        :   False       ,
    'context'       :   1           ,
    'min_word_count':   11          ,
    'word_space'    :   'sparse'    ,
    'clustering'    :   ['agglomerative', 'ward'],
    'clustering_metric' : ['silhouette', 'cosine'],
    'cluster_range' :   3000        ,   # 3000, 5000, 7000, 10000
    'top_level'     :   0.01        ,
    'grammar_rules' :   2           ,
    'max_disjuncts' :   1000000     ,   # off
    'tmpath'        :   tmpath      , 
    'verbose'       :   'min'       ,
    'template_path' :   'poc-turtle',
    'linkage_limit' :   1000        }
rp = module_path + '/data/' + corpus + '/LG-E-clean/GCB-LG-English-clean.ull'
cp = rp  # corpus path = reference_path
runs = (1,1)
out_dir = module_path + '/output/' + corpus + '-' + str(UTC())[:10]
if check_corpus(rp, 'min'): print(UTC(), out_dir)
2018-12-11 07:44:07 UTC /home/obaskov/94/language-learning/output/GCB-2018-12-11

Tests: "LG English", min_word_count = 11, 3/5/7/10 Kclusters

In [8]:
display(html_table([header] + table)); print(UTC())
LineCorpusParsingSpaceLinkageAffinityG12nThresholdRulesMWCNNSIPAPQF1Top 5 cluster sizes
2.1GCBLG-EnglishcALWEdwardeuclideannone---300011---0.048%45%0.51[180, 161, 158, 148, 134]
2.2GCBLG-EnglishcALWEdwardeuclideannone---500011---0.048%45%0.51[132, 104, 77, 75, 74]
2.3GCBLG-EnglishcALWEdwardeuclideannone---700011---0.047%44%0.51[96, 45, 38, 37, 36]
2018-12-12 00:05:51 UTC

10,000 clusters -- still running (6+ hours)

In [ ]:
%%capture
kwargs['cluster_range'] = 10000
line = [[2.3, corpus, dataset, 0, 0, 'none']]
a, _, header, log, rules = wide_rows(line, out_dir, cp, rp, runs, **kwargs)
table.extend(a)
In [ ]:
display(html_table([header] + a)); print(UTC())