void TMultiClassifier::predictionAndDistribution(const TExample &ex,
		PValueList &classValues, PDistributionList &classDists) {
	if (computesProbabilities) {
		classDists = classDistribution(ex);
		PValueList classValues = new TValueList();
		TValue value;
		PVariable classVar;
		for (int i = 0; i < classVars->size(); i++) {
			classVar = classVars->at(i);
			value = classVar->varType == TValue::FLOATVAR ?
					TValue(classDists->at(i)->average()) :
					classDists->at(i)->highestProbValue(ex);
			classValues->push_back(value);
		}
	} else {
		classValues = operator()(ex);
		PDistributionList classDist = new TDistributionList();
		PDistribution dist;
		PVariable classVar;

		for (int i = 0; i < classVars->size(); i++) {
			classVar = classVars->at(i);
			dist = TDistribution::create(classVar);
			dist->add(classValues->at(i));
			classDist->push_back(dist);
		}

	}
}
Beispiel #2
0
void TClassifier::predictionAndDistribution(const TExample &ex, TValue &val, PDistribution &classDist)
{ if (computesProbabilities) {
    classDist = classDistribution(ex);
    val = classVar->varType==TValue::FLOATVAR ? TValue(classDist->average()) : classDist->highestProbValue(ex);
  }
  else {
    val = operator()(ex);
    classDist = TDistribution::create(classVar);
    classDist->add(val);
  }
}
PValueList TMultiClassifier::operator ()(const TExample &exam) {
	if (!computesProbabilities)
		raiseError("invalid setting of 'computesProbabilities'");

	PValueList classValues = new TValueList();
	TValue value;
	PVariable classVar;
	PDistributionList classDists = classDistribution(exam);

	for (int i = 0; i < classVars->size(); i++) {
		classVar = classVars->at(i);
		value = classVar->varType == TValue::FLOATVAR ?
				TValue(classDists->at(i)->average()) : classDists->at(i)->highestProbValue(exam);
		classValues->push_back(value);
	}

	return classValues;
}
Beispiel #4
0
TValue TClassifier::operator ()(const TExample &exam)
{ if (!computesProbabilities)
    raiseError("invalid setting of 'computesProbabilities'");

  return classVar->varType==TValue::FLOATVAR ? TValue(classDistribution(exam)->average()) : classDistribution(exam)->highestProbValue(exam);
}