Package edu.cmu.tetrad.data
Class ContinuousDiscretizationSpec
java.lang.Object
edu.cmu.tetrad.data.ContinuousDiscretizationSpec
- All Implemented Interfaces:
DiscretizationSpec
,TetradSerializable
,Serializable
public final class ContinuousDiscretizationSpec
extends Object
implements TetradSerializable, DiscretizationSpec
Specifies how a column (continuous or discrete) should be discretized. For a discrete column the mapping is int[]
remap; for a continuous column the mapping is double[] cutoffs. The categories are the string labels for the
categories. This is just a small immutable class that columns can map to in order to remember how discretizations
were done so that the user doesn't have to keep typing in information over and over again.
- Version:
- $Id: $Id
- Author:
- josephramsey
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
ConstantEVENLY_DISTRIBUTED_INTERVALS=2
static final int
The types of discretizationstatic final int
ConstantNONE=3
-
Constructor Summary
ConstructorsConstructorDescriptionContinuousDiscretizationSpec
(double[] breakpoints, List<String> categories) Constructor for creating a ContinuousDiscretizationSpec object.ContinuousDiscretizationSpec
(double[] breakpoints, List<String> categories, int method) Creates a ContinuousDiscretizationSpec object with the given breakpoints, categories, and method. -
Method Summary
Modifier and TypeMethodDescriptiondouble[]
Retrieves the array of breakpoints used for discretization.Retrieves the list of categories for the discretized data.int
Returns the value of the method used for discretization.static DiscretizationSpec
Generates a simple exemplar of this class to test serialization.void
setMethod
(int method) Sets the method used for discretization.
-
Field Details
-
EVENLY_DISTRIBUTED_VALUES
public static final int EVENLY_DISTRIBUTED_VALUESThe types of discretization- See Also:
-
EVENLY_DISTRIBUTED_INTERVALS
public static final int EVENLY_DISTRIBUTED_INTERVALSConstantEVENLY_DISTRIBUTED_INTERVALS=2
- See Also:
-
NONE
public static final int NONEConstantNONE=3
- See Also:
-
-
Constructor Details
-
ContinuousDiscretizationSpec
-
ContinuousDiscretizationSpec
Creates a ContinuousDiscretizationSpec object with the given breakpoints, categories, and method.- Parameters:
breakpoints
- The array of breakpoints used for discretization.categories
- The list of categories for the discretized data.method
- The method used for discretization. Possible values are: - EVENLY_DISTRIBUTED_VALUES: 0 (evenly distributed values) - EVENLY_DISTRIBUTED_INTERVALS: 1 (evenly distributed intervals) - NONE: 2 (no discretization)- Throws:
NullPointerException
- if breakpoints is null.IllegalArgumentException
- if method is not one of the valid values.
-
-
Method Details
-
serializableInstance
Generates a simple exemplar of this class to test serialization.- Returns:
- a
DiscretizationSpec
object
-
getMethod
public int getMethod()Returns the value of the method used for discretization.- Returns:
- The method used for discretization.
-
setMethod
public void setMethod(int method) Sets the method used for discretization.- Parameters:
method
- The method used for discretization. Possible values are: - ContinuousDiscretizationSpec.EVENLY_DISTRIBUTED_VALUES (0): for evenly distributed values - ContinuousDiscretizationSpec.EVENLY_DISTRIBUTED_INTERVALS (1): for evenly distributed intervals - ContinuousDiscretizationSpec.NONE (2): for no discretization- Throws:
IllegalArgumentException
- if method is not one of the valid values.
-
getCategories
-
getBreakpoints
public double[] getBreakpoints()Retrieves the array of breakpoints used for discretization.- Returns:
- The array of breakpoints.
-