
io.github.ericmedvet.jgea.experimenter.builders.NumericalDatasets Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jgea.experimenter Show documentation
Show all versions of jgea.experimenter Show documentation
Experimenter tool based on jgea and textual config files (with jnb).
package io.github.ericmedvet.jgea.experimenter.builders;
import io.github.ericmedvet.jgea.problem.regression.NumericalDataset;
import io.github.ericmedvet.jgea.problem.regression.univariate.UnivariateRegressionFitness;
import io.github.ericmedvet.jgea.problem.regression.univariate.UnivariateRegressionProblem;
import io.github.ericmedvet.jnb.core.Param;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.List;
import java.util.function.Supplier;
/**
* @author "Eric Medvet" on 2023/05/01 for jgea
*/
public class NumericalDatasets {
private NumericalDatasets() {
}
@SuppressWarnings("unused")
public static Supplier empty(
@Param("xVars") List xVarNames,
@Param("yVars") List yVarNames
) {
return () -> new NumericalDataset(List.of(), xVarNames, yVarNames);
}
@SuppressWarnings("unused")
public static Supplier fromFile(
@Param("filePath") String filePath,
@Param(value = "folds", dIs = {0}) List folds,
@Param(value = "nFolds", dI = 1) int nFolds,
@Param(value = "xVarNamePattern", dS = "x.*") String xVarNamePattern,
@Param(value = "yVarNamePattern", dS = "y.*") String yVarNamePattern
) {
return () -> {
try {
return NumericalDataset
.loadFromCSV(new FileInputStream(filePath), xVarNamePattern, yVarNamePattern)
.folds(folds, nFolds);
} catch (IOException e) {
throw new RuntimeException(e);
}
};
}
@SuppressWarnings("unused")
public static Supplier fromProblem(
@Param("problem") UnivariateRegressionProblem problem
) {
return () -> problem.qualityFunction().getDataset();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy