Newer
Older
Alice Brenon
committed
#!/usr/bin/env python3
Alice Brenon
committed
import pandas
Alice Brenon
committed
from sys import argv
Alice Brenon
committed
"""
Make predictions on a set of document
Positional arguments
:param classify: an instance of the Classifier class
:param source: an instance of the Corpus class
Alice Brenon
committed
Keyword arguments
:param name: defaults to 'label' — the name of the column to be created, that is
to say, the name of the category you are predicting with your model (if your
model labels in "Red", "Green", or "Blue", you may want to use
`name='color'`).
:return: a panda dataframe containing the records from the input TSV file plus
an additional column
"""
records = pandas.DataFrame(source.get_all('key'))
records[name] = classify(source.get_all('content'))
Alice Brenon
committed
return records
if __name__ == '__main__':
classify = Classifier(argv[1])
source = corpus(argv[2])
label(classify, source).to_csv(argv[3], sep='\t', index=False)