Gutenberg Children Books 2019-02-20

LG-E-clean corpus, ALE clustering, 2000/1000/500/50/20 clusters, server 88...
trash filter off, min_word_count = 1, max_sentence_length' = 15

This notebook is shared as static GCB-LG-E-clean-ALE-MWC=1-MSL=15-2019-02-20.html.
Output data shared via GCB-LG-E-clean-ALE-MWC=1-MSL=15-2019-02-20 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)
2019-02-20 09:55:41 UTC :: module_path: /home/obaskov/language-learning

Corpus test settings

In [2]:
corpus = 'GCB' # 'Gutenberg-Children-Books' 
dataset = 'LG-E-clean'
kwargs = {
    'max_sentence_length'   :   15  ,
    'max_unparsed_words'    :   0   ,
    'left_wall'     :   ''          ,
    'period'        :   False       ,
    'context'       :   1           ,
    'min_word_count':   1           ,
    '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'    :   []          ,
    '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
out_dir = module_path + '/output/' + 'GCB-LG-E-clean-ALE-MWC=1-MSL=15-' + str(UTC())[:10]
print(UTC(), '\n', out_dir)
2019-02-20 09:55:41 UTC 
 /home/obaskov/language-learning/output/GCB-LG-E-clean-ALE-MWC=1-MSL=15-2019-02-20

Tests: min_word_count = 1; 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-cleancALWEdwardeuclideannone---20001---0.053%48%0.53[3175, 506, 330, 319, 316]
Cleaned dictionary: 18825 words, grammar learn time: 01:36:20, grammar test time: 00:36:43
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-cleancALWEdwardeuclideannone---10001---0.055%48%0.54[3604, 616, 506, 499, 370]
Cleaned dictionary: 18825 words, grammar learn time: 01:15:01, grammar test time: 00:36:20
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-cleancALWEdwardeuclideannone---5001---0.058%50%0.56[4750, 987, 624, 557, 531]
Cleaned dictionary: 18825 words, grammar learn time: 01:13:11, grammar test time: 00:40:18
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-cleancALWEdwardeuclideannone---501---0.090%59%0.6[11129, 3002, 1554, 833, 585]
Cleaned dictionary: 18825 words, grammar learn time: 01:08:41, grammar test time: 02:09:49
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-cleancALWEdwardeuclideannone---201---0.090%51%0.5[15685, 1577, 1138, 282, 98]
Cleaned dictionary: 18825 words, grammar learn time: 01:08:05, grammar test time: 30:50:55

Save results

In [17]:
display(html_table([header] + table))
CellCorpusParsingSpaceLinkageAffinityG12nThresholdRulesMWCNNSIPAPQF1Top 5 cluster sizes
ALE2000GCBLG-E-cleancALWEdwardeuclideannone---20001---0.053%48%0.53[3175, 506, 330, 319, 316]
ALE1000GCBLG-E-cleancALWEdwardeuclideannone---10001---0.055%48%0.54[3604, 616, 506, 499, 370]
ALE500GCBLG-E-cleancALWEdwardeuclideannone---5001---0.058%50%0.56[4750, 987, 624, 557, 531]
ALE50GCBLG-E-cleancALWEdwardeuclideannone---501---0.090%59%0.6[11129, 3002, 1554, 833, 585]
ALE20GCBLG-E-cleancALWEdwardeuclideannone---201---0.090%51%0.5[15685, 1577, 1138, 282, 98]
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-22 03:11:09 UTC :: finished, elapsed 41.3 hours
Results saved to /home/obaskov/language-learning/output/GCB-LG-E-clean-ALE-MWC=1-MSL=15-2019-02-20/all_tests_table.txt