public class CsvRecordFactory extends Object implements RecordFactory
Constructor and Description |
---|
CsvRecordFactory(String targetName,
Map<String,String> typeMap)
Construct a parser for CSV lines that encodes the parsed data in vector form.
|
CsvRecordFactory(String targetName,
String idName,
Map<String,String> typeMap) |
Modifier and Type | Method and Description |
---|---|
void |
defineTargetCategories(List<String> values)
Defines the values and thus the encoding of values of the target variables.
|
void |
firstLine(String line)
Processes the first line of a file (which should contain the variable names).
|
String |
getIdName() |
String |
getIdString(CharSequence line)
Extract the id column value from the CSV record
|
Iterable<String> |
getPredictors()
Returns a list of the names of the predictor variables.
|
List<String> |
getTargetCategories() |
String |
getTargetLabel(int code)
Extract the corresponding raw target label according to a code
|
String |
getTargetString(CharSequence line)
Extract the raw target string from a line read from a CSV file.
|
Map<String,Set<Integer>> |
getTraceDictionary() |
CsvRecordFactory |
includeBiasTerm(boolean useBias) |
CsvRecordFactory |
maxTargetValue(int max)
Defines the number of target variable categories, but allows this parser to
pick encodings for them as they appear.
|
int |
processLine(CharSequence line,
Vector featureVector,
boolean returnTarget)
Decodes a single line of CSV data and records the target(if retrunTarget is true)
and predictor variables in a record.
|
int |
processLine(String line,
Vector featureVector)
Decodes a single line of CSV data and records the target and predictor variables in a record.
|
void |
setIdName(String idName) |
boolean |
usesFirstLineAsSchema() |
public CsvRecordFactory(String targetName, Map<String,String> typeMap)
targetName
- The name of the target variable.typeMap
- A map describing the types of the predictor variables.public void defineTargetCategories(List<String> values)
defineTargetCategories
in interface RecordFactory
values
- The values the target variable can have.public CsvRecordFactory maxTargetValue(int max)
maxTargetValue
in interface RecordFactory
max
- The number of categories that will be expected. Once this many have been
seen, all others will get the encoding max-1.public boolean usesFirstLineAsSchema()
usesFirstLineAsSchema
in interface RecordFactory
public void firstLine(String line)
firstLine
in interface RecordFactory
line
- Header line for the file.public int processLine(String line, Vector featureVector)
processLine
in interface RecordFactory
line
- The raw data.featureVector
- Where to fill in the features. Should be zeroed before calling
processLine.public int processLine(CharSequence line, Vector featureVector, boolean returnTarget)
line
- The raw data.featureVector
- Where to fill in the features. Should be zeroed before calling
processLine.returnTarget
- whether process and return target value, -1 will be returned if false.public String getTargetString(CharSequence line)
line
- the line of content read from CSV filepublic String getTargetLabel(int code)
code
- the integer code encoded during training processpublic String getIdString(CharSequence line)
line
- the line of content read from CSV filepublic Iterable<String> getPredictors()
getPredictors
in interface RecordFactory
public Map<String,Set<Integer>> getTraceDictionary()
getTraceDictionary
in interface RecordFactory
public CsvRecordFactory includeBiasTerm(boolean useBias)
includeBiasTerm
in interface RecordFactory
public List<String> getTargetCategories()
getTargetCategories
in interface RecordFactory
public String getIdName()
public void setIdName(String idName)
Copyright © 2008–2017 The Apache Software Foundation. All rights reserved.