Gutenberg Children Books 2019-02-07

ULLPP Line 54: LG-English-5.5.1 corpus, trash filter off, min_word_count = 11; 2000/1000/500/50/20 clusters

Link Grammar 5.5.1, test_grammar updated 2019-01-23, server 88.99.210.144.
This notebook is shared as static Gutenberg-Children-Books-LG-E-551-MWC=11-2019-02-07.html.
The results are shared as 'all_tests_table.txt' in Gutenberg-Children-Books-LG-E-551-MWC=2-2019-02-07 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)

Corpus test settings

In [2]:
corpus = 'GCB' # 'Gutenberg-Children-Books-Caps' 
dataset = 'LG-E-551'  # parsed with Link Grammar v.5.5.1 2018-10-25
kwargs = {
    'left_wall'     :   ''          ,
    'period'        :   False       ,
    'context'       :   1           ,
    'min_word_count':   11          ,
    '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
    'stop_words'    :   []          ,   # allow any token
    '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-551-MWC=11-' + str(UTC())[:10]
if check_corpus(rp, 'min'): print(UTC(), '\n', out_dir)
2019-02-07 09:24:24 UTC 
 /home/obaskov/88/language-learning/output/Gutenberg-Children-LG-E-551-MWC=11-2019-02-07

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

In [3]:
%%capture
table = []
kwargs['cluster_range'] = 2000
line = [['ALE2000', corpus, dataset, 0, 0, 'none']]
a, _, header, log, rules = wide_rows(line, out_dir, cp, rp, runs, **kwargs)
header[0] = 'Cell'
table.extend(a)
In [4]:
display(html_table([header] + a)); print(test_stats(log))
CellCorpusParsingSpaceLinkageAffinityG12nThresholdRulesMWCNNSIPAPQF1Top 5 cluster sizes
ALE2000GCBLG-E-551cALWEdwardeuclideannone---200011---0.056%48%0.54[283, 267, 235, 205, 203]
Cleaned dictionary: 12872 words, grammar learn time: 01:14:35, grammar test time: 01:20:08
In [5]:
%%capture
kwargs['cluster_range'] = 1000
line = [['ALE1000', corpus, dataset, 0, 0, 'none']]
a, _, h, log, rules = wide_rows(line, out_dir, cp, rp, runs, **kwargs)
table.extend(a)
In [6]:
display(html_table([header] + a)); print(test_stats(log))
CellCorpusParsingSpaceLinkageAffinityG12nThresholdRulesMWCNNSIPAPQF1Top 5 cluster sizes
ALE1000GCBLG-E-551cALWEdwardeuclideannone---100011---0.058%49%0.55[660, 609, 604, 514, 389]
Cleaned dictionary: 12872 words, grammar learn time: 00:45:11, grammar test time: 01:16:18
In [7]:
%%capture
kwargs['cluster_range'] = 500
line = [['ALE500', corpus, dataset, 0, 0, 'none']]
a, _, header, log, rules = wide_rows(line, out_dir, cp, rp, runs, **kwargs)
header[0] = 'Cell'
table.extend(a)
In [8]:
display(html_table([header] + a)); print(test_stats(log))
CellCorpusParsingSpaceLinkageAffinityG12nThresholdRulesMWCNNSIPAPQF1Top 5 cluster sizes
ALE500GCBLG-E-551cALWEdwardeuclideannone---50011---0.061%51%0.56[1202, 1150, 642, 620, 609]
Cleaned dictionary: 12872 words, grammar learn time: 00:32:45, grammar test time: 01:17:39
In [11]:
%%capture
kwargs['cluster_range'] = 50
line = [['ALE50', corpus, dataset, 0, 0, 'none']]
a, _, h, log, rules = wide_rows(line, out_dir, cp, rp, runs, **kwargs)
table.extend(a)
In [12]:
display(html_table([header] + a)); print(test_stats(log))
CellCorpusParsingSpaceLinkageAffinityG12nThresholdRulesMWCNNSIPAPQF1Top 5 cluster sizes
ALE50GCBLG-E-551cALWEdwardeuclideannone---5011---0.089%55%0.56[4420, 3645, 1853, 884, 513]
Cleaned dictionary: 12872 words, grammar learn time: 00:21:52, grammar test time: 04:28:13
In [15]:
%%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 [16]:
display(html_table([header] + a)); print(test_stats(log))
CellCorpusParsingSpaceLinkageAffinityG12nThresholdRulesMWCNNSIPAPQF1Top 5 cluster sizes
ALE20GCBLG-E-551cALWEdwardeuclideannone---2011---0.090%47%0.47[8065, 2366, 884, 848, 467]
Cleaned dictionary: 12872 words, grammar learn time: 00:20:54, grammar test time: 96:55:14

Save results

In [17]:
display(html_table([header] + table))
CellCorpusParsingSpaceLinkageAffinityG12nThresholdRulesMWCNNSIPAPQF1Top 5 cluster sizes
ALE2000GCBLG-E-551cALWEdwardeuclideannone---200011---0.056%48%0.54[283, 267, 235, 205, 203]
ALE1000GCBLG-E-551cALWEdwardeuclideannone---100011---0.058%49%0.55[660, 609, 604, 514, 389]
ALE500GCBLG-E-551cALWEdwardeuclideannone---50011---0.061%51%0.56[1202, 1150, 642, 620, 609]
ALE50GCBLG-E-551cALWEdwardeuclideannone---5011---0.089%55%0.56[4420, 3645, 1853, 884, 513]
ALE20GCBLG-E-551cALWEdwardeuclideannone---2011---0.090%47%0.47[8065, 2366, 884, 848, 467]
In [18]:
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')
2019-02-11 21:57:21 UTC :: finished, elapsed 108.5 hours
Results saved to /home/obaskov/88/language-learning/output/Gutenberg-Children-LG-E-551-MWC=11-2019-02-07/all_tests_table.txt