Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## ec.cgp.problems
Class ClassificationProblem

    java.lang.Object
      ec.Problem
          ec.cgp.problems.ProblemCGP
              ec.cgp.problems.ClassificationProblem

All Implemented Interfaces:
  ec.Prototype, ec.Setup, ec.simple.SimpleProblemForm, java.io.Serializable, java.lang.Cloneable

Direct Known Subclasses:
  ProblemBreastCancerW, ProblemBreastCancerY, ProblemIris

    public abstract class ClassificationProblem

extends ProblemCGP

An extension of CGPProblem which provides some facilities to represent and evaluate classification problems.

Author:
  David Oranchak, doranchak@gmail.com, http://oranchak.com
See Also:
  Serialized Form

Field Summary
`(package private) static java.util.List<Record>` | `data` storage for records
`(package private) static java.lang.String` | `P_FILE`
`(package private) static java.lang.String` | `P_TEST`
`(package private) static float` | `test` proportion of records to reserve for the testing set (example: 0.3 = 30%)
`(package private) static java.util.List<Record>` | `testSet` portion of the records used for testing/verification
`(package private) static java.util.List<Record>` | `trainingSet` portion of the records used for training

Fields inherited from class ec.cgp.problems.ProblemCGP
`constantMax, constantMin, constants, numConstants, P_CONSTANT_MAX, P_CONSTANT_MIN, P_CONSTANTS`

Fields inherited from class ec.Problem
`P_PROBLEM`

Constructor Summary
`ClassificationProblem()`

Method Summary
`(package private) abstract boolean[]` | `compare(java.lang.Object[] outputs, Record r)` During evaluation, outputs are passed to this method.
`(package private) boolean[]` | `eval(ec.EvolutionState state, int threadnum, java.lang.Object[] inputs, Record rec, VectorIndividualCGP ind)` Sets the inputs, runs the Cartesian Genetic Program, and returns the results of classification.
`void` | `evaluate(ec.EvolutionState state, ec.Individual ind, int subpopulation, int threadnum)` Evaluate this individual.
`(package private) abstract Record` | `makeRecord(java.lang.String line)` Your implementing class must do the grunt work of turning a line from the text file into a Record instance that is specific to your problem.
`(package private) void` | `makeRecords(java.lang.String fileName, ec.util.MersenneTwisterFast rand)` Read lines of text from the input file and turn each line into a Record instance.
`(package private) abstract void` | `setInputs(java.lang.Object[] inputs, Record r)` Your implementing class must map attributes of the given Record to items in the input vector using this method.
`void` | `setup(ec.EvolutionState state, ec.util.Parameter base)` Configure this Classification Problem.

Methods inherited from class ec.cgp.problems.ProblemCGP
`describe, initConstants`

Methods inherited from class ec.Problem
`canEvaluate, clone, closeContacts, defaultBase, finishEvaluating, initializeContacts, prepareToEvaluate, reinitializeContacts`

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### data

    static java.util.List<Record> data

  storage for records

### trainingSet

    static java.util.List<Record> trainingSet

  portion of the records used for training

### testSet

    static java.util.List<Record> testSet

  portion of the records used for testing/verification

### P_FILE

    static java.lang.String P_FILE

### P_TEST

    static java.lang.String P_TEST

### test

    static float test

  proportion of records to reserve for the testing set (example: 0.3 = 30%)

Constructor Detail

### ClassificationProblem

    public ClassificationProblem()

Method Detail

### setup

    public void setup(ec.EvolutionState state,
                      ec.util.Parameter base)

  Configure this Classification Problem.

  Specified by:
    `setup` in interface `ec.Prototype`
  Specified by:
    `setup` in interface `ec.Setup`
  Overrides:
    `setup` in class `ProblemCGP`

### makeRecords

    void makeRecords(java.lang.String fileName,
                     ec.util.MersenneTwisterFast rand)

  Read lines of text from the input file and turn each line into a Record instance.

  Parameters:
    `fileName` - The full path of the input file.
    `rand` - RNG to use.

### makeRecord

    abstract Record makeRecord(java.lang.String line)

  Your implementing class must do the grunt work of turning a line from the text file into a Record instance that is specific to your problem.

  Parameters:
    `line` - The comma-delimited line from the data file.
  Returns:
    an instance of the Record.

### evaluate

    public void evaluate(ec.EvolutionState state,
                         ec.Individual ind,
                         int subpopulation,
                         int threadnum)

  Evaluate this individual. Fitness is set to the proportion of unsuccessfully classified training instances. If there are constant values, the input vector is filled with them starting at the end. The test set is also evaluated to measure performance of the classifier.

### setInputs

    abstract void setInputs(java.lang.Object[] inputs,
                            Record r)

  Your implementing class must map attributes of the given Record to items in the input vector using this method.

  Parameters:
    `inputs` - input array to set
    `r` - record to set values from

### compare

    abstract boolean[] compare(java.lang.Object[] outputs,
                               Record r)

  During evaluation, outputs are passed to this method. Your implementing class must compare the outputs to the target class(es) in the given Record. Each element of the return vector is set to true if the corresponding output represents a successfully classified instance.

  Parameters:
    `outputs` - The output vector resulting from evaluation of the CGP.
    `r` - The record from which to compare classification results.
  Returns:
    A boolean vector indicating sucess of classification.

### eval

    boolean[] eval(ec.EvolutionState state,
                   int threadnum,
                   java.lang.Object[] inputs,
                   Record rec,
                   VectorIndividualCGP ind)

  Sets the inputs, runs the Cartesian Genetic Program, and returns the results of classification.

  Parameters:
    `state` - The evolution state
    `threadnum` - The current thread number
    `inputs` - The input vector
    `rec` - The current record
    `ind` - The current individual
  Returns:
    boolean vector indicating successful/unsuccessful classification(s).

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD