vsm.model.BeagleComposite

class vsm.model.BeagleComposite(ctx_corp, ctx_matrix, ord_corp, ord_matrix, context_type='sentence')

BeagleComposite combines the BEAGLE order and context model with a user defined ratio. Default ratio is .5 which weighs order and context matrices equally.

Methods

BeagleComposite.__init__(ctx_corp, ...[, ...]) Assume that the context corpus is a subcorpus of the order corpus and that the eventual composite corpus is the context corpus.
BeagleComposite.load(f) Takes a filename or file object and loads it as an npz archive
BeagleComposite.save(f) Takes a filename or file object and saves self.matrix in an npz archive.
BeagleComposite.train([wgt]) Combines the context and order matrices blended by wgt ratio.
__init__(ctx_corp, ctx_matrix, ord_corp, ord_matrix, context_type='sentence')

Assume that the context corpus is a subcorpus of the order corpus and that the eventual composite corpus is the context corpus. The order matrix is sliced and reordered so that it aligns with the context matrix.

Parameters:
  • ctx_corp (Corpus) – Corpus from BEAGLE context model.
  • ctx_matrix (np.ndarray matrix) – BEAGLE context matrix.
  • ord_corp (Corpus) – Corpus from BEAGLE order model.
  • ord_matrix (np.ndarray matrix) – BEAGLE order matrix.
  • context_type (string, optional) – Name of tokenization stored in corpus whose tokens will be treated as documents. Default is sentence.
static load(f)

Takes a filename or file object and loads it as an npz archive into a BaseModel object.

Parameters:file (str-like or file-like object) – Designates the file to read. If file is a string ending in .gz, the file is first gunzipped. See numpy.load for further details.
Returns:A dictionary storing the data found in file.
See Also:numpy.load()
save(f)

Takes a filename or file object and saves self.matrix in an npz archive.

Parameters:file (str-like or file-like object) – Designates the file to which to save data. See numpy.savez for further details.
Returns:None
See Also:numpy.savez()
train(wgt=0.5)

Combines the context and order matrices blended by wgt ratio.

Parameters:wgt (float, optional) – The weight of context model. If wgt is .7 then the ratio of context and order model is 7:3. wgt should be a value in [0,1]. Default is .5.
Returns:None

Previous topic

vsm.model.TfSeq

Next topic

vsm.model.BeagleContextMulti

This Page