Package classifiers :: Module read_classified
[frames] | no frames]

Module read_classified

source code

This module reads the outputs of qd_classifier.py, specificially classifed.fiat and classes.chunk.

Functions
 
read_classified(f)
Read classified.fiat, as produced by l_classifier or qd_classifier This unpacks the two columns that are packed into ASCII representations and turns them back into python objects.
source code
 
model_fromchunk(chunk)
A factory function to read in an arbitrary classifier model.
source code
l_classifier or qd_classifier
read_classifier(chunk)
Read a classifier in from a gmisclib.chunkio.chunk.
source code
tuple(dict(str:str), list(some_kind_of_classifier))
read_classes(f)
Read classes.chunk, as produced by l_classifier or qd_classifier It converts the header information to ints or floats as appropriate.
source code
dict(str: str, int, or float)
read_classes_header(dc)
Read in the header info.
source code
Variables
  __package__ = 'classifiers'

Imports: fiatio, chunkio, die, Q


Function Details

read_classified(f)

source code 

Read classified.fiat, as produced by l_classifier or qd_classifier This unpacks the two columns that are packed into ASCII representations and turns them back into python objects.

Parameters:
  • f (file or str @rtype (dict, list(dict), list(str))) - file or filename
Returns:
Much like fiatio.read, it returns a tuple of header information, a list of dictionaries (each dictionary corresponding to a line) and a list of comment strings.

model_fromchunk(chunk)

source code 

A factory function to read in an arbitrary classifier model.

Parameters:
  • chunk (chunkio.chunk)

read_classifier(chunk)

source code 

Read a classifier in from a gmisclib.chunkio.chunk. This can yield either a quadratic or a linear classifier, depending what's available in the data file. (This is not normally called directly by the user.)

Parameters:
  • chunk (chunkio.chunk) - loosely, a data file. More precisely, a source of tokens.
Returns: l_classifier or qd_classifier
a single classifier, containing models for several classes.

read_classes(f)

source code 

Read classes.chunk, as produced by l_classifier or qd_classifier It converts the header information to ints or floats as appropriate. It expects to read in a forest of equivalent classifiers, and it returns a list of them. This is the normal API for reading classes.chunk.

Parameters:
  • f (str or file) - a filename or a file to read
Returns: tuple(dict(str:str), list(some_kind_of_classifier))

read_classes_header(dc)

source code 

Read in the header info. This is part of the normal API.

Parameters:
  • dc (chunkio.datachunk) - a datachunk containing the classes.chunk file produced by a classifier run.
Returns: dict(str: str, int, or float)
a dictionary containing the header information. See the docstring for the l_classifier script for typical contents. Numbers are converted to float or int as appropriate.