本文整理汇总了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)];
}