Mean shift clustering "Gutenberg Children Books" 2019-02-20

"Gutenberg Children Books" corpus "LG-English-clean" dataset, ,
trash filter off: min_word_count = 31,21,11,6,2, max_sentence_length off, Link Grammar 5.5.1
.

This notebook is shared as static Mean-shift-clustering-GCB-LG-E-clean-2019-02-20.html.
Output data shared via Mean-shift-clustering-GCB-LG-E-clean-2019-02-20 directory.

Basic settings

In [19]:
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-22 02:21:30 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':   1           ,  # 11, 1
    'word_space'    :   'sparse'    ,
    'clustering'    :   ('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-clean/GCB-LG-English-clean.ull'
cp = rp  # corpus path = reference_path
out_dir = module_path + '/output/' + 'Mean-shift-clustering-GCB-LG-E-clean-2018-02-20' + str(UTC())[:10]
print(UTC(), '\n', out_dir)
2019-02-20 10:18:46 UTC 
 /home/obaskov/94/language-learning/output/Mean-shift-clustering-GCB-LG-E-clean-2018-02-202019-02-20

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

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-cleancMLEdmean_shift---none---407031---0.049%42%0.49[1, 0]
Cleaned dictionary: 4070 words, grammar learn time: 01:03:48, grammar test time: 00:34:45
In [5]:
%%capture
kwargs['min_word_count'] = 21
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))
LineCorpusParsingSpaceLinkageAffinityG12nThresholdRulesMWCNNSIPAPQF1Top 5 cluster sizes
GCBLG-E-cleancMLEdmean_shift---none---531621---0.050%43%0.5[2, 1, 0]
Cleaned dictionary: 5317 words, grammar learn time: 02:01:58, grammar test time: 00:36:04
In [7]:
%%capture
kwargs['min_word_count'] = 11
a, _, h, log, rules = wide_rows(line, out_dir, cp, rp, runs, **kwargs)
table.extend(a)
In [8]:
display(html_table([header] + a)); print(test_stats(log))
LineCorpusParsingSpaceLinkageAffinityG12nThresholdRulesMWCNNSIPAPQF1Top 5 cluster sizes
GCBLG-E-cleancMLEdmean_shift---none---793811---0.051%45%0.52[78, 6, 3, 2, 1]
Cleaned dictionary: 8035 words, grammar learn time: 04:46:25, grammar test time: 00:37:35
In [11]:
%%capture
kwargs['min_word_count'] = 6
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))
LineCorpusParsingSpaceLinkageAffinityG12nThresholdRulesMWCNNSIPAPQF1Top 5 cluster sizes
GCBLG-E-cleancMLEdmean_shift---none---100956---0.051%46%0.52[1426, 6, 5, 4, 3]
Cleaned dictionary: 11625 words, grammar learn time: 13:14:25, grammar test time: 00:39:12
In [26]:
%%capture
kwargs['min_word_count'] = 2
a, _, h, log, rules = wide_rows(line, out_dir, cp, rp, runs, **kwargs)
table.extend(a)
In [27]:
display(html_table([header] + a)); print(test_stats(log))
LineCorpusParsingSpaceLinkageAffinityG12nThresholdRulesMWCNNSIPAPQF1Top 5 cluster sizes
GCBLG-E-cleancMLEdmean_shift---none---93672---0.052%47%0.52[12452, 3, 2, 1, 0]
Cleaned dictionary: 21872 words, grammar learn time: 98:48:41, grammar test time: 00:37:11

Save results

In [28]:
display(html_table([header] + table))
LineCorpusParsingSpaceLinkageAffinityG12nThresholdRulesMWCNNSIPAPQF1Top 5 cluster sizes
GCBLG-E-cleancMLEdmean_shift---none---407031---0.049%42%0.49[1, 0]
GCBLG-E-cleancMLEdmean_shift---none---531621---0.050%43%0.5[2, 1, 0]
GCBLG-E-cleancMLEdmean_shift---none---793811---0.051%45%0.52[78, 6, 3, 2, 1]
GCBLG-E-cleancMLEdmean_shift---none---100956---0.051%46%0.52[1426, 6, 5, 4, 3]
GCBLG-E-cleancMLEdmean_shift---none---93672---0.052%47%0.52[12452, 3, 2, 1, 0]
In [29]:
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-26 15:10:56 UTC :: finished, elapsed 108.8 hours
Results saved to /home/obaskov/94/language-learning/output/Mean-shift-clustering-GCB-LG-E-clean-2018-02-202019-02-20/all_tests_table.txt

Results for "Gutenberg Children Books" corpus with min_word_count = 51, 11, 1 are shared as static Mean-shift-clustering-GCB-LG-E-clean-2019-02-18.html.