本文整理汇总了Java中moa.core.DoubleVector.normalize方法的典型用法代码示例。如果您正苦于以下问题:Java DoubleVector.normalize方法的具体用法?Java DoubleVector.normalize怎么用?Java DoubleVector.normalize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类moa.core.DoubleVector
的用法示例。
在下文中一共展示了DoubleVector.normalize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getVotesForInstance
import moa.core.DoubleVector; //导入方法依赖的package包/类
/**
* Predicts a class for an example.
*/
public double[] getVotesForInstance(Instance inst) {
DoubleVector combinedVote = new DoubleVector();
if (this.trainingWeightSeenByModel > 0.0) {
for (int i = 0; i < this.ensemble.length; i++) {
if (this.ensembleWeights[i] > 0.0) {
DoubleVector vote = new DoubleVector(this.ensemble[i].getVotesForInstance(inst));
if (vote.sumOfValues() > 0.0) {
vote.normalize();
//scale weight and prevent overflow
vote.scaleValues(this.ensembleWeights[i] / (1.0 * this.ensemble.length + 1));
combinedVote.addValues(vote);
}
}
}
}
combinedVote.normalize();
return combinedVote.getArrayRef();
}
示例2: getVotesForInstance
import moa.core.DoubleVector; //导入方法依赖的package包/类
public double[] getVotesForInstance(Instance inst) {
DoubleVector combinedVote = new DoubleVector();
for (int i = 0; i < this.ensemble.length; i++) {
double memberWeight = getEnsembleMemberWeight(i);
if (memberWeight > 0.0) {
DoubleVector vote = new DoubleVector(this.ensemble[i].getVotesForInstance(inst));
if (vote.sumOfValues() > 0.0) {
vote.normalize();
vote.scaleValues(memberWeight);
combinedVote.addValues(vote);
}
} else {
break;
}
}
return combinedVote.getArrayRef();
}
示例3: getVotesForInstance
import moa.core.DoubleVector; //导入方法依赖的package包/类
public double[] getVotesForInstance(Instance inst) {
DoubleVector combinedVote = new DoubleVector();
for (int i = 0; i < this.ensemble.length; i++) {
double memberWeight = getEnsembleMemberWeight(i);
if (memberWeight > 0.0) {
DoubleVector vote = new DoubleVector(this.ensemble[i].getVotesForInstance(inst));
if (vote.sumOfValues() > 0.0) {
vote.normalize();
vote.scaleValues(memberWeight);
combinedVote.addValues(vote);
}
} else {
break;
}
}
return combinedVote.getArrayRef();
}
示例4: getVotesForInstance
import moa.core.DoubleVector; //导入方法依赖的package包/类
public double[] getVotesForInstance(Instance inst) {
DoubleVector combinedVote = new DoubleVector();
if (this.trainingWeightSeenByModel > 0.0) {
for (int i = 0; i < this.ensemble.length; i++) {
if (this.ensembleWeights[i] > 0.0) {
DoubleVector vote = new DoubleVector(this.ensemble[i].getVotesForInstance(inst));
if (vote.sumOfValues() > 0.0) {
vote.normalize();
vote.scaleValues(this.ensembleWeights[i]);
combinedVote.addValues(vote);
}
}
}
}
return combinedVote.getArrayRef();
}
示例5: getVotesForInstance
import moa.core.DoubleVector; //导入方法依赖的package包/类
@Override
public double[] getVotesForInstance(Instance inst) {
DoubleVector combinedVote = new DoubleVector();
StringBuilder sb = null;
if (VerbosityOption.getValue()>1)
sb=new StringBuilder();
for (int i = 0; i < this.ensemble.length; i++) {
DoubleVector vote = new DoubleVector(this.ensemble[i].getVotesForInstance(transformInstance(inst,i)));
if (VerbosityOption.getValue()>1)
sb.append(vote.getValue(0) + ", ");
if (this.isRegression == false && vote.sumOfValues() != 0.0){
vote.normalize();
}
combinedVote.addValues(vote);
}
if (this.isRegression == true){
combinedVote.scaleValues(1.0/this.ensemble.length);
}
if (VerbosityOption.getValue()>1){
sb.append(combinedVote.getValue(0) + ", ").append(inst.classValue());
System.out.println(sb.toString());
}
return combinedVote.getArrayRef();
}
示例6: getVotesForInstance
import moa.core.DoubleVector; //导入方法依赖的package包/类
/**
* Predicts a class for an example.
*/
public double[] getVotesForInstance(Instance inst) {
DoubleVector combinedVote = new DoubleVector();
if (this.trainingWeightSeenByModel > 0.0) {
for (int i = 0; i < this.learners.length; i++) {
if (this.weights[i][0] > 0.0) {
DoubleVector vote = new DoubleVector(this.learners[(int) this.weights[i][1]].getVotesForInstance(inst));
if (vote.sumOfValues() > 0.0) {
vote.normalize();
// scale weight and prevent overflow
vote.scaleValues(this.weights[i][0] / (1.0 * this.learners.length + 1.0));
combinedVote.addValues(vote);
}
}
}
}
//combinedVote.normalize();
return combinedVote.getArrayRef();
}
示例7: getVotesForInstance
import moa.core.DoubleVector; //导入方法依赖的package包/类
@Override
public double[] getVotesForInstance(Instance instance) {
Instance testInstance = instance.copy();
if(this.ensemble == null)
initEnsemble(testInstance);
DoubleVector combinedVote = new DoubleVector();
for(int i = 0 ; i < this.ensemble.length ; ++i) {
DoubleVector vote = new DoubleVector(this.ensemble[i].getVotesForInstance(testInstance));
if (vote.sumOfValues() > 0.0) {
vote.normalize();
double acc = this.ensemble[i].evaluator.getPerformanceMeasurements()[1].getValue();
if(! this.disableWeightedVote.isSet() && acc > 0.0) {
for(int v = 0 ; v < vote.numValues() ; ++v) {
vote.setValue(v, vote.getValue(v) * acc);
}
}
combinedVote.addValues(vote);
}
}
return combinedVote.getArrayRef();
}
示例8: getVotesForInstance
import moa.core.DoubleVector; //导入方法依赖的package包/类
@Override
public double[] getVotesForInstance(Instance inst) {
DoubleVector combinedVote = new DoubleVector();
if (this.trainingWeightSeenByModel > 0.0) {
for (int i = 0; i < this.ensemble.size(); i++) {
if (this.ensembleWeights.get(i) > 0.0) {
DoubleVector vote = new DoubleVector(this.ensemble.get(i)
.getVotesForInstance(inst));
if (vote.sumOfValues() > 0.0) {
vote.normalize();
vote.scaleValues(this.ensembleWeights.get(i));
combinedVote.addValues(vote);
}
}
}
}
return combinedVote.getArrayRef();
}
示例9: getVotesForInstance
import moa.core.DoubleVector; //导入方法依赖的package包/类
/**
* Predicts a class for an example.
*/
public double[] getVotesForInstance(Instance inst) {
DoubleVector combinedVote = new DoubleVector();
if (this.trainingWeightSeenByModel > 0.0) {
for (int i = 0; i < this.ensemble.length; i++) {
if (this.weights[i][0] > 0.0) {
DoubleVector vote = new DoubleVector(this.ensemble[(int) this.weights[i][1]].classifier.getVotesForInstance(inst));
if (vote.sumOfValues() > 0.0) {
vote.normalize();
// scale weight and prevent overflow
vote.scaleValues(this.weights[i][0] / (1.0 * this.ensemble.length + 1.0));
combinedVote.addValues(vote);
}
}
}
}
//combinedVote.normalize();
return combinedVote.getArrayRef();
}
示例10: getVotesForInstance
import moa.core.DoubleVector; //导入方法依赖的package包/类
@Override
public double[] getVotesForInstance(Instance inst) {
if (this.outputCodesOption.isSet()) {
return getVotesForInstanceBinary(inst);
}
DoubleVector combinedVote = new DoubleVector();
for (int i = 0; i < this.ensemble.length; i++) {
double memberWeight = getEnsembleMemberWeight(i);
if (memberWeight > 0.0) {
DoubleVector vote = new DoubleVector(this.ensemble[i].getVotesForInstance(inst));
if (vote.sumOfValues() > 0.0) {
vote.normalize();
vote.scaleValues(memberWeight);
combinedVote.addValues(vote);
}
} else {
break;
}
}
return combinedVote.getArrayRef();
}
示例11: getVotesForInstance
import moa.core.DoubleVector; //导入方法依赖的package包/类
@Override
public double[] getVotesForInstance(Instance inst) {
DoubleVector combinedVote = new DoubleVector();
for (int i = 0; i < this.ensemble.length; i++) {
DoubleVector vote = new DoubleVector(this.ensemble[i].getVotesForInstance(inst));
if (vote.sumOfValues() > 0.0) {
vote.normalize();
combinedVote.addValues(vote);
}
}
return combinedVote.getArrayRef();
}
示例12: getVotesForInstance
import moa.core.DoubleVector; //导入方法依赖的package包/类
public double[] getVotesForInstance(Instance inst) {
DoubleVector combinedVote = new DoubleVector();
for (int i = 0; i < this.ensemble.length; i++) {
DoubleVector vote = new DoubleVector(this.ensemble[i].getVotesForInstance(inst));
if (vote.sumOfValues() > 0.0) {
vote.normalize();
if ((this.useWeightOption != null)
&& this.useWeightOption.isSet()) {
vote.scaleValues(1.0 / (this.error[i] * this.error[i]));
}
combinedVote.addValues(vote);
}
}
return combinedVote.getArrayRef();
}
示例13: getVotesForInstance
import moa.core.DoubleVector; //导入方法依赖的package包/类
@Override
public double[] getVotesForInstance(Instance inst) {
DoubleVector combinedVote = new DoubleVector();
ArrayList<Integer> arr;
int cmb = this.combinationOption.getChosenIndex();
if (cmb == 0)
arr = getMAXIndexes();
else
arr = getWVDIndexes();
if (this.trainingWeightSeenByModel > 0.0) {
for (int i = 0; i < arr.size(); i++) {
if (this.ensembleWeights[arr.get(i)].val > 0.0) {
DoubleVector vote = new DoubleVector(this.ensemble[arr.get(i)].getVotesForInstance(inst));
if (vote.sumOfValues() > 0.0) {
vote.normalize();
vote.scaleValues(this.ensembleWeights[arr.get(i)].val);
combinedVote.addValues(vote);
}
}
}
}
return combinedVote.getArrayRef();
}
示例14: getVotesForInstance
import moa.core.DoubleVector; //导入方法依赖的package包/类
@Override
public double[] getVotesForInstance(Instance inst) {
if (this.outputCodesOption.isSet()) {
return getVotesForInstanceBinary(inst);
}
DoubleVector combinedVote = new DoubleVector();
for (int i = 0; i < this.ensemble.length; i++) {
DoubleVector vote = new DoubleVector(this.ensemble[i].getVotesForInstance(inst));
if (vote.sumOfValues() > 0.0) {
vote.normalize();
combinedVote.addValues(vote);
}
}
return combinedVote.getArrayRef();
}
示例15: getMaxPosterior
import moa.core.DoubleVector; //导入方法依赖的package包/类
private double getMaxPosterior(double[] incomingPrediction) {
if (incomingPrediction.length > 1) {
DoubleVector vote = new DoubleVector(incomingPrediction);
if (vote.sumOfValues() > 0.0) {
vote.normalize();
}
incomingPrediction = vote.getArrayRef();
outPosterior = (incomingPrediction[Utils.maxIndex(incomingPrediction)]);
} else {
outPosterior = 0;
}
return outPosterior;
}