本文整理匯總了Java中weka.core.Utils.logs2probs方法的典型用法代碼示例。如果您正苦於以下問題:Java Utils.logs2probs方法的具體用法?Java Utils.logs2probs怎麽用?Java Utils.logs2probs使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類weka.core.Utils
的用法示例。
在下文中一共展示了Utils.logs2probs方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: distributionForInstance
import weka.core.Utils; //導入方法依賴的package包/類
/**
* Calculates the class membership probabilities for the given test instance.
*
* @param instance the instance to be classified
* @return predicted class probability distribution
* @throws Exception if instance could not be classified successfully
*/
@Override
public double[] distributionForInstance(Instance instance) throws Exception {
// default model?
if (m_NumIterationsPerformed == 0) {
return m_ZeroR.distributionForInstance(instance);
}
if (m_NumIterationsPerformed == 0) {
throw new Exception("No model built");
}
double[] sums = new double[instance.numClasses()];
if (m_NumIterationsPerformed == 1) {
return m_Classifiers[0].distributionForInstance(instance);
} else {
for (int i = 0; i < m_NumIterationsPerformed; i++) {
sums[(int) m_Classifiers[i].classifyInstance(instance)] += m_Betas[i];
}
return Utils.logs2probs(sums);
}
}
示例2: convertInstance
import weka.core.Utils; //導入方法依賴的package包/類
/**
* Convert a single instance over. The converted instance is added to the end
* of the output queue.
*
* @param instance the instance to convert
* @throws Exception if something goes wrong
*/
protected void convertInstance(Instance instance) throws Exception {
// set up values
double[] instanceVals = new double[outputFormatPeek().numAttributes()];
double[] tempvals;
if (instance.classIndex() >= 0) {
tempvals = new double[outputFormatPeek().numAttributes() - 1];
} else {
tempvals = new double[outputFormatPeek().numAttributes()];
}
int pos = 0;
for (int j = 0; j < m_clusterers.length; j++) {
if (m_clusterers[j] != null) {
double[] probs;
if (m_removeAttributes != null) {
m_removeAttributes.input(instance);
probs = logs2densities(j, m_removeAttributes.output());
} else {
probs = logs2densities(j, instance);
}
System.arraycopy(probs, 0, tempvals, pos, probs.length);
pos += probs.length;
}
}
tempvals = Utils.logs2probs(tempvals);
System.arraycopy(tempvals, 0, instanceVals, 0, tempvals.length);
if (instance.classIndex() >= 0) {
instanceVals[instanceVals.length - 1] = instance.classValue();
}
push(new DenseInstance(instance.weight(), instanceVals));
}
示例3: distributionForInstance
import weka.core.Utils; //導入方法依賴的package包/類
/**
* Returns the cluster probability distribution for an instance.
*
* @param instance the instance to be clustered
* @return the probability distribution
* @throws Exception if computation fails
*/
public double[] distributionForInstance(Instance instance) throws Exception {
return Utils.logs2probs(logJointDensitiesForInstance(instance));
}