Package jazzparser :: Package taggers :: Module models :: Class TaggerModel
[hide private]
[frames] | no frames]

Class TaggerModel

source code

object --+
         |
        TaggerModel
Known Subclasses:

A trainable model used by a ModelTagger.

Instance Methods [hide private]
 
__init__(self, model_name, overwrite=False, options={}, description=None)
Creates an empty, untrained model.
source code
 
__get_my_filename(self) source code
 
process_training_options(self)
Verifies and processes the training option values.
source code
 
_get_options(self)
Instead of processing training options when instantiating (which makes it impossible to have required options, since we're not always training when instantiating), we process the training options the first time they're needed.
source code
 
get_extra_filenames(self)
Should return a list of all the files that are stored along with the main model file (not including the main file).
source code
 
save(self)
Saves the model data to a file.
source code
 
delete(self)
Removes all the model's data.
source code
 
_generate_description(self)
Don't override this.
source code
 
__get_description(self) source code
 
_get_model_data(self)
Subclasses should implement this method to return the raw data of the model in a form that can be pickled and written out to a file.
source code
 
train(self, sequence_index, grammar=None, logger=None)
Trains the loaded model using the data in the list of sequences.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Methods [hide private]
 
__get_filename(cls, model_name) source code
 
_get_model_dir(cls) source code
 
list_models(cls)
Returns a list of the names of available models.
source code
 
load_model(cls, model_name) source code
 
_load_model(cls, data)
Subclasses should implement this method to load up the model data given in the argument data.
source code
Class Variables [hide private]
  MODEL_TYPE = None
hash(x)
  TRAINING_OPTIONS = []
Properties [hide private]
  _filename
  options
Instead of processing training options when instantiating (which makes it impossible to have required options, since we're not always training when instantiating), we process the training options the first time they're needed.
  description

Inherited from object: __class__

Method Details [hide private]

__init__(self, model_name, overwrite=False, options={}, description=None)
(Constructor)

source code 

Creates an empty, untrained model. To load a previously stored model, use from_file().

Optionally stores some custom descriptive text. This will be included in the descriptive text that gets stored along with the model.

Overrides: object.__init__

process_training_options(self)

source code 

Verifies and processes the training option values. Access them in self.options.

_get_options(self)

source code 

Instead of processing training options when instantiating (which makes it impossible to have required options, since we're not always training when instantiating), we process the training options the first time they're needed.

If you want to do this ahead of time to verify the validity of the values, call process_training_options.

get_extra_filenames(self)

source code 

Should return a list of all the files that are stored along with the main model file (not including the main file).

By default this is an empty list, but some subclasses may want to put some names in this list. These should just be filenames, not full paths. The files are assumed to be in the model type's directory.

delete(self)

source code 

Removes all the model's data. It is assumed that the tagger will not be used at all after this has been called.

_generate_description(self)

source code 

Don't override this. You can add your own information into the descriptive text (per subclass, for example) by calling __init__ with the description kwarg, or by setting the model_description attribute. You might, for example, want to do this at training time.

_load_model(cls, data)
Class Method

source code 

Subclasses should implement this method to load up the model data given in the argument data. They should return an instance of themselves. The data will be in the form of a dictionary, as returned by the class' _get_model_data().

A default implementation that just uses simple pickling is provided. It assumes that the class can be instantiated using no arguments.

_get_model_data(self)

source code 

Subclasses should implement this method to return the raw data of the model in a form that can be pickled and written out to a file.

A default implementation to complement the implementation of _load_model is provided.

*** IMPORTANT: *** Some implementations perform part of the model storage in their _get_model_data method, so you shouldn't use this just to get the data if you don't plan to store it. (Not sure why you'd want the raw data anyway and this is a private method - just warning you!)


Property Details [hide private]

_filename

Get Method:
__get_my_filename(self)

options

Instead of processing training options when instantiating (which makes it impossible to have required options, since we're not always training when instantiating), we process the training options the first time they're needed.

If you want to do this ahead of time to verify the validity of the values, call process_training_options.

Get Method:
_get_options(self) - Instead of processing training options when instantiating (which makes it impossible to have required options, since we're not always training when instantiating), we process the training options the first time they're needed.

description

Get Method:
__get_description(self)