ILE clustering "Gutenberg Children Books" 2019-03-25

"Gutenberg Children Books" corpus, new "LG-E-noQuotes" dataset (GC_LGEnglish_noQuotes_fullyParsed.ull),
trash filter off: min_word_count = 31,21,11,6,2,1; max_sentence_length off; Link Grammar 5.5.1
.

This notebook is shared as static ILE-GCB-LG-E-clean-2019-03-25.html.
Output data shared via Mean-shift-clustering-GCB-LG-E-noQuotes-2019-03-25 directory.
Compare results with Mean-shift-clustering-GCB-LG-E-clean-2019-02-20.html, data: Mean-shift-clustering-GCB-LG-E-clean-2019-02-20.

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-03-25 14:40:34 UTC :: module_path: /home/obaskov/94/language-learning

Corpus test settings

In [2]:
corpus = 'GCB' # 'Gutenberg-Children-Books-Caps' 
dataset = 'LG-E-noQuotes'  # 'LG-E-clean'
kwargs = {
    'left_wall'     :   ''          ,
    'period'        :   False       ,
    'context'       :   2           ,
    'min_word_count':   1           ,  # 11, 1
    'word_space'    :   'discrete'  ,  # 'sparse'    ,
    'clustering'    :   'group'     ,  # ('mean_shift', 2),
    'clustering_metric' : ['silhouette', 'cosine'],
    'cluster_range' :   [0]         ,   # auto
    '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-noQuotes/GC_LGEnglish_noQuotes_fullyParsed.ull'
cp = rp  # corpus path = reference_path
out_dir = module_path + '/output/' + 'ILE-GCB-LG-E-clean-' + str(UTC())[:10]
print(UTC(), '\n', out_dir)
2019-03-25 14:40:36 UTC 
 /home/obaskov/94/language-learning/output/ILE-GCB-LG-E-clean-2019-03-25

Tests: min_word_count = 31, 21, 11, 6, 2, 1

min_word_count = 31, 21, 11, 6

In [3]:
%%capture
table = []
line = [['', corpus, dataset, 0, 0, 'none']]
kwargs['min_word_count'] = 31
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))
LineCorpusParsingSpaceLinkageAffinityG12nThresholdRulesMWCNNSIPAPQF1Top 5 cluster sizes
GCBLG-E-noQuotesdILEdg---none---193631---0.053%46%0.56[1, 0]
grammar learn time: 01:36:04, grammar test time: 00:15:48
In [6]:
display(html_table([header] + a)); print(test_stats(log))
LineCorpusParsingSpaceLinkageAffinityG12nThresholdRulesMWCNNSIPAPQF1Top 5 cluster sizes
GCBLG-E-noQuotesdILEdg---none---266021---0.055%49%0.59[1, 0]
grammar learn time: 01:56:23, grammar test time: 00:17:03
In [8]:
display(html_table([header] + a)); print(test_stats(log))
LineCorpusParsingSpaceLinkageAffinityG12nThresholdRulesMWCNNSIPAPQF1Top 5 cluster sizes
GCBLG-E-noQuotesdILEdg---none---425311---0.059%54%0.63[1, 0]
grammar learn time: 02:39:58, grammar test time: 00:18:45
In [12]:
display(html_table([header] + a)); print(test_stats(log))
LineCorpusParsingSpaceLinkageAffinityG12nThresholdRulesMWCNNSIPAPQF1Top 5 cluster sizes
GCBLG-E-noQuotesdILEdg---none---65786---0.061%57%0.65[5, 1, 0]
grammar learn time: 03:47:45, grammar test time: 00:20:04
In [13]:
display(html_table([header] + table))
LineCorpusParsingSpaceLinkageAffinityG12nThresholdRulesMWCNNSIPAPQF1Top 5 cluster sizes
GCBLG-E-noQuotesdILEdg---none---193631---0.053%46%0.56[1, 0]
GCBLG-E-noQuotesdILEdg---none---266021---0.055%49%0.59[1, 0]
GCBLG-E-noQuotesdILEdg---none---425311---0.059%54%0.63[1, 0]
GCBLG-E-noQuotesdILEdg---none---65786---0.061%57%0.65[5, 1, 0]
In [14]:
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-03-26 02:03:59 UTC :: finished, elapsed 11.4 hours
Results saved to /home/obaskov/94/language-learning/output/ILE-GCB-LG-E-clean-2019-03-25/all_tests_table.txt

min_word_count = 2

In [ ]:
%%capture
kwargs['min_word_count'] = 2
a, _, h, log, rules = wide_rows(line, out_dir, cp, rp, runs, **kwargs)
table.extend(a)

ParserError: Process 'link-parser' terminated with exit code: 255 and error message: 'link-grammar: <...> Fatal error: Unable to open dictionary.
executed in 6h 16m 18s, finished 08:20:17 UTC 2019-03-26

min_word_count = 1

In [19]:
%%capture
kwargs['min_word_count'] = 1
a, _, h, log, rules = wide_rows(line, out_dir, cp, rp, runs, **kwargs)
table.extend(a)
In [20]:
display(html_table([header] + a)); print(test_stats(log))
LineCorpusParsingSpaceLinkageAffinityG12nThresholdRulesMWCNNSIPAPQF1Top 5 cluster sizes
GCBLG-E-noQuotesdILEdg---none---194321---0.062%60%0.65[419, 173, 170, 80, 67]
grammar learn time: 10:46:49, grammar test time: 00:25:32

Save results

In [21]:
display(html_table([header] + table))
LineCorpusParsingSpaceLinkageAffinityG12nThresholdRulesMWCNNSIPAPQF1Top 5 cluster sizes
GCBLG-E-noQuotesdILEdg---none---193631---0.053%46%0.56[1, 0]
GCBLG-E-noQuotesdILEdg---none---266021---0.055%49%0.59[1, 0]
GCBLG-E-noQuotesdILEdg---none---425311---0.059%54%0.63[1, 0]
GCBLG-E-noQuotesdILEdg---none---65786---0.061%57%0.65[5, 1, 0]
GCBLG-E-noQuotesdILEdg---none---194321---0.062%60%0.65[419, 173, 170, 80, 67]
In [22]:
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-03-26 20:10:54 UTC :: finished, elapsed 29.5 hours
Results saved to /home/obaskov/94/language-learning/output/ILE-GCB-LG-E-clean-2019-03-25/all_tests_table.txt