本文整理汇总了Java中moa.core.DoubleVector.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java DoubleVector.getValue方法的具体用法?Java DoubleVector.getValue怎么用?Java DoubleVector.getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类moa.core.DoubleVector
的用法示例。
在下文中一共展示了DoubleVector.getValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: computeClassDistPerValue
import moa.core.DoubleVector; //导入方法依赖的package包/类
private void computeClassDistPerValue(double[][] classDistLower,
double[][] classDistUpper) {
double estimator, classDistError;
int numberOfValues = classDistLower.length;
int numberOfClasses = classDistLower[0].length;
for (int i = 0; i < numberOfValues; i++) {
for (int j = 0; j < numberOfClasses; j++) {
if (attValueDist.getValue(i) == 0.0) {
classDistLower[i][j] = 0.0;
classDistUpper[i][j] = 1.0;
} else {
DoubleVector classCounter = nominalAttClassObserver.get(i);
double attValuePerClassCounter = classCounter != null ? classCounter.getValue(j) : 0.0;
estimator = attValuePerClassCounter / attValueDist.getValue(i);
classDistError = IademCommonProcedures.getIADEM_HoeffdingBound(estimator, attValueDist.getValue(i));
classDistLower[i][j] = Math.max(0.0, estimator - classDistError);
classDistUpper[i][j] = Math.min(1.0, estimator + classDistError);
}
}
}
}
示例2: doNaiveBayesPrediction
import moa.core.DoubleVector; //导入方法依赖的package包/类
public static double[] doNaiveBayesPrediction(Instance inst,
DoubleVector observedClassDistribution,
AutoExpandVector<AttributeClassObserver> attributeObservers) {
double[] votes = new double[observedClassDistribution.numValues()];
double observedClassSum = observedClassDistribution.sumOfValues();
for (int classIndex = 0; classIndex < votes.length; classIndex++) {
votes[classIndex] = observedClassDistribution.getValue(classIndex)
/ observedClassSum;
for (int attIndex = 0; attIndex < inst.numAttributes() - 1; attIndex++) {
int instAttIndex = modelAttIndexToInstanceAttIndex(attIndex,
inst);
AttributeClassObserver obs = attributeObservers.get(attIndex);
if ((obs != null) && !inst.isMissing(instAttIndex)) {
votes[classIndex] *= obs.probabilityOfAttributeValueGivenClass(inst.value(instAttIndex), classIndex);
}
}
}
// TODO: need logic to prevent underflow?
return votes;
}
示例3: getBestSecondBestEntropy
import moa.core.DoubleVector; //导入方法依赖的package包/类
protected double [] getBestSecondBestEntropy(DoubleVector entropy){
double[] entropyValues = new double[2];
double best = Double.MAX_VALUE;
double secondBest = Double.MAX_VALUE;
for (int i = 0; i < entropy.numValues(); i++) {
if (entropy.getValue(i) < best) {
secondBest = best;
best = entropy.getValue(i);
} else{
if (entropy.getValue(i) < secondBest) {
secondBest = entropy.getValue(i);
}
}
}
entropyValues[0] = best;
entropyValues[1] = secondBest;
return entropyValues;
}
示例4: getModelMeasurementsImpl
import moa.core.DoubleVector; //导入方法依赖的package包/类
/**
* print GUI evaluate model
*/
@Override
protected Measurement[] getModelMeasurementsImpl() {
Measurement[] m=null;
Measurement[] mNoFeatureRanking=new Measurement[]{
new Measurement("anomaly detections", this.numAnomaliesDetected),
new Measurement("change detections", this.numChangesDetected),
new Measurement("rules (number)", this.ruleSet.size()+1),
new Measurement("Avg #inputs/rule", getAverageInputs()),
new Measurement("Avg #outputs/rule", getAverageOutputs())};
if(featureRanking instanceof NoFeatureRanking){
m=mNoFeatureRanking;
}
else{
m=new Measurement[mNoFeatureRanking.length+this.nAttributes];
for(int i=0; i<mNoFeatureRanking.length; i++)
m[i]=mNoFeatureRanking[i];
DoubleVector rankings=this.featureRanking.getFeatureRankings();
for(int i=0; i<this.nAttributes; i++)
m[i+mNoFeatureRanking.length]=new Measurement("Attribute" + i, rankings.getValue(i));
}
return m;
}
示例5: getMeritOfSplitForOutput
import moa.core.DoubleVector; //导入方法依赖的package包/类
protected double getMeritOfSplitForOutput(DoubleVector preSplitDist, DoubleVector[] postSplitDists) {
double merit=0;
//count number of branches with weightSeen higher than threshold
int count = 0;
for(int i = 0; i < postSplitDists.length; i++)
if(postSplitDists[i].getValue(0) >=0.05*preSplitDist.getValue(0))
count = count +1;
//Consider split if all branches have required weight seen
if(count == postSplitDists.length){
double varPreSplit=Utils.computeVariance(preSplitDist);
double sumVarPostSplit=0;
double weightTotal=0;
for (int i=0; i<postSplitDists.length;i++){
weightTotal+=postSplitDists[i].getValue(0);
}
double [] variances=getBranchSplitVarianceOutput(postSplitDists);
for(int i = 0; i < variances.length; i++)
if(postSplitDists[i].getValue(0)>0)
sumVarPostSplit+=(postSplitDists[i].getValue(0)/weightTotal*variances[i]); //weight variance
merit=(1-sumVarPostSplit/varPreSplit);
}
/*if(merit<0 || merit>1)
System.out.println("out of range");*/
return merit;
}
示例6: getMeritOfSplitForOutput
import moa.core.DoubleVector; //导入方法依赖的package包/类
protected double getMeritOfSplitForOutput(DoubleVector preSplitDist, DoubleVector[] postSplitDists) {
double merit=0;
//count number of branches with weightSeen higher than threshold
int count = 0;
for(int i = 0; i < postSplitDists.length; i++)
if(postSplitDists[i].getValue(0) >=0.05*preSplitDist.getValue(0))
count = count +1;
//Consider split if all branches have required weight seen
if(count == postSplitDists.length){
double varPreSplit=computeVariance(preSplitDist);
double sumVarPostSplit=0;
double weightTotal=0;
for (int i=0; i<postSplitDists.length;i++){
weightTotal+=postSplitDists[i].getValue(0);
}
double [] variances=getBranchSplitVarianceOutput(postSplitDists);
for(int i = 0; i < variances.length; i++)
if(postSplitDists[i].getValue(0)>0)
sumVarPostSplit+=(postSplitDists[i].getValue(0)/weightTotal*variances[i]); //weight variance
merit= 1 - sumVarPostSplit / varPreSplit;
}
/*if(merit<0 || merit>1)
System.out.println("out of range");*/
return merit;
}
示例7: dotProd
import moa.core.DoubleVector; //导入方法依赖的package包/类
protected static double dotProd(Instance inst1, DoubleVector weights, int classIndex) {
double result = 0;
int n1 = inst1.numValues();
int n2 = weights.numValues();
for (int p1 = 0, p2 = 0; p1 < n1 && p2 < n2;) {
int ind1 = inst1.index(p1);
int ind2 = p2;
if (ind1 == ind2) {
if (ind1 != classIndex && !inst1.isMissingSparse(p1)) {
result += inst1.valueSparse(p1) * weights.getValue(p2);
}
p1++;
p2++;
} else if (ind1 > ind2) {
p2++;
} else {
p1++;
}
}
return (result);
}
示例8: scalarProduct
import moa.core.DoubleVector; //导入方法依赖的package包/类
public double scalarProduct(DoubleVector u, DoubleVector v) {
double ret = 0.0;
for (int i = 0; i < Math.max(u.numValues(), v.numValues()); i++) {
ret += u.getValue(i) * v.getValue(i);
}
return ret;
}
示例9: getNaiveBayesPrediction
import moa.core.DoubleVector; //导入方法依赖的package包/类
protected double[] getNaiveBayesPrediction(Instance obs) {
double[] classVotes = getMajorityClassVotes(obs);
DoubleVector condProbabilities;
for (int i = 0; i < virtualChildren.size(); i++) {
VirtualNode currentVirtualNode = virtualChildren.get(i);
if (currentVirtualNode != null && currentVirtualNode.hasInformation()) {
double valor = obs.value(i);
condProbabilities = currentVirtualNode.computeConditionalProbability(valor);
if (condProbabilities != null) {
for (int j = 0; j < classVotes.length; j++) {
classVotes[j] *= condProbabilities.getValue(j);
}
}
}
}
// normalize class votes
double classVoteCount = 0.0;
for (int i = 0; i < classVotes.length; i++) {
classVoteCount += classVotes[i];
}
if (classVoteCount == 0.0) {
for (int i = 0; i < classVotes.length; i++) {
classVotes[i] = 1.0 / classVotes.length;
}
} else {
for (int i = 0; i < classVotes.length; i++) {
classVotes[i] /= classVoteCount;
}
}
return classVotes;
}
示例10: computeClassDistBinaryTest
import moa.core.DoubleVector; //导入方法依赖的package包/类
protected void computeClassDistBinaryTest(double[][][] classDistPerTestAndSplit_lower,
double[][][] classDistPerTestAndSplit_upper) {
int numberOfClasses = classDistPerTestAndSplit_lower[0][0].length;
double estimator, bound;
double leftTotal = this.classValueDist.sumOfValues();
for (int currentAttIndex = 0; currentAttIndex < classDistPerTestAndSplit_lower.length; currentAttIndex++) {
for (int j = 0; j < numberOfClasses; j++) {
// compute probabilities in the left branch
DoubleVector classCounter = nominalAttClassObserver.get(currentAttIndex);
double attClassCounter = classCounter != null ? classCounter.getValue(j) : 0.0;
if (attValueDist.getValue(currentAttIndex) != 0) {
estimator = attClassCounter / attValueDist.getValue(currentAttIndex);
bound = IademCommonProcedures.getIADEM_HoeffdingBound(estimator, attValueDist.getValue(currentAttIndex));
classDistPerTestAndSplit_lower[currentAttIndex][0][j] = Math.max(0.0, estimator - bound);
classDistPerTestAndSplit_upper[currentAttIndex][0][j] = Math.min(1.0, estimator + bound);
} else {
classDistPerTestAndSplit_lower[currentAttIndex][0][j] = 0.0;
classDistPerTestAndSplit_upper[currentAttIndex][0][j] = 1.0;
}
// compute probabilities in the right branch
attClassCounter = classValueDist.getValue(j) - attClassCounter;
double rightTotal = leftTotal - attValueDist.getValue(currentAttIndex);
if (rightTotal != 0) {
estimator = attClassCounter / rightTotal;
bound = IademCommonProcedures.getIADEM_HoeffdingBound(estimator, rightTotal);
classDistPerTestAndSplit_lower[currentAttIndex][1][j] = Math.max(0.0, estimator - bound);
classDistPerTestAndSplit_upper[currentAttIndex][1][j] = Math.min(1.0, estimator + bound);
} else {
classDistPerTestAndSplit_lower[currentAttIndex][1][j] = 0.0;
classDistPerTestAndSplit_upper[currentAttIndex][1][j] = 1.0;
}
}
}
}
示例11: getNaiveBayesPrediction
import moa.core.DoubleVector; //导入方法依赖的package包/类
protected double[] getNaiveBayesPrediction(Instance inst) {
double[] classDist = getMajorityClassVotes(inst);
DoubleVector conditionalProbability = null;
for (int i = 0; i < virtualChildren.size(); i++) {
VirtualNode virtual = virtualChildren.get(i);
if (virtual != null && virtual.hasInformation()) {
double currentValue = inst.value(i);
conditionalProbability = virtual.computeConditionalProbability(currentValue);
if (conditionalProbability != null) {
for (int j = 0; j < classDist.length; j++) {
classDist[j] *= conditionalProbability.getValue(j);
}
}
}
}
double sum = 0.0;
for (int i = 0; i < classDist.length; i++) {
sum += classDist[i];
}
if (sum == 0.0) {
for (int i = 0; i < classDist.length; i++) {
classDist[i] = 1.0 / classDist.length;
}
} else {
for (int i = 0; i < classDist.length; i++) {
classDist[i] /= sum;
}
}
return classDist;
}
示例12: oberversDistribProb
import moa.core.DoubleVector; //导入方法依赖的package包/类
protected double[] oberversDistribProb(Instance inst,
DoubleVector classDistrib) {
double[] votes = new double[this.numClass];
double sum = classDistrib.sumOfValues();
for (int z = 0; z < this.numClass; z++) {
votes[z] = classDistrib.getValue(z) / sum;
}
return votes;
}
示例13: getMeritOfSplitForOutput
import moa.core.DoubleVector; //导入方法依赖的package包/类
protected double getMeritOfSplitForOutput(DoubleVector preSplitDist, DoubleVector[] postSplitDists) {
double merit=0;
//count number of branches with weightSeen higher than threshold
int count = 0;
for(int i = 0; i < postSplitDists.length; i++)
if(postSplitDists[i].getValue(0) >=0.05*preSplitDist.getValue(0))
count = count +1;
//Consider split if all branches have required weight seen
if(count == postSplitDists.length){
double EntPreSplit=Utils.computeEntropy(preSplitDist);
double sumEntPostSplit=0;
double weightTotal=0;
for (int i=0; i<postSplitDists.length;i++){
weightTotal+=postSplitDists[i].getValue(0);
}
double [] Entropies=getBranchSplitEntropyOutput(postSplitDists);
for(int i = 0; i < Entropies.length; i++)
if(postSplitDists[i].getValue(0)>0)
sumEntPostSplit+=(postSplitDists[i].getValue(0)/weightTotal*Entropies[i]); //weight variance
merit=(EntPreSplit-sumEntPostSplit);
}
/*if(merit<0 || merit>1)
System.out.println("out of range");*/
return merit;
}
示例14: scalarProduct
import moa.core.DoubleVector; //导入方法依赖的package包/类
public static double scalarProduct(DoubleVector u, DoubleVector v) {
double ret = 0.0;
for (int i = 0; i < Math.max(u.numValues(), v.numValues()); i++) {
ret += u.getValue(i) * v.getValue(i);
}
return ret;
}
示例15: probabilityOfAttributeValueGivenClass
import moa.core.DoubleVector; //导入方法依赖的package包/类
@Override
public double probabilityOfAttributeValueGivenClass(double attVal,
int classVal) {
DoubleVector obs = this.attValDistPerClass.get(classVal);
return obs != null ? (obs.getValue((int) attVal) + 1.0)
/ (obs.sumOfValues() + obs.numValues()) : 0.0;
}