Gutenberg Children Books 2018-12-23_beta

ULLPP Line 53: LGE-clean corpus, min_word_count = 2; 2000/1000/500/50 clusters

Link Grammar 5.5.1, test_grammar updated 2018-10-19.
This notebook is shared as static Gutenberg-Children-Books-2018-12-23.html.
Output data shared via Gutenberg-Children-Books-2018-12-23 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)
2018-12-23 16:03:59 UTC :: module_path: /home/obaskov/94/language-learning

Corpus test settings

In [2]:
corpus = 'GCB' # 'Gutenberg-Children-Books-Caps' 
dataset = 'LG-E-clean'
kwargs = {
    'left_wall'     :   ''          ,
    'period'        :   False       ,
    'context'       :   1           ,
    'min_word_count':   2           ,
    'word_space'    :   'sparse'    ,
    'clustering'    :   ['agglomerative', 'ward'],
    'clustering_metric' : ['silhouette', 'cosine'],
    'cluster_range' :   2000        ,   # 2000/1000/500/50/20
    'top_level'     :   0.01        ,
    'grammar_rules' :   2           ,
    'max_disjuncts' :   1000000     ,   # off
    'tmpath'        :   tmpath      , 
    'verbose'       :   'log+'       ,
    '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-LG-E-clean-' + str(UTC())[:10]
if check_corpus(rp, 'min'): print(UTC(), '\n', out_dir)
2018-12-23 16:03:59 UTC 
 /home/obaskov/94/language-learning/output/Gutenberg-Children-LG-E-clean-2018-12-23

Tests: min_word_count = 2; 2000/1000/500/50/20 clusters

In [4]:
display(html_table([header] + a)); print(test_stats(log))
CellCorpusParsingSpaceLinkageAffinityG12nThresholdRulesMWCNNSIPAPQF1Top 5 cluster sizes
ALE2000GCBLG-E-cleancALWEdwardeuclideannone---20002---0.046%45%0.50[1929, 791, 463, 392, 387]
Cleaned dictionary: 21859 words, grammar learn time: 02:28:26, test time: 00:29:09 (hh:mm:ss)
In [6]:
display(html_table([header] + a)); print(test_stats(log))
CellCorpusParsingSpaceLinkageAffinityG12nThresholdRulesMWCNNSIPAPQF1Top 5 cluster sizes
ALE1000GCBLG-E-cleancALWEdwardeuclideannone---10002---0.048%45%0.51[2831, 1497, 620, 577, 505]
Cleaned dictionary: 21859 words, grammar learn time: 02:08:16, test time: 00:28:48 (hh:mm:ss)
In [8]:
display(html_table([header] + a)); print(test_stats(log))
CellCorpusParsingSpaceLinkageAffinityG12nThresholdRulesMWCNNSIPAPQF1Top 5 cluster sizes
ALE500GCBLG-E-cleancALWEdwardeuclideannone---5002---0.050%47%0.52[2975, 2423, 1781, 672, 594]
Cleaned dictionary: 21859 words, grammar learn time: 02:01:04, test time: 00:30:08 (hh:mm:ss)
In [12]:
display(html_table([header] + a)); print(test_stats(log))
CellCorpusParsingSpaceLinkageAffinityG12nThresholdRulesMWCNNSIPAPQF1Top 5 cluster sizes
ALE50GCBLG-E-cleancALWEdwardeuclideannone---502---0.064%44%0.45[17132, 1817, 680, 565, 486]
Cleaned dictionary: 21859 words, grammar learn time: 01:55:51, test time: 01:43:12 (hh:mm:ss)
In [ ]:
%%capture
kwargs['cluster_range'] = 20
line = [['ALE20', corpus, dataset, 0, 0, 'none']]
a, _, h, 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 [13]:
display(html_table([header] + table))
CellCorpusParsingSpaceLinkageAffinityG12nThresholdRulesMWCNNSIPAPQF1Top 5 cluster sizes
ALE2000GCBLG-E-cleancALWEdwardeuclideannone---20002---0.046%45%0.50[1929, 791, 463, 392, 387]
ALE1000GCBLG-E-cleancALWEdwardeuclideannone---10002---0.048%45%0.51[2831, 1497, 620, 577, 505]
ALE500GCBLG-E-cleancALWEdwardeuclideannone---5002---0.050%47%0.52[2975, 2423, 1781, 672, 594]
ALE50GCBLG-E-cleancALWEdwardeuclideannone---502---0.064%44%0.45[17132, 1817, 680, 565, 486]
In [ ]:
print(UTC(), ':: finished, elapsed', str(round((time.time()-start)/3600.0, 1)), 'hours')
table_str = list2file(table, out_dir + '/all_tests_table.txt')
print('Results saved to', out_dir + '/all_tests_table.txt')