org.encog.app.analyst.csv.balance
Class BalanceCSV
- java.lang.Object
-
- org.encog.app.analyst.csv.basic.BasicFile
-
- org.encog.app.analyst.csv.balance.BalanceCSV
-
- All Implemented Interfaces:
- QuantTask
public class BalanceCSV extends BasicFile
Balance a CSV file. This utility is useful when you have several an unbalanced training set. You may have a large number of one particular class, and many fewer elements of other classes. This can hinder many Machine Learning methods. This class can be used to balance the data. Obviously this class cannot generate data. You must request how many items you want per class. Some classes will have lower than this number if they were already below the specified amount. Any class above this amount will be trimmed to that amount.
-
-
Field Summary
-
Fields inherited from class org.encog.app.analyst.csv.basic.BasicFile
REPORT_INTERVAL
-
-
Constructor Summary
Constructors Constructor and Description BalanceCSV()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidanalyze(java.io.File inputFile, boolean headers, CSVFormat format)Analyze the data.java.lang.StringdumpCounts()Return a string that lists the counts per class.java.util.Map<java.lang.String,java.lang.Integer>getCounts()voidprocess(java.io.File outputFile, int targetField, int countPer)Process and balance the data.-
Methods inherited from class org.encog.app.analyst.csv.basic.BasicFile
appendSeparator, getColumnCount, getFormat, getInputFilename, getInputHeadings, getPrecision, getRecordCount, getReport, getReportInterval, getScript, isAnalyzed, isExpectInputHeaders, isProduceOutputHeaders, performBasicCounts, prepareOutputFile, readHeaders, reportDone, reportDone, requestStop, resetStatus, setAnalyzed, setColumnCount, setExpectInputHeaders, setInputFilename, setInputFormat, setInputHeadings, setPrecision, setProduceOutputHeaders, setRecordCount, setReport, setReportInterval, setScript, shouldStop, toString, updateStatus, updateStatus, validateAnalyzed, writeRow
-
-
-
-
Method Detail
-
analyze
public void analyze(java.io.File inputFile, boolean headers, CSVFormat format)Analyze the data. This counts the records and prepares the data to be processed.- Parameters:
inputFile- The input file to process.headers- True, if headers are present.format- The format of the CSV file.
-
dumpCounts
public java.lang.String dumpCounts()
Return a string that lists the counts per class.- Returns:
- The counts per class.
-
getCounts
public java.util.Map<java.lang.String,java.lang.Integer> getCounts()
- Returns:
- Tracks the counts of each class.
-
process
public void process(java.io.File outputFile, int targetField, int countPer)Process and balance the data.- Parameters:
outputFile- The output file to write data to.targetField- The field that is being balanced, this field determines the classes.countPer- The desired count per class.
-
-
DMelt 3.0 © DataMelt by jWork.ORG