本文整理了Java中weka.core.Utils.sum()
方法的一些代码示例,展示了Utils.sum()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.sum()
方法的具体详情如下:
包路径:weka.core.Utils
类名称:Utils
方法名:sum
[英]Computes the sum of the elements of an array of doubles.
[中]计算一个双精度数组的元素之和。
代码示例来源:origin: net.sf.meka.thirdparty/mulan
/**
* The number of set members. Calculated on first call and
* cached for subsequent calls.
* @return The number of set members
*/
public int size() {
if (size == -1) {
size = Utils.sum(labelSet);
}
return size;
}
代码示例来源:origin: net.sf.meka.thirdparty/mulan
/**
* Gets the squared error for all clusters
*
* @return the squared error
*/
public double getSquaredError() {
return Utils.sum(m_squaredErrors);
}
代码示例来源:origin: Waikato/weka-trunk
/**
* Gets the squared error for all clusters.
*
* @return the squared error, NaN if fast distance calculation is used
* @see #m_FastDistanceCalc
*/
public double getSquaredError() {
if (m_FastDistanceCalc) {
return Double.NaN;
} else {
return Utils.sum(m_squaredErrors);
}
}
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
/**
* Gets the squared error for all clusters.
*
* @return the squared error, NaN if fast distance calculation is used
* @see #m_FastDistanceCalc
*/
public double getSquaredError() {
if (m_FastDistanceCalc) {
return Double.NaN;
} else {
return Utils.sum(m_squaredErrors);
}
}
代码示例来源:origin: net.sf.meka/meka
/**
* EmptyVectors - percentage of empty vectors sum(y[i])==0 in Y.
*/
public static final double emptyVectors(int Y[][]) {
int N = Y.length;
int L = Y[0].length;
double sum = 0.0;
for(int i = 0; i < N; i++) {
if (Utils.sum(Y[i]) <= 0.0)
sum ++;
}
return (double)sum/(double)N;
}
代码示例来源:origin: Waikato/meka
/**
* EmptyVectors - percentage of empty vectors sum(y[i])==0 in Y.
*/
public static final double emptyVectors(int Y[][]) {
int N = Y.length;
int L = Y[0].length;
double sum = 0.0;
for(int i = 0; i < N; i++) {
if (Utils.sum(Y[i]) <= 0.0)
sum ++;
}
return (double)sum/(double)N;
}
代码示例来源:origin: Waikato/weka-trunk
/**
* Adds counts to given bag.
*/
public final void add(int bagIndex, double[] counts) {
double sum = Utils.sum(counts);
for (int i = 0; i < counts.length; i++) {
m_perClassPerBag[bagIndex][i] += counts[i];
}
m_perBag[bagIndex] = m_perBag[bagIndex] + sum;
for (int i = 0; i < counts.length; i++) {
m_perClass[i] = m_perClass[i] + counts[i];
}
totaL = totaL + sum;
}
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
/**
* Adds counts to given bag.
*/
public final void add(int bagIndex, double[] counts) {
double sum = Utils.sum(counts);
for (int i = 0; i < counts.length; i++) {
m_perClassPerBag[bagIndex][i] += counts[i];
}
m_perBag[bagIndex] = m_perBag[bagIndex] + sum;
for (int i = 0; i < counts.length; i++) {
m_perClass[i] = m_perClass[i] + counts[i];
}
totaL = totaL + sum;
}
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
double eval(double[] args) {
return Utils.sum(args);
}
代码示例来源:origin: Waikato/weka-trunk
double eval(double[] args) {
return Utils.sum(args);
}
代码示例来源:origin: net.sf.meka.thirdparty/mulan
public double getValue() {
double tp = Utils.sum(truePositives);
double fp = Utils.sum(falsePositives);
double fn = Utils.sum(falseNegatives);
return InformationRetrievalMeasures.precision(tp, fp, fn);
}
代码示例来源:origin: net.sf.meka.thirdparty/mulan
public double getValue() {
double tn = Utils.sum(trueNegatives);
double fp = Utils.sum(falsePositives);
double fn = Utils.sum(falseNegatives);
return InformationRetrievalMeasures.specificity(tn, fp, fn);
}
代码示例来源:origin: net.sf.meka.thirdparty/mulan
public double getValue() {
double tp = Utils.sum(truePositives);
double fp = Utils.sum(falsePositives);
double fn = Utils.sum(falseNegatives);
return InformationRetrievalMeasures.fMeasure(tp, fp, fn, beta);
}
代码示例来源:origin: net.sf.meka.thirdparty/mulan
public double getValue() {
double tp = Utils.sum(truePositives);
double fp = Utils.sum(falsePositives);
double fn = Utils.sum(falseNegatives);
return InformationRetrievalMeasures.recall(tp, fp, fn);
}
代码示例来源:origin: sc.fiji/Trainable_Segmentation
/**
* Normalizes branch sizes so they contain frequencies (stored in "props")
* instead of counts (stored in "dist"). Creates a new double[] which it
* returns.
*/
protected static double[] countsToFreqs( double[][] dist ) {
double[] props = new double[dist.length];
for (int k = 0; k < props.length; k++) {
props[k] = Utils.sum(dist[k]);
}
if (Utils.eq(Utils.sum(props), 0)) {
for (int k = 0; k < props.length; k++) {
props[k] = 1.0 / (double) props.length;
}
} else {
FastRfUtils.normalize(props);
}
return props;
}
代码示例来源:origin: sc.fiji/Trainable_Segmentation
/**
* Normalizes branch sizes so they contain frequencies (stored in "props")
* instead of counts (stored in "dist"). <p>
*
* Overwrites the supplied "props"! <p>
*
* props.length must be == dist.length.
*/
protected static void countsToFreqs( double[][] dist, double[] props ) {
for (int k = 0; k < props.length; k++) {
props[k] = Utils.sum(dist[k]);
}
if (Utils.eq(Utils.sum(props), 0)) {
for (int k = 0; k < props.length; k++) {
props[k] = 1.0 / (double) props.length;
}
} else {
FastRfUtils.normalize(props);
}
}
代码示例来源:origin: fiji/Trainable_Segmentation
/**
* Normalizes branch sizes so they contain frequencies (stored in "props")
* instead of counts (stored in "dist"). Creates a new double[] which it
* returns.
*/
protected static double[] countsToFreqs( double[][] dist ) {
double[] props = new double[dist.length];
for (int k = 0; k < props.length; k++) {
props[k] = Utils.sum(dist[k]);
}
if (Utils.eq(Utils.sum(props), 0)) {
for (int k = 0; k < props.length; k++) {
props[k] = 1.0 / (double) props.length;
}
} else {
FastRfUtils.normalize(props);
}
return props;
}
代码示例来源:origin: fiji/Trainable_Segmentation
/**
* Normalizes branch sizes so they contain frequencies (stored in "props")
* instead of counts (stored in "dist"). <p>
*
* Overwrites the supplied "props"! <p>
*
* props.length must be == dist.length.
*/
protected static void countsToFreqs( double[][] dist, double[] props ) {
for (int k = 0; k < props.length; k++) {
props[k] = Utils.sum(dist[k]);
}
if (Utils.eq(Utils.sum(props), 0)) {
for (int k = 0; k < props.length; k++) {
props[k] = 1.0 / (double) props.length;
}
} else {
FastRfUtils.normalize(props);
}
}
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
/**
* Classifies a given instance. Either this or distributionForInstance() needs
* to be implemented by subclasses.
*
* @param instance the instance to be assigned to a cluster
* @return the number of the assigned cluster as an integer
* @exception Exception if instance could not be clustered successfully
*/
@Override
public int clusterInstance(Instance instance) throws Exception {
double[] dist = distributionForInstance(instance);
if (dist == null) {
throw new Exception("Null distribution predicted");
}
if (Utils.sum(dist) <= 0) {
throw new Exception("Unable to cluster instance");
}
return Utils.maxIndex(dist);
}
代码示例来源:origin: Waikato/weka-trunk
/**
* Classifies a given instance. Either this or distributionForInstance() needs
* to be implemented by subclasses.
*
* @param instance the instance to be assigned to a cluster
* @return the number of the assigned cluster as an integer
* @exception Exception if instance could not be clustered successfully
*/
@Override
public int clusterInstance(Instance instance) throws Exception {
double[] dist = distributionForInstance(instance);
if (dist == null) {
throw new Exception("Null distribution predicted");
}
if (Utils.sum(dist) <= 0) {
throw new Exception("Unable to cluster instance");
}
return Utils.maxIndex(dist);
}
内容来源于网络,如有侵权,请联系作者删除!