本文整理匯總了Java中weka.core.Utils.minIndex方法的典型用法代碼示例。如果您正苦於以下問題:Java Utils.minIndex方法的具體用法?Java Utils.minIndex怎麽用?Java Utils.minIndex使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類weka.core.Utils
的用法示例。
在下文中一共展示了Utils.minIndex方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: distributionForInstance
import weka.core.Utils; //導入方法依賴的package包/類
/**
* Returns class probabilities. When minimum expected cost approach is chosen,
* returns probability one for class with the minimum expected misclassification
* cost. Otherwise it returns the probability distribution returned by
* the base classifier.
*
* @param instance the instance to be classified
* @return the computed distribution for the given instance
* @throws Exception if instance could not be classified
* successfully */
public double[] distributionForInstance(Instance instance) throws Exception {
if (!m_MinimizeExpectedCost) {
return m_Classifier.distributionForInstance(instance);
}
double [] pred = m_Classifier.distributionForInstance(instance);
double [] costs = m_CostMatrix.expectedCosts(pred, instance);
/*
for (int i = 0; i < pred.length; i++) {
System.out.print(pred[i] + " ");
}
System.out.println();
for (int i = 0; i < costs.length; i++) {
System.out.print(costs[i] + " ");
}
System.out.println("\n");
*/
// This is probably not ideal
int classIndex = Utils.minIndex(costs);
for (int i = 0; i < pred.length; i++) {
if (i == classIndex) {
pred[i] = 1.0;
} else {
pred[i] = 0.0;
}
}
return pred;
}
示例2: getOuput
import weka.core.Utils; //導入方法依賴的package包/類
/**
* Compute the output. Either a probability distribution or a single
* value (regression).
*
* @param incoming the values from the last hidden layer
* @param preds the array to fill with predicted values
* @throws Exception if there is a problem computing the output
*/
protected void getOuput(HashMap<String, Double> incoming, double[] preds) throws Exception {
if (preds.length != m_outputNeurons.length) {
throw new Exception("[NeuralOutputs] Incorrect number of predictions requested: "
+ preds.length + "requested, " + m_outputNeurons.length + " expected");
}
for (int i = 0; i < m_outputNeurons.length; i++) {
Double neuronOut = incoming.get(m_outputNeurons[i]);
if (neuronOut == null) {
throw new Exception("[NeuralOutputs] Unable to find output neuron "
+ m_outputNeurons[i] + " in the incoming HashMap!!");
}
if (m_classAttribute.isNumeric()) {
// will be only one output neuron anyway
preds[0] = neuronOut.doubleValue();
preds[0] = m_regressionMapping.getResultInverse(preds);
} else {
// clip at zero
// preds[m_categoricalIndexes[i]] = (neuronOut < 0) ? 0.0 : neuronOut;
preds[m_categoricalIndexes[i]] = neuronOut;
}
}
if (m_classAttribute.isNominal()) {
// check for negative values and adjust
double min = preds[Utils.minIndex(preds)];
if (min < 0) {
for (int i = 0; i < preds.length; i++) {
preds[i] -= min;
}
}
// do a simplemax normalization
Utils.normalize(preds);
}
}
示例3: eval
import weka.core.Utils; //導入方法依賴的package包/類
double eval(double[] args) {
return args[Utils.minIndex(args)];
}