本文整理汇总了Java中moa.core.DoubleVector类的典型用法代码示例。如果您正苦于以下问题:Java DoubleVector类的具体用法?Java DoubleVector怎么用?Java DoubleVector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DoubleVector类属于moa.core包,在下文中一共展示了DoubleVector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: insertEntry
import moa.core.DoubleVector; //导入依赖的package包/类
public void insertEntry(LearningEvaluation learningEvaluation) {
Measurement[] measurements = learningEvaluation.getMeasurements();
Measurement orderMeasurement = Measurement.getMeasurementNamed(
getOrderingMeasurementName(), measurements);
if (orderMeasurement == null) {
throw new IllegalArgumentException();
}
DoubleVector entryVals = new DoubleVector();
for (Measurement measurement : measurements) {
entryVals.setValue(addMeasurementName(measurement.getName()),
measurement.getValue());
}
double orderVal = orderMeasurement.getValue();
int index = 0;
while ((index < this.measurementValues.size())
&& (orderVal > this.measurementValues.get(index)[0])) {
index++;
}
this.measurementValues.add(index, entryVals.getArrayRef());
}
示例2: getPredictionForInstance
import moa.core.DoubleVector; //导入依赖的package包/类
@Override
public Prediction getPredictionForInstance(MultiLabelInstance instance) {
Prediction prediction=null;
double [] votes= new double[instance.numClasses()];
double vote;
if (this.hasStarted){
prediction=new MultiLabelPrediction(ensemble.length);
DoubleVector combinedVote = new DoubleVector();
for (int i = 0; i < this.ensemble.length; i++) {
vote= this.ensemble[i].getVotesForInstance(transformInstance(instance,i))[0];
prediction.setVote(i, 0, vote);
}
}
return prediction;
}
示例3: 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();
}
示例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 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();
}
示例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.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();
}
示例7: getBestSplitSuggestions
import moa.core.DoubleVector; //导入依赖的package包/类
/**
* Return the best split suggestions for this node using the given split criteria
*/
public AttributeExpansionSuggestion[] getBestSplitSuggestions(MultiLabelSplitCriterion criterion) {
List<AttributeExpansionSuggestion> bestSuggestions = new LinkedList<AttributeExpansionSuggestion>();
for (int i = 0; i < attributeObservers.size(); i++) {
AttributeStatisticsObserver obs = attributeObservers.get(i);
if (obs != null) {
DoubleVector[] preSplitStatistics = new DoubleVector[tree.getModelContext().numOutputAttributes()];
for (int j = 0; j < tree.getModelContext().numOutputAttributes(); j++) {
preSplitStatistics[j] = new DoubleVector();
preSplitStatistics[j].setValue(0, examplesSeen);
preSplitStatistics[j].setValue(1, sumOfValues.getValue(j));
preSplitStatistics[j].setValue(2, sumOfSquares.getValue(j));
}
AttributeExpansionSuggestion bestSuggestion = null;
bestSuggestion = obs.getBestEvaluatedSplitSuggestion(criterion, preSplitStatistics, i);
if (bestSuggestion != null) {
bestSuggestions.add(bestSuggestion);
}
}
}
return bestSuggestions.toArray(new AttributeExpansionSuggestion[bestSuggestions.size()]);
}
示例8: getBranchesSplitMerits
import moa.core.DoubleVector; //导入依赖的package包/类
@Override
public double [] getBranchesSplitMerits(DoubleVector[][] postSplitDists){
int numOutputs=postSplitDists.length;
int numBranches=postSplitDists[0].length;
double [] merits=new double[numBranches];
for(int j=0; j<numOutputs;j++)
{
double [] branchMeritsOutput=getBranchSplitVarianceOutput(postSplitDists[j]);
/* double weightTotal=0;
for (int i=0; i<numBranches;i++){
weightTotal+=postSplitDists[j][i].getValue(0)/weightTotal*postSplitDists[j][i].getValue(0);
}
for (int i=0; i<numBranches;i++){
merits[i]+=postSplitDists[j][i].getValue(0)/weightTotal*branchMeritsOutput[i];
}*/
for (int i=0; i<numBranches;i++){
if (postSplitDists[j][i].getValue(0)>0)
merits[i]-=branchMeritsOutput[i];
else
merits[i]=-Double.MAX_VALUE;
}
}
return merits;
}
示例9: 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);
}
}
}
}
示例10: 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;
}
示例11: getBranchesSplitMerits
import moa.core.DoubleVector; //导入依赖的package包/类
@Override
public double [] getBranchesSplitMerits(DoubleVector[][] postSplitDists){
int numOutputs=postSplitDists.length;
int numBranches=postSplitDists[0].length;
double [] merits=new double[numBranches];
for(int j=0; j<numOutputs;j++)
{
double [] branchMeritsOutput=getBranchSplitEntropyOutput(postSplitDists[j]);
for (int i=0; i<numBranches;i++){
if (postSplitDists[j][i].getValue(0)>0)
merits[i]-=branchMeritsOutput[i];
else
merits[i]=-Double.MAX_VALUE;
}
}
return merits;
}
示例12: 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);
}
示例13: getFeatureRankings
import moa.core.DoubleVector; //导入依赖的package包/类
@Override
public DoubleVector getFeatureRankings() {
/*DoubleVector normRankings=null;
if(attributeImportance!=null){
double total=0;
for (int i=0; i<attributeImportance.numValues();i++)
total+=attributeImportance.getValue(i);
//
normRankings=new DoubleVector();
double[] aux= new double[attributeImportance.numValues()];
for (int i=0; i<attributeImportance.numValues();i++)
aux[i]=attributeImportance.getValue(i)/total;
normRankings= new DoubleVector(aux);
}
return normRankings;
*/
if(attributeImportance==null)
return new DoubleVector();
return attributeImportance;
}
示例14: getClassDistsResultingFromMultiwaySplit
import moa.core.DoubleVector; //导入依赖的package包/类
public double[][] getClassDistsResultingFromMultiwaySplit(
int maxAttValsObserved) {
DoubleVector[] resultingDists = new DoubleVector[maxAttValsObserved];
for (int i = 0; i < resultingDists.length; i++) {
resultingDists[i] = new DoubleVector();
}
for (int i = 0; i < this.attValDistPerClass.size(); i++) {
DoubleVector attValDist = this.attValDistPerClass.get(i);
if (attValDist != null) {
for (int j = 0; j < attValDist.numValues(); j++) {
resultingDists[j].addToValue(i, attValDist.getValue(j));
}
}
}
double[][] distributions = new double[maxAttValsObserved][];
for (int i = 0; i < distributions.length; i++) {
distributions[i] = resultingDists[i].getArrayRef();
}
return distributions;
}
示例15: getClassDistsResultingFromBinarySplit
import moa.core.DoubleVector; //导入依赖的package包/类
public double[][] getClassDistsResultingFromBinarySplit(double splitValue) {
DoubleVector lhsDist = new DoubleVector();
DoubleVector rhsDist = new DoubleVector();
for (int i = 0; i < this.attValDistPerClass.size(); i++) {
GaussianEstimator estimator = this.attValDistPerClass.get(i);
if (estimator != null) {
if (splitValue < this.minValueObservedPerClass.getValue(i)) {
rhsDist.addToValue(i, estimator.getTotalWeightObserved());
} else if (splitValue >= this.maxValueObservedPerClass.getValue(i)) {
lhsDist.addToValue(i, estimator.getTotalWeightObserved());
} else {
double[] weightDist = estimator.estimatedWeight_LessThan_EqualTo_GreaterThan_Value(splitValue);
lhsDist.addToValue(i, weightDist[0] + weightDist[1]);
rhsDist.addToValue(i, weightDist[2]);
}
}
}
return new double[][]{lhsDist.getArrayRef(), rhsDist.getArrayRef()};
}