class documentation

class ARFF_Formatter: (source)

Constructor: ARFF_Formatter(labels, features)

View In Hierarchy

Converts featuresets and labeled featuresets to ARFF-formatted strings, appropriate for input into Weka.

Features and classes can be specified manually in the constructor, or may be determined from data using from_train.

Static Method from_train Constructs an ARFF_Formatter instance with class labels and feature types determined from the given data. Handles boolean, numeric and string (note: not nominal) types.
Method __init__ No summary
Method data_section Returns the ARFF data section for the given data.
Method format Returns a string representation of ARFF output for the given data.
Method header_section Returns an ARFF header as a string.
Method labels Returns the list of classes.
Method write Writes ARFF data to a file for the given data.
Method _fmt_arff_val Undocumented
Instance Variable _features Undocumented
Instance Variable _labels Undocumented
@staticmethod
def from_train(tokens): (source)

Constructs an ARFF_Formatter instance with class labels and feature types determined from the given data. Handles boolean, numeric and string (note: not nominal) types.

def __init__(self, labels, features): (source)
Parameters
labelsA list of all class labels that can be generated.
featuresA list of feature specifications, where each feature specification is a tuple (fname, ftype); and ftype is an ARFF type string such as NUMERIC or STRING.
def data_section(self, tokens, labeled=None): (source)

Returns the ARFF data section for the given data.

Parameters
tokensa list of featuresets (dicts) or labelled featuresets which are tuples (featureset, label).
labeledIndicates whether the given tokens are labeled or not. If None, then the tokens will be assumed to be labeled if the first token's value is a tuple or list.
def format(self, tokens): (source)

Returns a string representation of ARFF output for the given data.

def header_section(self): (source)

Returns an ARFF header as a string.

def labels(self): (source)

Returns the list of classes.

def write(self, outfile, tokens): (source)

Writes ARFF data to a file for the given data.

def _fmt_arff_val(self, fval): (source)

Undocumented

_features = (source)

Undocumented

Undocumented