com.expleague.ml.func.FuncEnsemble Maven / Gradle / Ivy
package com.expleague.ml.func;
import com.expleague.commons.math.vectors.Vec;
import com.expleague.commons.math.Func;
import java.util.List;
/**
* User: qdeee
* Date: 09.04.14
*/
public class FuncEnsemble extends Ensemble implements Func{
public FuncEnsemble(final X[] models, final Vec weights) {
super(models, weights);
}
public FuncEnsemble(final List models, final double step) {
super(models, step);
}
@Override
public double value(final Vec x) {
double result = 0.;
double weightTotal = 0;
for (int i = 0; i < size(); i++) {
double weight = weights.get(i);
result += models[i].value(x) * weight;
weightTotal += weight;
}
return result / weightTotal;
}
@Override
public int dim() {
return super.xdim();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy