/*** * Extract the id column value from the CSV record * @param line the line of content read from CSV file * @return the id value of the CSV record */ public String getIdString(CharSequence line) { List<String> values = parseCsvLine(line); return values.get(id); }
@Test public void testAddToVector() { RecordFactory csv = new CsvRecordFactory("y", ImmutableMap.of("x1", "n", "x2", "w", "x3", "t")); csv.firstLine("z,x1,y,x2,x3,q"); csv.maxTargetValue(2);
/*** * Extract the raw target string from a line read from a CSV file. * @param line the line of content read from CSV file * @return the raw target value in the corresponding column of CSV line */ public String getTargetString(CharSequence line) { List<String> values = parseCsvLine(line); return values.get(target); }
/*** * Extract the raw target string from a line read from a CSV file. * @param line the line of content read from CSV file * @return the raw target value in the corresponding column of CSV line */ public String getTargetString(CharSequence line) { List<String> values = parseCsvLine(line); return values.get(target); }
/*** * Extract the raw target string from a line read from a CSV file. * @param line the line of content read from CSV file * @return the raw target value in the corresponding column of CSV line */ public String getTargetString(CharSequence line) { List<String> values = parseCsvLine(line); return values.get(target); }
/*** * Extract the id column value from the CSV record * @param line the line of content read from CSV file * @return the id value of the CSV record */ public String getIdString(CharSequence line) { List<String> values = parseCsvLine(line); return values.get(id); }
/*** * Extract the id column value from the CSV record * @param line the line of content read from CSV file * @return the id value of the CSV record */ public String getIdString(CharSequence line) { List<String> values = parseCsvLine(line); return values.get(id); }
private List<String> parseCsvLine(CharSequence line) { return parseCsvLine(line.toString()); }
private List<String> parseCsvLine(CharSequence line) { return parseCsvLine(line.toString()); }
private List<String> parseCsvLine(CharSequence line) { return parseCsvLine(line.toString()); }
/*** * Decodes a single line of CSV data and records the target(if retrunTarget is true) * and predictor variables in a record. As a side effect, features are added into the featureVector. * Returns the value of the target variable. When used during classify against production data without * target value, the method will be called with returnTarget = false. * @param line The raw data. * @param featureVector Where to fill in the features. Should be zeroed before calling * processLine. * @param returnTarget whether process and return target value, -1 will be returned if false. * @return The value of the target variable. */ public int processLine(CharSequence line, Vector featureVector, boolean returnTarget) { List<String> values = parseCsvLine(line); int targetValue = -1; if (returnTarget) { targetValue = targetDictionary.intern(values.get(target)); if (targetValue >= maxTargetValue) { targetValue = maxTargetValue - 1; } } for (Integer predictor : predictors) { String value = predictor >= 0 ? values.get(predictor) : null; predictorEncoders.get(predictor).addToVector(value, featureVector); } return targetValue; }
/*** * Decodes a single line of CSV data and records the target(if retrunTarget is true) * and predictor variables in a record. As a side effect, features are added into the featureVector. * Returns the value of the target variable. When used during classify against production data without * target value, the method will be called with returnTarget = false. * @param line The raw data. * @param featureVector Where to fill in the features. Should be zeroed before calling * processLine. * @param returnTarget whether process and return target value, -1 will be returned if false. * @return The value of the target variable. */ public int processLine(CharSequence line, Vector featureVector, boolean returnTarget) { List<String> values = parseCsvLine(line); int targetValue = -1; if (returnTarget) { targetValue = targetDictionary.intern(values.get(target)); if (targetValue >= maxTargetValue) { targetValue = maxTargetValue - 1; } } for (Integer predictor : predictors) { String value = predictor >= 0 ? values.get(predictor) : null; predictorEncoders.get(predictor).addToVector(value, featureVector); } return targetValue; }
/*** * Decodes a single line of CSV data and records the target(if retrunTarget is true) * and predictor variables in a record. As a side effect, features are added into the featureVector. * Returns the value of the target variable. When used during classify against production data without * target value, the method will be called with returnTarget = false. * @param line The raw data. * @param featureVector Where to fill in the features. Should be zeroed before calling * processLine. * @param returnTarget whether process and return target value, -1 will be returned if false. * @return The value of the target variable. */ public int processLine(CharSequence line, Vector featureVector, boolean returnTarget) { List<String> values = parseCsvLine(line); int targetValue = -1; if (returnTarget) { targetValue = targetDictionary.intern(values.get(target)); if (targetValue >= maxTargetValue) { targetValue = maxTargetValue - 1; } } for (Integer predictor : predictors) { String value = predictor >= 0 ? values.get(predictor) : null; predictorEncoders.get(predictor).addToVector(value, featureVector); } return targetValue; }
/** * Decodes a single line of CSV data and records the target and predictor variables in a record. * As a side effect, features are added into the featureVector. Returns the value of the target * variable. * * @param line The raw data. * @param featureVector Where to fill in the features. Should be zeroed before calling * processLine. * @return The value of the target variable. */ @Override public int processLine(String line, Vector featureVector) { List<String> values = parseCsvLine(line); int targetValue = targetDictionary.intern(values.get(target)); if (targetValue >= maxTargetValue) { targetValue = maxTargetValue - 1; } for (Integer predictor : predictors) { String value; if (predictor >= 0) { value = values.get(predictor); } else { value = null; } predictorEncoders.get(predictor).addToVector(value, featureVector); } return targetValue; }
/** * Decodes a single line of CSV data and records the target and predictor variables in a record. * As a side effect, features are added into the featureVector. Returns the value of the target * variable. * * @param line The raw data. * @param featureVector Where to fill in the features. Should be zeroed before calling * processLine. * @return The value of the target variable. */ @Override public int processLine(String line, Vector featureVector) { List<String> values = parseCsvLine(line); int targetValue = targetDictionary.intern(values.get(target)); if (targetValue >= maxTargetValue) { targetValue = maxTargetValue - 1; } for (Integer predictor : predictors) { String value; if (predictor >= 0) { value = values.get(predictor); } else { value = null; } predictorEncoders.get(predictor).addToVector(value, featureVector); } return targetValue; }
/** * Decodes a single line of CSV data and records the target and predictor variables in a record. * As a side effect, features are added into the featureVector. Returns the value of the target * variable. * * @param line The raw data. * @param featureVector Where to fill in the features. Should be zeroed before calling * processLine. * @return The value of the target variable. */ @Override public int processLine(String line, Vector featureVector) { List<String> values = parseCsvLine(line); int targetValue = targetDictionary.intern(values.get(target)); if (targetValue >= maxTargetValue) { targetValue = maxTargetValue - 1; } for (Integer predictor : predictors) { String value; if (predictor >= 0) { value = values.get(predictor); } else { value = null; } predictorEncoders.get(predictor).addToVector(value, featureVector); } return targetValue; }
variableNames = parseCsvLine(line); int column = 0; for (String var : variableNames) {
variableNames = parseCsvLine(line); int column = 0; for (String var : variableNames) {
variableNames = parseCsvLine(line); int column = 0; for (String var : variableNames) {