POC-English-NoAmb tests 2018-08-09

Updated optimal clustering search (2018-08-05), server 94.130.238.118
Each line is calculated 1x, parsing metrics tested 1x for each calculation.
The calculation table is shared as 'short_table.txt' in data folder
http://langlearn.singularitynet.io/data/clustering_2018/POC-English-NoAmb-2018-08-09/
This notebook is shared as static html via
http://langlearn.singularitynet.io/data/clustering_2018/html/POC-English-NoAmb-2018-08-09.html
Results consistency test is shared via
http://langlearn.singularitynet.io/data/clustering_2018/html/POC-English-NoAmb-2018-08-09-multi.html

Basic settings

In [1]:
import os, sys, time
from IPython.display import display
module_path = os.path.abspath(os.path.join('..'))
if module_path not in sys.path: 
    sys.path.append(module_path)
grammar_learner_path = module_path + '/src/grammar_learner/'
if os.path.exists(grammar_learner_path) and grammar_learner_path not in sys.path: 
    sys.path.append(grammar_learner_path)
from utl import UTC
from read_files import check_dir
from widgets import html_table
from pqa_table import table_cds
tmpath = module_path + '/tmp/'
if check_dir(tmpath, True, 'none'):
    table = []
    long_table = []
    header = ['Line','Corpus','Parsing','LW','"."','Generalization','Space','Rules','PA','PQ']
    start = time.time()
    print(UTC(), ':: module_path =', module_path)
else: print(UTC(), ':: could not create temporary files directory', tmpath)
2018-08-09 08:55:13 UTC :: module_path = /home/obaskov/language-learning

Grammar Learner corpus-specific parameters

In [2]:
corpus = 'POC-English-NoAmb'
out_dir = module_path + '/output/'+ corpus + '-' + str(UTC())[:10]
runs = (1,1)    # (attempts to learn grammar per line, grammar tests per attempt)
if runs != (1,1): out_dir += '-multi'
kwargs = {
    'left_wall'     :   ''          ,
    'period'        :   False       ,
    'word_space'    :   'vectors'   ,
    'cluster_range' :   (2,50,9)    ,
    'clustering'    :   ('kmeans', 'kmeans++', 18),
    'tmpath'        :   tmpath      , 
    'verbose'       :   'max'       ,
    'template_path' :   'poc-turtle',
    'linkage_limit' :   1000         ,
    'categories_generalization': 'off' }
lines = [
    [14, 'POC-English-NoAmb', 'MST-fixed-manually'              ,'LW','.', 'none' ],
    [15, 'POC-English-NoAmb', 'MST-fixed-manually'              , 0  , 0 , 'none' ],
    [16, 'POC-English-NoAmb', 'LG-English'                      ,'LW','.', 'none' ],
    [17, 'POC-English-NoAmb', 'LG-English'                      , 0  , 0 , 'none' ],
    [18, 'POC-English-NoAmb', 'R=6-Weight=6:R-mst-weight=+1:R'  ,'LW','.', 'none' ],
    [19, 'POC-English-NoAmb', 'R=6-Weight=6:R-mst-weight=+1:R'  , 0  , 0 , 'none' ],
    [20, 'POC-English-NoAmb', 'R=6-Weight=1-mst-weight=+1:R'    ,'LW','.', 'none' ], 
    [21, 'POC-English-NoAmb', 'R=6-Weight=1-mst-weight=+1:R'    , 0  , 0 , 'none' ], 
    [22, 'POC-English-NoAmb', 'LG-ANY-mst-weight=+1:R'          ,'LW','.', 'none' ],
    [23, 'POC-English-NoAmb', 'LG-ANY-mst-weight=+1:R'          , 0  , 0 , 'none' ]]
# cp,rp :: (test) corpus_path and reference_path
cp = module_path + '/data/POC-English-NoAmb/poc_english_noamb_corpus.txt'
rp = module_path + '/data/POC-English-NoAmb/poc-english_noAmb-parses-gold.txt'
#cp = rp  # July 2018 Grammar Tester option

ULL Project Plan ⇒ Parses ⇒ lines 13-17

Connectors-DRK-Connectors

In [3]:
%%capture
kwargs['context'] = 1
kwargs['word_space'] = 'vectors'
kwargs['clustering'] = ('kmeans','kmeans++',18)
kwargs['cluster_range'] = (2,50,9)
kwargs['grammar_rules'] = 1
average21, long21 = table_cds(lines, out_dir, cp, rp, runs, **kwargs)
table.extend(average21)
long_table.extend(long21)
In [4]:
display(html_table([header]+average21))
LineCorpusParsingLW"."GeneralizationSpaceRulesPAPQ
14POC-English-NoAmbMST-fixed-manuallyLW + nonecDRKc1164%55%
15POC-English-NoAmbMST-fixed-manually -- -- nonecDRKc872%64%
16POC-English-NoAmbLG-EnglishLW + nonecDRKc1268%55%
17POC-English-NoAmbLG-English -- -- nonecDRKc1175%64%
18POC-English-NoAmbR=6-Weight=6:R-mst-weight=+1:RLW + nonecDRKc1092%56%
19POC-English-NoAmbR=6-Weight=6:R-mst-weight=+1:R -- -- nonecDRKc999%65%
20POC-English-NoAmbR=6-Weight=1-mst-weight=+1:RLW + nonecDRKc2490%58%
21POC-English-NoAmbR=6-Weight=1-mst-weight=+1:R -- -- nonecDRKc2290%55%
22POC-English-NoAmbLG-ANY-mst-weight=+1:RLW + nonecDRKc1098%64%
23POC-English-NoAmbLG-ANY-mst-weight=+1:R -- -- nonecDRKc999%65%

Connectors-DRK-Disjuncts

In [5]:
%%capture
kwargs['context'] = 1
kwargs['word_space'] = 'vectors'
kwargs['clustering'] = ('kmeans','kmeans++',18)
kwargs['cluster_range'] = (2,50,9)
kwargs['grammar_rules'] = 2
average22, long22 = table_cds(lines, out_dir, cp, rp, runs, **kwargs)
table.extend(average22)
long_table.extend(long22)
In [6]:
display(html_table([header]+average22))
LineCorpusParsingLW"."GeneralizationSpaceRulesPAPQ
14POC-English-NoAmbMST-fixed-manuallyLW + nonecDRKd100%0%
15POC-English-NoAmbMST-fixed-manually -- -- nonecDRKd8100%100%
16POC-English-NoAmbLG-EnglishLW + nonecDRKd130%0%
17POC-English-NoAmbLG-English -- -- nonecDRKd1146%39%
18POC-English-NoAmbR=6-Weight=6:R-mst-weight=+1:RLW + nonecDRKd10100%68%
19POC-English-NoAmbR=6-Weight=6:R-mst-weight=+1:R -- -- nonecDRKd9100%66%
20POC-English-NoAmbR=6-Weight=1-mst-weight=+1:RLW + nonecDRKd2470%46%
21POC-English-NoAmbR=6-Weight=1-mst-weight=+1:R -- -- nonecDRKd2281%57%
22POC-English-NoAmbLG-ANY-mst-weight=+1:RLW + nonecDRKd1095%57%
23POC-English-NoAmbLG-ANY-mst-weight=+1:R -- -- nonecDRKd9100%60%

Disjuncts-DRK-Disjuncts

In [7]:
%%capture
kwargs['context'] = 2
kwargs['word_space'] = 'vectors'
kwargs['clustering'] = ('kmeans','kmeans++',18)
kwargs['cluster_range'] = (2,50,9)
kwargs['grammar_rules'] = 2
average23, long23 = table_cds(lines, out_dir, cp, rp, runs, **kwargs)
table.extend(average23)
long_table.extend(long23)
In [8]:
display(html_table([header]+average23))
LineCorpusParsingLW"."GeneralizationSpaceRulesPAPQ
14POC-English-NoAmbMST-fixed-manuallyLW + nonedDRKd130%0%
15POC-English-NoAmbMST-fixed-manually -- -- nonedDRKd1246%39%
16POC-English-NoAmbLG-EnglishLW + nonedDRKd140%0%
17POC-English-NoAmbLG-English -- -- nonedDRKd1246%39%
18POC-English-NoAmbR=6-Weight=6:R-mst-weight=+1:RLW + nonedDRKd1693%58%
19POC-English-NoAmbR=6-Weight=6:R-mst-weight=+1:R -- -- nonedDRKd12100%68%
20POC-English-NoAmbR=6-Weight=1-mst-weight=+1:RLW + nonedDRKd2765%40%
21POC-English-NoAmbR=6-Weight=1-mst-weight=+1:R -- -- nonedDRKd1079%52%
22POC-English-NoAmbLG-ANY-mst-weight=+1:RLW + nonedDRKd1694%58%
23POC-English-NoAmbLG-ANY-mst-weight=+1:R -- -- nonedDRKd1497%62%

Disjuncts-ILE-Disjuncts

In [9]:
%%capture
kwargs['context'] = 2
kwargs['word_space'] = 'discrete'
kwargs['clustering'] = 'group'
kwargs['grammar_rules'] = 2
average24, long24 = table_cds(lines, out_dir, cp, rp, runs, **kwargs)
table.extend(average24)
long_table.extend(long24)
In [10]:
display(html_table([header]+average24))
LineCorpusParsingLW"."GeneralizationSpaceRulesPAPQ
14POC-English-NoAmbMST-fixed-manuallyLW + nonedILEd150%0%
15POC-English-NoAmbMST-fixed-manually -- -- nonedILEd1346%39%
16POC-English-NoAmbLG-EnglishLW + nonedILEd150%0%
17POC-English-NoAmbLG-English -- -- nonedILEd1346%39%
18POC-English-NoAmbR=6-Weight=6:R-mst-weight=+1:RLW + nonedILEd1693%58%
19POC-English-NoAmbR=6-Weight=6:R-mst-weight=+1:R -- -- nonedILEd14100%68%
20POC-English-NoAmbR=6-Weight=1-mst-weight=+1:RLW + nonedILEd4463%39%
21POC-English-NoAmbR=6-Weight=1-mst-weight=+1:R -- -- nonedILEd4272%50%
22POC-English-NoAmbLG-ANY-mst-weight=+1:RLW + nonedILEd1694%58%
23POC-English-NoAmbLG-ANY-mst-weight=+1:R -- -- nonedILEd1497%62%

All tests (all entries for multi-test runs > (1.1))

In [11]:
display(html_table([header]+long_table))
LineCorpusParsingLW"."GeneralizationSpaceRulesPAPQ
14POC-English-NoAmbMST-fixed-manuallyLW + nonecDRKc 11 64%55%
15POC-English-NoAmbMST-fixed-manually -- -- nonecDRKc 8 72%64%
16POC-English-NoAmbLG-EnglishLW + nonecDRKc 12 68%55%
17POC-English-NoAmbLG-English -- -- nonecDRKc 11 75%64%
18POC-English-NoAmbR=6-Weight=6:R-mst-weight=+1:RLW + nonecDRKc 10 92%56%
19POC-English-NoAmbR=6-Weight=6:R-mst-weight=+1:R -- -- nonecDRKc 9 99%65%
20POC-English-NoAmbR=6-Weight=1-mst-weight=+1:RLW + nonecDRKc 24 90%58%
21POC-English-NoAmbR=6-Weight=1-mst-weight=+1:R -- -- nonecDRKc 22 90%55%
22POC-English-NoAmbLG-ANY-mst-weight=+1:RLW + nonecDRKc 10 98%64%
23POC-English-NoAmbLG-ANY-mst-weight=+1:R -- -- nonecDRKc 9 99%65%
14POC-English-NoAmbMST-fixed-manuallyLW + nonecDRKd 10 0%0%
15POC-English-NoAmbMST-fixed-manually -- -- nonecDRKd 8 100%100%
16POC-English-NoAmbLG-EnglishLW + nonecDRKd 13 0%0%
17POC-English-NoAmbLG-English -- -- nonecDRKd 11 46%39%
18POC-English-NoAmbR=6-Weight=6:R-mst-weight=+1:RLW + nonecDRKd 10 100%68%
19POC-English-NoAmbR=6-Weight=6:R-mst-weight=+1:R -- -- nonecDRKd 9 100%66%
20POC-English-NoAmbR=6-Weight=1-mst-weight=+1:RLW + nonecDRKd 24 70%46%
21POC-English-NoAmbR=6-Weight=1-mst-weight=+1:R -- -- nonecDRKd 22 81%57%
22POC-English-NoAmbLG-ANY-mst-weight=+1:RLW + nonecDRKd 10 95%57%
23POC-English-NoAmbLG-ANY-mst-weight=+1:R -- -- nonecDRKd 9 100%60%
14POC-English-NoAmbMST-fixed-manuallyLW + nonedDRKd 13 0%0%
15POC-English-NoAmbMST-fixed-manually -- -- nonedDRKd 12 46%39%
16POC-English-NoAmbLG-EnglishLW + nonedDRKd 14 0%0%
17POC-English-NoAmbLG-English -- -- nonedDRKd 12 46%39%
18POC-English-NoAmbR=6-Weight=6:R-mst-weight=+1:RLW + nonedDRKd 16 93%58%
19POC-English-NoAmbR=6-Weight=6:R-mst-weight=+1:R -- -- nonedDRKd 12 100%68%
20POC-English-NoAmbR=6-Weight=1-mst-weight=+1:RLW + nonedDRKd 27 65%40%
21POC-English-NoAmbR=6-Weight=1-mst-weight=+1:R -- -- nonedDRKd 10 79%52%
22POC-English-NoAmbLG-ANY-mst-weight=+1:RLW + nonedDRKd 16 94%58%
23POC-English-NoAmbLG-ANY-mst-weight=+1:R -- -- nonedDRKd 14 97%62%
14POC-English-NoAmbMST-fixed-manuallyLW + nonedILEd 15 0%0%
15POC-English-NoAmbMST-fixed-manually -- -- nonedILEd 13 46%39%
16POC-English-NoAmbLG-EnglishLW + nonedILEd 15 0%0%
17POC-English-NoAmbLG-English -- -- nonedILEd 13 46%39%
18POC-English-NoAmbR=6-Weight=6:R-mst-weight=+1:RLW + nonedILEd 16 93%58%
19POC-English-NoAmbR=6-Weight=6:R-mst-weight=+1:R -- -- nonedILEd 14 100%68%
20POC-English-NoAmbR=6-Weight=1-mst-weight=+1:RLW + nonedILEd 44 63%39%
21POC-English-NoAmbR=6-Weight=1-mst-weight=+1:R -- -- nonedILEd 42 72%50%
22POC-English-NoAmbLG-ANY-mst-weight=+1:RLW + nonedILEd 16 94%58%
23POC-English-NoAmbLG-ANY-mst-weight=+1:R -- -- nonedILEd 14 97%62%
In [12]:
from write_files import list2file
print(UTC(), ':: finished, elapsed', str(round((time.time()-start)/60, 1)), 'min')
table_str = list2file(table, out_dir+'/short_table.txt')
if runs == (1,1):
    print('Results saved to', out_dir + '/short_table.txt')
else:
    long_table_str = list2file(long_table, out_dir+'/long_table.txt')
    print('Average results saved to', out_dir + '/short_table.txt\n'
          'Detailed results for every run saved to', out_dir + '/long_table.txt')
2018-08-09 09:23:17 UTC :: finished, elapsed 28.1 min
Results saved to /home/obaskov/language-learning/output/POC-English-NoAmb-2018-08-09/short_table.txt