org.encog.app.analyst.script.normalize
Class AnalystField

java.lang.Object
  extended by org.encog.app.analyst.script.normalize.AnalystField

public class AnalystField
extends Object

Holds a field to be analyzed.


Field Summary
static int MIN_EQ_CLASSES
          Minimum classes for encode using equilateral.
 
Constructor Summary
AnalystField()
          Construct the object with a range of 1 and -1.
AnalystField(AnalystField field)
          Construct an analyst field.
AnalystField(double theNormalizedHigh, double theNormalizedLow)
          Construct the object.
AnalystField(NormalizationAction theAction, String theName)
          Construct an object.
AnalystField(NormalizationAction theAction, String theName, double ahigh, double alow, double nhigh, double nlow)
          Construct the field, with no defaults.
AnalystField(String theName, NormalizationAction theAction, double high, double low)
          Construct an analyst field to use.
 
Method Summary
 void addRawHeadings(StringBuilder line, String prefix, CSVFormat format)
          Add headings for a raw file.
 void analyze(double d)
          Analyze the specified value.
 double deNormalize(double value)
          Denormalize the specified value.
 ClassItem determineClass(double[] data)
          Determine what class the specified data belongs to.
 ClassItem determineClass(int pos, double[] data)
          Determine the class using part of an array.
 int determineMode(EncogAnalyst analyst)
          Determine the mode, this is the class item that has the most instances.
 double[] encode(double d)
           
 double[] encode(int classNumber)
          Encode the class.
 double[] encode(String str)
          Encode the string to numeric form.
 double[] encodeEquilateral(int classNumber)
          Perform an equilateral encode.
 ClassItem findClass(int index)
           
 void fixSingleValue()
          Fix normalized fields that have a single value for the min/max.
 NormalizationAction getAction()
           
 double getActualHigh()
           
 double getActualLow()
           
 List<ClassItem> getClasses()
           
 int getColumnsNeeded()
           
 Equilateral getEq()
           
 String getName()
           
 double getNormalizedHigh()
           
 double getNormalizedLow()
           
 int getTimeSlice()
           
 void init()
          Init any internal structures.
 boolean isClassify()
           
 boolean isIgnored()
           
 boolean isInput()
           
 boolean isOutput()
           
 int lookup(String str)
          Lookup the specified field.
 void makeClass(NormalizationAction theAction, int classFrom, int classTo, int high, int low)
          Make the classes based on numbers.
 void makeClass(NormalizationAction theAction, String[] cls, double high, double low)
          Make the classes using names.
 void makePassThrough()
          Make this a pass-through field.
 double normalize(double value)
          Normalize the specified value.
 void setAction(NormalizationAction theAction)
          Set the theAction for the field.
 void setActualHigh(double theActualHigh)
          Set the actual high for the field.
 void setActualLow(double theActualLow)
          Set the actual low for the field.
 void setName(String theName)
          Set the name of the field.
 void setNormalizedHigh(double theNormalizedHigh)
          Set the normalized high for the field.
 void setNormalizedLow(double theNormalizedLow)
          Set the normalized low for the field.
 void setOutput(boolean b)
          Set if this is an output field.
 void setTimeSlice(int theTimeSlice)
           
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MIN_EQ_CLASSES

public static final int MIN_EQ_CLASSES
Minimum classes for encode using equilateral.

See Also:
Constant Field Values
Constructor Detail

AnalystField

public AnalystField()
Construct the object with a range of 1 and -1.


AnalystField

public AnalystField(AnalystField field)
Construct an analyst field. Works like a C++ copy constructor.

Parameters:
field - The field to clone.

AnalystField

public AnalystField(double theNormalizedHigh,
                    double theNormalizedLow)
Construct the object.

Parameters:
theNormalizedHigh - The normalized high.
theNormalizedLow - The normalized low.

AnalystField

public AnalystField(NormalizationAction theAction,
                    String theName)
Construct an object.

Parameters:
theAction - The desired action.
theName - The name of this column.

AnalystField

public AnalystField(NormalizationAction theAction,
                    String theName,
                    double ahigh,
                    double alow,
                    double nhigh,
                    double nlow)
Construct the field, with no defaults.

Parameters:
theAction - The normalization action to take.
theName - The name of this field.
ahigh - The actual high.
alow - The actual low.
nhigh - The normalized high.
nlow - The normalized low.

AnalystField

public AnalystField(String theName,
                    NormalizationAction theAction,
                    double high,
                    double low)
Construct an analyst field to use.

Parameters:
theName - The name of the field.
theAction - The action to use.
high - The high value.
low - The low value.
Method Detail

addRawHeadings

public void addRawHeadings(StringBuilder line,
                           String prefix,
                           CSVFormat format)
Add headings for a raw file.

Parameters:
line - The line to write the raw headings to.
prefix - The prefix to place.
format - The format to use.

analyze

public void analyze(double d)
Analyze the specified value. Adjust min/max as needed. Usually used only internally.

Parameters:
d - The value to analyze.

deNormalize

public double deNormalize(double value)
Denormalize the specified value.

Parameters:
value - The value to normalize.
Returns:
The normalized value.

determineClass

public ClassItem determineClass(double[] data)
Determine what class the specified data belongs to.

Parameters:
data - The data to analyze.
Returns:
The class the data belongs to.

determineClass

public ClassItem determineClass(int pos,
                                double[] data)
Determine the class using part of an array.

Parameters:
pos - The position to begin.
data - The array to check.
Returns:
The class item.

encode

public double[] encode(int classNumber)
Encode the class.

Parameters:
classNumber - The class number.
Returns:
The encoded class.

encode

public double[] encode(String str)
Encode the string to numeric form.

Parameters:
str - The string to encode.
Returns:
The numeric form.

encodeEquilateral

public double[] encodeEquilateral(int classNumber)
Perform an equilateral encode.

Parameters:
classNumber - The class number.
Returns:
The class to encode.

fixSingleValue

public void fixSingleValue()
Fix normalized fields that have a single value for the min/max. Separate them by 2 units.


getAction

public NormalizationAction getAction()
Returns:
The action for the field.

getActualHigh

public double getActualHigh()
Returns:
The actual high for the field.

getActualLow

public double getActualLow()
Returns:
The actual low for the field.

getClasses

public List<ClassItem> getClasses()
Returns:
The classes.

getColumnsNeeded

public int getColumnsNeeded()
Returns:
Returns the number of columns needed for this classification. The number of columns needed will vary, depending on the classification method used.

getEq

public Equilateral getEq()
Returns:
The equilateral utility.

getName

public String getName()
Returns:
The name of the field.

getNormalizedHigh

public double getNormalizedHigh()
Returns:
The normalized high for the field.

getNormalizedLow

public double getNormalizedLow()
Returns:
The normalized low for the neural network.

getTimeSlice

public int getTimeSlice()
Returns:
the timeSlice

init

public void init()
Init any internal structures.


isClassify

public boolean isClassify()
Returns:
True if this field is classification.

isIgnored

public final boolean isIgnored()
Returns:
Is this field ignored.

isInput

public boolean isInput()
Returns:
Is this field input.

isOutput

public boolean isOutput()
Returns:
Is this field output.

lookup

public int lookup(String str)
Lookup the specified field.

Parameters:
str - The name of the field to lookup.
Returns:
The index of the field, or -1 if not found.

makeClass

public void makeClass(NormalizationAction theAction,
                      int classFrom,
                      int classTo,
                      int high,
                      int low)
Make the classes based on numbers.

Parameters:
theAction - The action.
classFrom - The starting class.
classTo - The ending class.
high - The high value.
low - The low value.

makeClass

public void makeClass(NormalizationAction theAction,
                      String[] cls,
                      double high,
                      double low)
Make the classes using names.

Parameters:
theAction - The action to use.
cls - The class names.
high - The high value.
low - The low value.

makePassThrough

public void makePassThrough()
Make this a pass-through field.


normalize

public double normalize(double value)
Normalize the specified value.

Parameters:
value - The value to normalize.
Returns:
The normalized value.

setAction

public void setAction(NormalizationAction theAction)
Set the theAction for the field.

Parameters:
theAction - The action for the field.

setActualHigh

public void setActualHigh(double theActualHigh)
Set the actual high for the field.

Parameters:
theActualHigh - The actual high for the field.

setActualLow

public void setActualLow(double theActualLow)
Set the actual low for the field.

Parameters:
theActualLow - The actual low for the field.

setName

public void setName(String theName)
Set the name of the field.

Parameters:
theName - The name of the field.

setNormalizedHigh

public void setNormalizedHigh(double theNormalizedHigh)
Set the normalized high for the field.

Parameters:
theNormalizedHigh - The normalized high for the field.

setNormalizedLow

public void setNormalizedLow(double theNormalizedLow)
Set the normalized low for the field.

Parameters:
theNormalizedLow - The normalized low for the field.

setOutput

public void setOutput(boolean b)
Set if this is an output field.

Parameters:
b - True, if this is output.

setTimeSlice

public void setTimeSlice(int theTimeSlice)
Parameters:
theTimeSlice - the timeSlice to set

toString

public String toString()

Overrides:
toString in class Object

determineMode

public int determineMode(EncogAnalyst analyst)
Determine the mode, this is the class item that has the most instances.

Parameters:
analyst - The Encog analyst.
Returns:
The mode.

encode

public double[] encode(double d)

findClass

public ClassItem findClass(int index)


Copyright © 2014. All Rights Reserved.