learning module

This module contains the Learning class

class learning.Learning(sample_instance)[source]

Bases: object

A learning instance

Example:
>>> from sp2learn import Learning, Sample
>>> train_file = '0.spice.train'
>>> pT = Sample(adr=train_file)
>>> S_app = Learning(sample_instance=pT)
  • Input:
Parameters:sample_instance (Sample) – a an instance of Sample

(nbL, nbEx, and dictionaries )

static BuildAutomatonFromHankel(lhankel, nbL, rank, sparse=False)[source]

Build an automaton from Hankel matrix

  • Input:
Parameters:
  • lhankel (list) – list of Hankel matrix
  • nbL (int) – the number of letters
  • rank (int) – the ranking number
  • sparse (boolean) – (default value = False) True if Hankel matrix is sparse
  • Output:
Returns:An automaton instance
Return type:Automaton
LearnAutomaton(rank, lrows=[], lcolumns=[], version='classic', partial=False, sparse=False)[source]

Learn Automaton from sample

  • Input:
Parameters:
  • rank (int) – the ranking number
  • lrows (int or list of int) – number or list of rows, a list of strings if partial=True; otherwise, based on self.pref if version=”classic” or “prefix”, self.fact otherwise
  • lcolumns (int or list of int) – number or list of columns a list of strings if partial=True ; otherwise, based on self.suff if version=”classic” or “suffix”, self.fact otherwise
  • version (string) – (default = “classic”) version name
  • partial (boolean) – (default value = False) build of partial Hankel matrix
  • sparse (boolean) – (default value = False) True if Hankel matrix is sparse
  • Output:
Returns:An automaton instance
Return type:Automaton
static Perplexity(A, adr)[source]

Perplexity calculation

sample_object

Sample object, contains dictionaries