Example #1
0
double MultilayerPerceptron::getCE(const vector<vector<double> > &inputs, const vector<vector<double> > &targets)
{
	size_t sInputs = inputs.size();
	int os = getOutputSize();
	int errCount = 0;
	int n = 0;
	vector<int> yObtained;
	for(size_t p = 0; p < sInputs; p++){
		yObtained = getClasifierOutput(inputs[p],
									   (ot == UnipolarClasifier ? 0.5 : 0),
									   ot);
		for(int element = 0; element < os; element++){
			switch(ot){
				case UnipolarClasifier:
					if(toUnipolar(targets[p], 0.5)[element] != yObtained[element]){
						errCount++;
					}
					break;
				case BipolarClasifier:
					if(toBipolar(targets[p], 0)[element] != yObtained[element]){
						errCount++;
					}
					break;
			}
			n++;
		}
	}

	return errCount/n;
}
String MouseOverKnob::getTextFromValue(double val)
{
    // calculate bipolar value, only makes sense if minimum is 0 since maximum is used for scaling
    if (displayBipolarValue)
    {
        float coeff = toBipolar(static_cast<float>(this->getMinimum()), static_cast<float>(this->getMaximum()), static_cast<float>(val));
        val = this->getMaximum() * coeff;
    }

    int decimal = getNumDecimalPlacesToDisplay();
    if (decimal > 0)
    {
        return String(val, decimal) + getTextValueSuffix();
    }
    return String(roundToInt(val)) + getTextValueSuffix();
}