<< Click to Display Table of Contents >> Navigation: Using SMILE > Datasets > Discretization |
To discretize a variable in a data set, use the DSL_dataset::Discretize method. To convert a variable to a discrete variable with 10 states, use the following code:
vector<double> edges;
int res = ds.Discretize(varIdx, DSL_dataset::Hierarchical, 10, "discState", edges);
Note that after the discretization the variable will have state names starting with the specified prefix ("discState" in this case). The names will be suffixed with numeric values derived from calculated discretization intervals. These intervals are also returned in the (optional) edges parameter.
The supported discretization methods are defined in the DSL_dataset::DiscretizeAlgorithm enum:
•Hierarchical
•UniformWidth
•UniformCount
Discretization works on both continuous and discrete variables.