POC-Turtle baseline test 2018-10-24

Agglomerative clustering, test_grammar updated 2018-10-19, Link Grammar 5.4.4; server 94.130.238.118.
poc-turtle-parses-gold.txt updated 2018-10-24. This notebook is shared as POC-Turtle-2018-10-24.html.
The "All tests" table is shared as 'short_table.txt' in POC-Turtle-2018-10-24 folder.
Previous (reference) tests: POC-Turtle-2018-10-21.html, POC-Turtle-2018-08-05.html.

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
from src.grammar_learner.read_files import check_dir
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
tmpath = module_path + '/tmp/'
check_dir(tmpath, True, 'none')
table = []
start = time.time()
print(UTC(), ':: module_path =', module_path)
2018-10-24 15:14:21 UTC :: module_path = /home/obaskov/94/language-learning

Grammar Learner corpus-specific parameters

In [2]:
corpus = 'POC-Turtle'
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       ,
    'context'       :   1           ,
    'word_space'    :   'vectors'   ,
    'clustering'    :   ('kmeans', 'kmeans++', 10),
    'cluster_range' :   (2,9,1,5),
    'grammar_rules' :   1           ,
    'tmpath'        :   tmpath      , 
    'template_path' :   'poc-turtle',
    'linkage_limit' :   1000        ,
    'verbose'       :   'min'       }
lines = [
    #[5, 'POC-Turtle'    , 'MST-fixed-2018-05-05'            , 0  , 0 , 'none'  ],
    [5, 'POC-Turtle'    , 'MST-fixed-manually'              , 0  , 0 , 'none'  ],
    [6, 'POC-Turtle'    , 'R=6-Weight=6:R-mst-weight=+1:R'  , 0  , 0 , 'none'  ],
    [7, 'POC-Turtle'    , 'R=6-Weight=1-no-mst-weighting'   , 0  , 0 , 'none'  ],
    [8, 'POC-Turtle'    , 'LG-ANY-all-parses'               , 0  , 0 , 'none'  ]]
# cp,rp :: (test) corpus_path and reference_path:
# cp = module_path + '/data/POC-Turtle/poc-turtle-corpus.txt'
# rp = module_path + '/data/POC-Turtle/MST-fixed-2018-05-05/poc-turtle-parses-gold.txt'
rp = module_path + '/data/POC-Turtle/MST-fixed-manually/poc-turtle-parses-gold.txt'
cp = rp

ULL Project Plan ⇒ Parses ⇒ lines 5-8

Connectors-DRK-Connectors

In [3]:
%%capture
kwargs['context'] = 1
kwargs['grammar_rules'] = 1
average21, _, header = table_rows(lines, out_dir, cp, rp, runs, **kwargs)
table.extend(average21)
In [4]:
display(html_table([header]+average21))
LineCorpusParsingLWRWGen.SpaceRulesSilhouettePAPQF1
5POC-TurtleMST-fixed-manually --- --- nonecDRKc40.75100%100%1.00
6POC-TurtleR=6-Weight=6:R-mst-weight=+1:R --- --- nonecDRKc40.56100%100%1.00
7POC-TurtleR=6-Weight=1-no-mst-weighting --- --- nonecDRKc70.467%0%0.00
8POC-TurtleLG-ANY-all-parses --- --- nonecDRKc40.59100%100%1.00

Connectors-DRK-Disjuncts

In [5]:
%%capture
kwargs['context'] = 1
kwargs['grammar_rules'] = 2
average22, _, header = table_rows(lines, out_dir, cp, rp, runs, **kwargs)
table.extend(average22)
In [6]:
display(html_table([header]+average22))
LineCorpusParsingLWRWGen.SpaceRulesSilhouettePAPQF1
5POC-TurtleMST-fixed-manually --- --- nonecDRKd40.75100%100%1.00
6POC-TurtleR=6-Weight=6:R-mst-weight=+1:R --- --- nonecDRKd40.56100%92%0.92
7POC-TurtleR=6-Weight=1-no-mst-weighting --- --- nonecDRKd70.4100%50%0.50
8POC-TurtleLG-ANY-all-parses --- --- nonecDRKd40.59100%100%1.00

Disjuncts-DRK-Disjuncts

In [7]:
%%capture
kwargs['context'] = 2
kwargs['grammar_rules'] = 2
average23, _, header = table_rows(lines, out_dir, cp, rp, runs, **kwargs)
table.extend(average23)
In [8]:
display(html_table([header]+average23))
LineCorpusParsingLWRWGen.SpaceRulesSilhouettePAPQF1
5POC-TurtleMST-fixed-manually --- --- nonedDRKd40.9100%100%1.00
6POC-TurtleR=6-Weight=6:R-mst-weight=+1:R --- --- nonedDRKd60.55100%92%0.92
7POC-TurtleR=6-Weight=1-no-mst-weighting --- --- nonedDRKdfail --- 0%0% ---
8POC-TurtleLG-ANY-all-parses --- --- nonedDRKd40.61100%96%0.96

Disjuncts-ILE-Disjuncts

In [9]:
%%capture
kwargs['context'] = 2
kwargs['word_space'] = 'discrete'
kwargs['clustering'] = 'group'
kwargs['grammar_rules'] = 2
average24, _, header = table_rows(lines, out_dir, cp, rp, runs, **kwargs)
table.extend(average24)
In [10]:
display(html_table([header]+average24))
LineCorpusParsingLWRWGen.SpaceRulesSilhouettePAPQF1
5POC-TurtleMST-fixed-manually --- --- nonedILEd6 --- 100%100%1.00
6POC-TurtleR=6-Weight=6:R-mst-weight=+1:R --- --- nonedILEd8 --- 100%92%0.92
7POC-TurtleR=6-Weight=1-no-mst-weighting --- --- nonedILEd11 --- 100%50%0.50
8POC-TurtleLG-ANY-all-parses --- --- nonedILEd8 --- 100%96%0.96

Disjuncts-ALE-disjuncts

In [11]:
%%capture
kwargs['context'] = 2
kwargs['cluster_range'] = (2,12,1,1)
kwargs['word_space'] = 'sparse'
kwargs['clustering'] = ('agglomerative', 'ward')
kwargs['clustering_metric'] = ('silhouette', 'cosine')
kwargs['grammar_rules'] = 2
average25, _, header = table_rows(lines, out_dir, cp, rp, runs, **kwargs)
table.extend(average25)
In [12]:
display(html_table([header]+average25))
LineCorpusParsingLWRWGen.SpaceRulesSilhouettePAPQF1
5POC-TurtleMST-fixed-manually --- --- nonedALEd60.85100%100%1.00
6POC-TurtleR=6-Weight=6:R-mst-weight=+1:R --- --- nonedALEd70.61100%92%0.92
7POC-TurtleR=6-Weight=1-no-mst-weighting --- --- nonedALEd70.31100%50%0.50
8POC-TurtleLG-ANY-all-parses --- --- nonedALEd60.62100%96%0.96

Connectors-ALE-disjuncts

In [13]:
%%capture
kwargs['context'] = 1
kwargs['grammar_rules'] = 2
average26, _, header = table_rows(lines, out_dir, cp, rp, runs, **kwargs)
table.extend(average26)
In [14]:
display(html_table([header]+average26))
LineCorpusParsingLWRWGen.SpaceRulesSilhouettePAPQF1
5POC-TurtleMST-fixed-manually --- --- nonecALEd60.85100%100%1.00
6POC-TurtleR=6-Weight=6:R-mst-weight=+1:R --- --- nonecALEd60.63100%92%0.92
7POC-TurtleR=6-Weight=1-no-mst-weighting --- --- nonecALEd60.44100%50%0.50
8POC-TurtleLG-ANY-all-parses --- --- nonecALEd50.65100%96%0.96

All tests

In [15]:
display(html_table([header] + table))
LineCorpusParsingLWRWGen.SpaceRulesSilhouettePAPQF1
5POC-TurtleMST-fixed-manually --- --- nonecDRKc40.75100%100%1.00
6POC-TurtleR=6-Weight=6:R-mst-weight=+1:R --- --- nonecDRKc40.56100%100%1.00
7POC-TurtleR=6-Weight=1-no-mst-weighting --- --- nonecDRKc70.467%0%0.00
8POC-TurtleLG-ANY-all-parses --- --- nonecDRKc40.59100%100%1.00
5POC-TurtleMST-fixed-manually --- --- nonecDRKd40.75100%100%1.00
6POC-TurtleR=6-Weight=6:R-mst-weight=+1:R --- --- nonecDRKd40.56100%92%0.92
7POC-TurtleR=6-Weight=1-no-mst-weighting --- --- nonecDRKd70.4100%50%0.50
8POC-TurtleLG-ANY-all-parses --- --- nonecDRKd40.59100%100%1.00
5POC-TurtleMST-fixed-manually --- --- nonedDRKd40.9100%100%1.00
6POC-TurtleR=6-Weight=6:R-mst-weight=+1:R --- --- nonedDRKd60.55100%92%0.92
7POC-TurtleR=6-Weight=1-no-mst-weighting --- --- nonedDRKdfail --- 0%0% ---
8POC-TurtleLG-ANY-all-parses --- --- nonedDRKd40.61100%96%0.96
5POC-TurtleMST-fixed-manually --- --- nonedILEd6 --- 100%100%1.00
6POC-TurtleR=6-Weight=6:R-mst-weight=+1:R --- --- nonedILEd8 --- 100%92%0.92
7POC-TurtleR=6-Weight=1-no-mst-weighting --- --- nonedILEd11 --- 100%50%0.50
8POC-TurtleLG-ANY-all-parses --- --- nonedILEd8 --- 100%96%0.96
5POC-TurtleMST-fixed-manually --- --- nonedALEd60.85100%100%1.00
6POC-TurtleR=6-Weight=6:R-mst-weight=+1:R --- --- nonedALEd70.61100%92%0.92
7POC-TurtleR=6-Weight=1-no-mst-weighting --- --- nonedALEd70.31100%50%0.50
8POC-TurtleLG-ANY-all-parses --- --- nonedALEd60.62100%96%0.96
5POC-TurtleMST-fixed-manually --- --- nonecALEd60.85100%100%1.00
6POC-TurtleR=6-Weight=6:R-mst-weight=+1:R --- --- nonecALEd60.63100%92%0.92
7POC-TurtleR=6-Weight=1-no-mst-weighting --- --- nonecALEd60.44100%50%0.50
8POC-TurtleLG-ANY-all-parses --- --- nonecALEd50.65100%96%0.96
In [16]:
table_str = list2file(table, out_dir+'/all_tests_table.txt')
print(UTC(), ':: finished, elapsed', str(round((time.time()-start))), 
      'seconds.  Results saved to\n', out_dir + '/all_tests_table.txt')
2018-10-24 15:14:32 UTC :: finished, elapsed 11 seconds.  Results saved to
 /home/obaskov/94/language-learning/output/POC-Turtle-2018-10-24/all_tests_table.txt