Java Code Examples for com.jstarcraft.ai.data.DataInstance#getWeight()

The following examples show how to use com.jstarcraft.ai.data.DataInstance#getWeight() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ArrayInstance.java    From jstarcraft-ai with Apache License 2.0 6 votes vote down vote up
public void copyInstance(DataInstance instance) {
    for (int index = 0; index < qualityOrder; index++) {
        this.qualityFeatures[index] = DataInstance.defaultInteger;
    }
    for (int index = 0; index < quantityOrder; index++) {
        this.quantityFeatures[index] = DataInstance.defaultFloat;
    }
    instance.iterateQualityFeatures((index, value) -> {
        this.qualityFeatures[index] = value;
    });
    instance.iterateQuantityFeatures((index, value) -> {
        this.quantityFeatures[index] = value;
    });
    this.qualityMark = instance.getQualityMark();
    this.quantityMark = instance.getQuantityMark();
    this.weight = instance.getWeight();
}
 
Example 2
Source File: HashInstance.java    From jstarcraft-ai with Apache License 2.0 5 votes vote down vote up
public void copyInstance(DataInstance instance) {
    this.qualityFeatures.clear();
    this.quantityFeatures.clear();
    instance.iterateQualityFeatures((index, value) -> {
        this.qualityFeatures.put(index, value);
    });
    instance.iterateQuantityFeatures((index, value) -> {
        this.quantityFeatures.put(index, value);
    });
    this.qualityMark = instance.getQualityMark();
    this.quantityMark = instance.getQuantityMark();
    this.weight = instance.getWeight();
}
 
Example 3
Source File: ZeroRuleRegressor.java    From jstarcraft-ai with Apache License 2.0 5 votes vote down vote up
@Override
public void practice(DataModule module, DataModule... contexts) {
    float markSum = 0F;
    float weightSum = 0F;
    for (DataInstance instance : module) {
        markSum += instance.getQuantityMark() * instance.getWeight();
        weightSum += instance.getWeight();
    }
    quantity = markSum / weightSum;
}
 
Example 4
Source File: ZeroRuleClassifier.java    From jstarcraft-ai with Apache License 2.0 5 votes vote down vote up
@Override
public void practice(DataModule module, DataModule... contexts) {
    float[] markSums = new float[dimension];
    for (DataInstance instance : module) {
        markSums[instance.getQualityMark()] += instance.getWeight();
    }
    float current = Float.MIN_VALUE;
    for (int index = 0; index < dimension; index++) {
        if (current < markSums[index]) {
            quality = index;
            current = markSums[index];
        }
    }
}