  # Function Design: 6-Output Mapper Functions

Posted

Mapper functions with 6 discrete outputs is as high as I'll go (I still have to implement all of them in all the programming languages of GeneXproTools). Although they continue to scale up amazingly well, with hardly any loss in performance compared to the mapper functions of 4 and 5 outputs (see the posts "Function Design: 4-Output Mapper Functions" and "Function Design: 5-Output Mapper Functions"), I don't think we'll benefit from higher order output functions to solve multi-class classification problems with more than 3 classes, unless the problems are really simple such as the 3-class Iris problem.

I must confess that I couldn't find even a toy problem to test effectively these higher order mappers on them. For example, not even the Balance Scale data, a well-known toy problem, can be satisfactorily solved in one go with these functions (and also the argmin/argmax functions of 4 arguments) using the current setup. Other tools are obviously needed, such as special fitness functions, linking structures and sampling schemes, just to name a few.

But these functions are nonetheless interesting and very useful on their own and, meshed with other functions, they can impact positively on the evolution of all kinds of models.

So here it is, the C++ code for the 6-output mapper functions of 2, 3, and 4 arguments. Again, there are 3 new functions in the series – Map6A, Map6B, and Map6C – respectively with 2, 3, and 4 arguments. And their performance is again exceptional with 98% hits for Map6A, 98% for Map6B, and 99% for Map6C against 96% for the argmax.

// Map6A(x0,x1): 6-Output Mapper Function
const double SLACK = 10.0;
double output = 0.0;
if (x < (x - SLACK))
output = 0.0;
else if (x >= (x - SLACK) && x < (x - SLACK/2.0))
output = 1.0;
else if (x >= (x - SLACK/2.0) && x < x)
output = 2.0;
else if (x >= x && x < (x + SLACK/2.0))
output = 3.0;
else if (x >= (x + SLACK/2.0) && x < (x + SLACK))
output = 4.0;
else if (x >= (x + SLACK))
output = 5.0;
return output;

// Map6B(x0,x1,x2): 6-Output Mapper Function
// evaluate min(x,y), max(x,y), midrange, midpoint1, midpoint2
double min = x;
double max = x;
if (min > x)
{
min = x;
max = x;
}
double midrange = (min + max)/2.0;
double midpoint1 = (min + midrange)/2.0;
double midpoint2 = (midrange + max)/2.0;
double output = 0.0;
if (x < min)
output = 0.0;
else if (x >= min && x < midpoint1)
output = 1.0;
else if (x >= midpoint1 && x < midrange)
output = 2.0;
else if (x >= midrange && x < midpoint2)
output = 3.0;
else if (x >= midpoint2 && x < max)
output = 4.0;
else if (x >= max)
output = 5.0;
return output;

// Map6C(x0,x1,x2,x3): 6-Output Mapper Function
// evaluate min(x,y,z), max(x,y,z), midleValue(x,y,z), midrange1, midrange2
//
// evaluate min(x,y,z)
double min = x;
int argmin = 0;
if (min > x)
{
min = x;
argmin = 1;
}
if (min > x)
{
min = x;
argmin = 2;
}
// evaluate max(x,y,z)
double max = x;
int argmax = 0;
if (max < x)
{
max = x;
argmax = 1;
}
if (max < x)
{
max = x;
argmax = 2;
}
// evaluate midleValue(x,y,z)
double midleValue = x;
if (0 != argmin && 0 != argmax)
midleValue = x;
if (1 != argmin && 1 != argmax)
midleValue = x;
// evaluate midrange1 e midrange2
double midrange1 = (min + midleValue)/2.0;
double midrange2 = (midleValue + max)/2.0;

double output = 0.0;
if (x < min)
output = 0.0;
else if (x >= min && x < midrange1)
output = 1.0;
else if (x >= midrange1 && x < midleValue)
output = 2.0;
else if (x >= midleValue && x < midrange2)
output = 3.0;
else if (x >= midrange2 && x < max)
output = 4.0;
else if (x >= max)
output = 5.0;
return output;

In the next post we'll go the other direction and take a look at the 3-output mapper functions of 2, 3, and 4 arguments, the last in the series of new mapper functions.

Author