Gutenberg Children Books 2018-12-13_beta

500 clusters, min_word_count = 361, 21, 11, 2

Link Grammar 5.5.1, test_grammar updated 2018-10-19.
This notebook is shared as static Gutenberg-Children-Books-2018-12-13.html.
Output data shared via Gutenberg-Children-Books-2018-12-13 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, test_stats
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 [6]:
corpus = 'GCB' # 'Gutenberg-Children-Books-Caps'
dataset = 'LG-English'
kwargs = {
    'left_wall'     :   ''          ,
    'period'        :   False       ,
    'context'       :   1           ,
    'min_word_count':   31          ,   # 31/21/11/2
    'word_space'    :   'sparse'    ,
    'clustering'    :   ['agglomerative', 'ward'],
    'clustering_metric' : ['silhouette', 'cosine'],
    'cluster_range' :   500        ,
    '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/' + 'Gutenberg-Children-Books-Caps-' + str(UTC())[:10]
if check_corpus(rp, 'min'): print(UTC(), out_dir)
2018-12-13 14:06:10 UTC /home/obaskov/94/language-learning/output/Gutenberg-Children-Books-Caps-2018-12-13

Tests: "LG English", 500 clusters, min_word_count = 31/21/11/2/1

In [8]:
display(html_table([header] + a)); print(test_stats(log))
LineCorpusParsingSpaceLinkageAffinityG12nThresholdRulesMWCNNSIPAPQF1Top 5 cluster sizes
2.1GCBLG-EnglishcALWEdwardeuclideannone---50031---0.050%44%0.51[1002, 466, 437, 384, 381]
Cleaned dictionary: 7057 words, grammar learn time: 00:17:24, test time: 00:58:37 (h:m:s)
In [10]:
display(html_table([header] + a)); print(test_stats(log))
LineCorpusParsingSpaceLinkageAffinityG12nThresholdRulesMWCNNSIPAPQF1Top 5 cluster sizes
2.2GCBLG-EnglishcALWEdwardeuclideannone---50021---0.051%46%0.52[1028, 625, 620, 584, 551]
Cleaned dictionary: 8929 words, grammar learn time: 00:22:03, test time: 00:59:38 (h:m:s)
In [12]:
display(html_table([header] + a)); print(test_stats(log))
LineCorpusParsingSpaceLinkageAffinityG12nThresholdRulesMWCNNSIPAPQF1Top 5 cluster sizes
2.3GCBLG-EnglishcALWEdwardeuclideannone---50011---0.052%47%0.53[1096, 1028, 907, 848, 716]
Cleaned dictionary: 12790 words, grammar learn time: 00:39:21, test time: 01:01:41 (h:m:s)
In [15]:
display(html_table([header] + a)); print(test_stats(log))
LineCorpusParsingSpaceLinkageAffinityG12nThresholdRulesMWCNNSIPAPQF1Top 5 cluster sizes
2.4GCBLG-EnglishcALWEdwardeuclideannone---5002---0.054%48%0.54[5491, 3805, 3098, 1724, 964]
Cleaned dictionary: 31700 words, grammar learn time: 05:54:26, test time: 01:06:37 (h:m:s)
In [ ]:
%%capture
kwargs['min_word_count'] = 1
line = [[2.5, 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(test_stats(log))

Save results

In [16]:
display(html_table([header] + table))
LineCorpusParsingSpaceLinkageAffinityG12nThresholdRulesMWCNNSIPAPQF1Top 5 cluster sizes
2.1GCBLG-EnglishcALWEdwardeuclideannone---50031---0.050%44%0.51[1002, 466, 437, 384, 381]
2.2GCBLG-EnglishcALWEdwardeuclideannone---50021---0.051%46%0.52[1028, 625, 620, 584, 551]
2.3GCBLG-EnglishcALWEdwardeuclideannone---50011---0.052%47%0.53[1096, 1028, 907, 848, 716]
2.4GCBLG-EnglishcALWEdwardeuclideannone---5002---0.054%48%0.54[5491, 3805, 3098, 1724, 964]