Class AMLPlanBuilder<L extends org.api4.java.ai.ml.core.learner.ISupervisedLearner<org.api4.java.ai.ml.core.dataset.supervised.ILabeledInstance,​org.api4.java.ai.ml.core.dataset.supervised.ILabeledDataset<? extends org.api4.java.ai.ml.core.dataset.supervised.ILabeledInstance>>,​B extends AMLPlanBuilder<L,​B>>

  • All Implemented Interfaces:
    IMLPlanBuilder<L,​B>, org.api4.java.common.control.ILoggingCustomizable
    Direct Known Subclasses:
    MLPlanSimpleBuilder

    public abstract class AMLPlanBuilder<L extends org.api4.java.ai.ml.core.learner.ISupervisedLearner<org.api4.java.ai.ml.core.dataset.supervised.ILabeledInstance,​org.api4.java.ai.ml.core.dataset.supervised.ILabeledDataset<? extends org.api4.java.ai.ml.core.dataset.supervised.ILabeledInstance>>,​B extends AMLPlanBuilder<L,​B>>
    extends java.lang.Object
    implements IMLPlanBuilder<L,​B>, org.api4.java.common.control.ILoggingCustomizable
    The MLPlanBuilder helps to easily configure and initialize ML-Plan with specific parameter settings. For convenient use, the MLPlanBuilder also offers methods for initializing ML-Plan with default configuration to use ML-Plan for single label classification in combination with WEKA or scikit-learn or for multi-label classification in combination with MEKA and consequently with WEKA (for baselearners of multi-label reduction strategies).
    • Constructor Detail

      • AMLPlanBuilder

        protected AMLPlanBuilder()
      • AMLPlanBuilder

        protected AMLPlanBuilder​(IProblemType<L> problemType)
                          throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • withProblemType

        public AMLPlanBuilder<L,​B> withProblemType​(IProblemType<L> problemType)
                                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • withPerformanceMeasureForSearchPhase

        public B withPerformanceMeasureForSearchPhase​(org.api4.java.ai.ml.core.evaluation.supervised.loss.IDeterministicPredictionPerformanceMeasure<?,​?> performanceMeasure)
      • withPerformanceMeasureForSelectionPhase

        public B withPerformanceMeasureForSelectionPhase​(org.api4.java.ai.ml.core.evaluation.supervised.loss.IDeterministicPredictionPerformanceMeasure<?,​?> performanceMeasure)
      • withPerformanceMeasure

        public B withPerformanceMeasure​(org.api4.java.ai.ml.core.evaluation.supervised.loss.IDeterministicPredictionPerformanceMeasure<?,​?> performanceMeasure)
      • getMetricForSearchPhase

        public org.api4.java.ai.ml.core.evaluation.supervised.loss.IDeterministicPredictionPerformanceMeasure<?,​?> getMetricForSearchPhase()
        Specified by:
        getMetricForSearchPhase in interface IMLPlanBuilder<L extends org.api4.java.ai.ml.core.learner.ISupervisedLearner<org.api4.java.ai.ml.core.dataset.supervised.ILabeledInstance,​org.api4.java.ai.ml.core.dataset.supervised.ILabeledDataset<? extends org.api4.java.ai.ml.core.dataset.supervised.ILabeledInstance>>,​B extends AMLPlanBuilder<L,​B>>
      • getMetricForSelectionPhase

        public org.api4.java.ai.ml.core.evaluation.supervised.loss.IDeterministicPredictionPerformanceMeasure<?,​?> getMetricForSelectionPhase()
        Specified by:
        getMetricForSelectionPhase in interface IMLPlanBuilder<L extends org.api4.java.ai.ml.core.learner.ISupervisedLearner<org.api4.java.ai.ml.core.dataset.supervised.ILabeledInstance,​org.api4.java.ai.ml.core.dataset.supervised.ILabeledDataset<? extends org.api4.java.ai.ml.core.dataset.supervised.ILabeledInstance>>,​B extends AMLPlanBuilder<L,​B>>
      • withPreferredComponentsFile

        public B withPreferredComponentsFile​(java.io.File preferredComponentsFile)
                                      throws java.io.IOException
        Creates a preferred node evaluator that can be used to prefer components over other components.
        Parameters:
        preferredComponentsFile - The file containing a priority list of component names.
        Returns:
        The builder object.
        Throws:
        java.io.IOException - Thrown if a problem occurs while trying to read the file containing the priority list.
      • withPreferredComponents

        public B withPreferredComponents​(java.util.List<java.lang.String> preferredComponents)
      • getPreferredComponents

        public java.util.List<java.lang.String> getPreferredComponents()
      • withPreferredNodeEvaluator

        public B withPreferredNodeEvaluator​(org.api4.java.ai.graphsearch.problem.pathsearch.pathevaluation.IPathEvaluator<ai.libs.jaicore.planning.hierarchical.algorithms.forwarddecomposition.graphgenerators.tfd.TFDNode,​java.lang.String,​java.lang.Double> preferredNodeEvaluator)
        This adds a new preferred node evaluator It is possible to specify several preferred node evaluators, which will be ordered by the order in which they are specified. The latest given evaluator is the most preferred one.
        Parameters:
        preferredNodeEvaluator -
        Returns:
      • getPreferredNodeEvaluators

        public java.util.List<org.api4.java.ai.graphsearch.problem.pathsearch.pathevaluation.IPathEvaluator<ai.libs.jaicore.planning.hierarchical.algorithms.forwarddecomposition.graphgenerators.tfd.TFDNode,​java.lang.String,​java.lang.Double>> getPreferredNodeEvaluators()
      • withSearchFactory

        public B withSearchFactory​(org.api4.java.ai.graphsearch.problem.IOptimalPathInORGraphSearchFactory searchFactory,
                                   ai.libs.jaicore.basic.algorithm.reduction.AlgorithmicProblemReduction transformer)
      • getComponents

        public ai.libs.jaicore.components.api.IComponentRepository getComponents()
                                                                          throws java.io.IOException
        Throws:
        java.io.IOException
      • getComponentParameterConfigurations

        public ai.libs.jaicore.components.api.INumericParameterRefinementConfigurationMap getComponentParameterConfigurations()
                                                                                                                       throws java.io.IOException
        Throws:
        java.io.IOException
      • withAlgorithmConfigFile

        public B withAlgorithmConfigFile​(java.io.File algorithmConfigFile)
        Loads the MLPlanClassifierConfig with default values and replaces all properties according to the properties defined in the given config file.
        Parameters:
        algorithmConfigFile - The file specifying the property values to replace the default configuration.
        Returns:
        The MLPlanBuilder object.
        Throws:
        java.io.IOException - An IOException is thrown if there are issues reading the config file.
      • withAlgorithmConfig

        public B withAlgorithmConfig​(MLPlanClassifierConfig config)
        Loads the MLPlanClassifierConfig with default values and replaces all properties according to the properties defined in the given config file.
        Parameters:
        config - The algorithm configuration.
        Returns:
        The MLPlanBuilder object.
        Throws:
        java.io.IOException - An IOException is thrown if there are issues reading the config file.
      • withDataset

        public B withDataset​(org.api4.java.ai.ml.core.dataset.supervised.ILabeledDataset<?> dataset)
        Set the data for which ML-Plan is supposed to find the best pipeline.
        Parameters:
        dataset - The dataset for which ML-Plan is to be run.
        Returns:
        The builder object.
      • getDataset

        public org.api4.java.ai.ml.core.dataset.supervised.ILabeledDataset<?> getDataset()
      • withSearchSpaceConfigFile

        public B withSearchSpaceConfigFile​(java.io.File searchSpaceConfig)
                                    throws java.io.IOException
        Specify the search space in which ML-Plan is required to work.
        Parameters:
        searchSpaceConfig - The file of the search space configuration.
        Returns:
        The builder object.
        Throws:
        java.io.IOException - Thrown if the given file does not exist.
      • withLearnerFactory

        public B withLearnerFactory​(ILearnerFactory<L> classifierFactory)
        Set the classifier factory that translates CompositionInstance objects to classifiers that can be evaluated.
        Parameters:
        classifierFactory - The classifier factory to be used to translate CompositionInstance objects to classifiers.
        Returns:
        The builder object.
      • withDatasetSplitterForSearchSelectionSplit

        public B withDatasetSplitterForSearchSelectionSplit​(org.api4.java.ai.ml.core.dataset.splitter.IFoldSizeConfigurableRandomDatasetSplitter<org.api4.java.ai.ml.core.dataset.supervised.ILabeledDataset<?>> datasetSplitter)
        Set the dataset splitter that is used for generating the holdout data portion that is put aside during search.
        Parameters:
        datasetSplitter - The dataset splitter to be used.
        Returns:
        The builder obect.
      • withRequestedInterface

        public B withRequestedInterface​(java.lang.String requestedInterface)
      • withTimeOut

        public B withTimeOut​(org.api4.java.algorithm.Timeout timeout)
        Parameters:
        timeout - The timeout for ML-Plan to search for the best classifier.
        Returns:
        The builder object.
      • getTimeOut

        public org.api4.java.algorithm.Timeout getTimeOut()
        Returns:
        The timeout for ML-Plan to search for the best classifier.
      • withTimeoutPrecautionOffsetInSeconds

        public B withTimeoutPrecautionOffsetInSeconds​(int seconds)
      • getTimeoutPrecautionOffsetInSeconds

        public int getTimeoutPrecautionOffsetInSeconds()
      • withNodeEvaluationTimeOut

        public B withNodeEvaluationTimeOut​(org.api4.java.algorithm.Timeout timeout)
        Parameters:
        timeout - The timeout for a single candidate evaluation.
        Returns:
        The builder object.
      • getNodeEvaluationTimeOut

        public org.api4.java.algorithm.Timeout getNodeEvaluationTimeOut()
        Returns:
        The timeout for ML-Plan to search for the best classifier.
      • withCandidateEvaluationTimeOut

        public B withCandidateEvaluationTimeOut​(org.api4.java.algorithm.Timeout timeout)
        Parameters:
        timeout - The timeout for a single candidate evaluation.
        Returns:
        The builder object.
      • getCandidateEvaluationTimeOut

        public org.api4.java.algorithm.Timeout getCandidateEvaluationTimeOut()
        Returns:
        The timeout for ML-Plan to search for the best classifier.
      • withMCCVBasedCandidateEvaluationInSearchPhase

        public B withMCCVBasedCandidateEvaluationInSearchPhase​(int numIterations,
                                                               double trainPortion)
      • withMCCVBasedCandidateEvaluationInSelectionPhase

        public B withMCCVBasedCandidateEvaluationInSelectionPhase​(int numIterations,
                                                                  double trainPortion)
      • getLearnerEvaluationFactoryForSearchPhase

        public ai.libs.jaicore.ml.core.evaluation.evaluator.factory.ISupervisedLearnerEvaluatorFactory<org.api4.java.ai.ml.core.dataset.supervised.ILabeledInstance,​org.api4.java.ai.ml.core.dataset.supervised.ILabeledDataset<? extends org.api4.java.ai.ml.core.dataset.supervised.ILabeledInstance>> getLearnerEvaluationFactoryForSearchPhase()
        Description copied from interface: IMLPlanBuilder
        This is the factory that will be used to create the pipeline evaluators for evaluation during search time
        Specified by:
        getLearnerEvaluationFactoryForSearchPhase in interface IMLPlanBuilder<L extends org.api4.java.ai.ml.core.learner.ISupervisedLearner<org.api4.java.ai.ml.core.dataset.supervised.ILabeledInstance,​org.api4.java.ai.ml.core.dataset.supervised.ILabeledDataset<? extends org.api4.java.ai.ml.core.dataset.supervised.ILabeledInstance>>,​B extends AMLPlanBuilder<L,​B>>
        Returns:
      • getLearnerEvaluationFactoryForSelectionPhase

        public ai.libs.jaicore.ml.core.evaluation.evaluator.factory.ISupervisedLearnerEvaluatorFactory<org.api4.java.ai.ml.core.dataset.supervised.ILabeledInstance,​org.api4.java.ai.ml.core.dataset.supervised.ILabeledDataset<? extends org.api4.java.ai.ml.core.dataset.supervised.ILabeledInstance>> getLearnerEvaluationFactoryForSelectionPhase()
        Description copied from interface: IMLPlanBuilder
        This is the factory that will be used to create the pipeline evaluators for evaluation during selection time
        Specified by:
        getLearnerEvaluationFactoryForSelectionPhase in interface IMLPlanBuilder<L extends org.api4.java.ai.ml.core.learner.ISupervisedLearner<org.api4.java.ai.ml.core.dataset.supervised.ILabeledInstance,​org.api4.java.ai.ml.core.dataset.supervised.ILabeledDataset<? extends org.api4.java.ai.ml.core.dataset.supervised.ILabeledInstance>>,​B extends AMLPlanBuilder<L,​B>>
        Returns:
      • withSearchPhaseEvaluatorFactory

        public void withSearchPhaseEvaluatorFactory​(ai.libs.jaicore.ml.core.evaluation.evaluator.factory.ISupervisedLearnerEvaluatorFactory<org.api4.java.ai.ml.core.dataset.supervised.ILabeledInstance,​org.api4.java.ai.ml.core.dataset.supervised.ILabeledDataset<? extends org.api4.java.ai.ml.core.dataset.supervised.ILabeledInstance>> evaluatorFactory)
        Sets the evaluator factory for the search phase.
        Parameters:
        evaluatorFactory - The evaluator factory for the search phase.
      • getSearchEvaluatorFactory

        protected ai.libs.jaicore.ml.core.evaluation.evaluator.factory.ISupervisedLearnerEvaluatorFactory<org.api4.java.ai.ml.core.dataset.supervised.ILabeledInstance,​org.api4.java.ai.ml.core.dataset.supervised.ILabeledDataset<? extends org.api4.java.ai.ml.core.dataset.supervised.ILabeledInstance>> getSearchEvaluatorFactory()
        Returns:
        The factory for the classifier evaluator of the search phase.
      • withSelectionPhaseEvaluatorFactory

        public B withSelectionPhaseEvaluatorFactory​(ai.libs.jaicore.ml.core.evaluation.evaluator.factory.ISupervisedLearnerEvaluatorFactory<org.api4.java.ai.ml.core.dataset.supervised.ILabeledInstance,​org.api4.java.ai.ml.core.dataset.supervised.ILabeledDataset<? extends org.api4.java.ai.ml.core.dataset.supervised.ILabeledInstance>> evaluatorFactory)
        Sets the evaluator factory for the selection phase.
        Parameters:
        evaluatorFactory - The evaluator factory for the selection phase.
        Returns:
        The builder object.
      • withNumCpus

        public B withNumCpus​(int numCpus)
        Sets the number of cpus that may be used by ML-Plan.
        Parameters:
        numCpus - The number of cpus to use.
        Returns:
        The builder object.
      • withSeed

        public B withSeed​(long seed)
      • getSelectionEvaluatorFactory

        protected ai.libs.jaicore.ml.core.evaluation.evaluator.factory.ISupervisedLearnerEvaluatorFactory<org.api4.java.ai.ml.core.dataset.supervised.ILabeledInstance,​org.api4.java.ai.ml.core.dataset.supervised.ILabeledDataset<? extends org.api4.java.ai.ml.core.dataset.supervised.ILabeledInstance>> getSelectionEvaluatorFactory()
        Returns:
        The factory for the classifier evaluator of the selection phase.
      • getHASCOFactory

        public ai.libs.hasco.builder.forwarddecomposition.HASCOViaFDBuilder<java.lang.Double,​?> getHASCOFactory()
        Specified by:
        getHASCOFactory in interface IMLPlanBuilder<L extends org.api4.java.ai.ml.core.learner.ISupervisedLearner<org.api4.java.ai.ml.core.dataset.supervised.ILabeledInstance,​org.api4.java.ai.ml.core.dataset.supervised.ILabeledDataset<? extends org.api4.java.ai.ml.core.dataset.supervised.ILabeledInstance>>,​B extends AMLPlanBuilder<L,​B>>
      • getLearnerFactory

        public ILearnerFactory<L> getLearnerFactory()
        Specified by:
        getLearnerFactory in interface IMLPlanBuilder<L extends org.api4.java.ai.ml.core.learner.ISupervisedLearner<org.api4.java.ai.ml.core.dataset.supervised.ILabeledInstance,​org.api4.java.ai.ml.core.dataset.supervised.ILabeledDataset<? extends org.api4.java.ai.ml.core.dataset.supervised.ILabeledInstance>>,​B extends AMLPlanBuilder<L,​B>>
      • getLoggerName

        public java.lang.String getLoggerName()
        Specified by:
        getLoggerName in interface org.api4.java.common.control.ILoggingCustomizable
      • setLoggerName

        public void setLoggerName​(java.lang.String name)
        Specified by:
        setLoggerName in interface org.api4.java.common.control.ILoggingCustomizable
      • getRequestedInterface

        public java.lang.String getRequestedInterface()
        Specified by:
        getRequestedInterface in interface IMLPlanBuilder<L extends org.api4.java.ai.ml.core.learner.ISupervisedLearner<org.api4.java.ai.ml.core.dataset.supervised.ILabeledInstance,​org.api4.java.ai.ml.core.dataset.supervised.ILabeledDataset<? extends org.api4.java.ai.ml.core.dataset.supervised.ILabeledInstance>>,​B extends AMLPlanBuilder<L,​B>>
      • getSearchSelectionDatasetSplitter

        public org.api4.java.ai.ml.core.dataset.splitter.IFoldSizeConfigurableRandomDatasetSplitter<org.api4.java.ai.ml.core.dataset.supervised.ILabeledDataset<?>> getSearchSelectionDatasetSplitter()
        Description copied from interface: IMLPlanBuilder
        This is the splitter that splits the given input data into data for the search phase and for the selection phase
        Specified by:
        getSearchSelectionDatasetSplitter in interface IMLPlanBuilder<L extends org.api4.java.ai.ml.core.learner.ISupervisedLearner<org.api4.java.ai.ml.core.dataset.supervised.ILabeledInstance,​org.api4.java.ai.ml.core.dataset.supervised.ILabeledDataset<? extends org.api4.java.ai.ml.core.dataset.supervised.ILabeledInstance>>,​B extends AMLPlanBuilder<L,​B>>
        Returns:
      • getSearchSpaceConfigFile

        public java.io.File getSearchSpaceConfigFile()
        Specified by:
        getSearchSpaceConfigFile in interface IMLPlanBuilder<L extends org.api4.java.ai.ml.core.learner.ISupervisedLearner<org.api4.java.ai.ml.core.dataset.supervised.ILabeledInstance,​org.api4.java.ai.ml.core.dataset.supervised.ILabeledDataset<? extends org.api4.java.ai.ml.core.dataset.supervised.ILabeledInstance>>,​B extends AMLPlanBuilder<L,​B>>
      • getAlgorithmConfig

        public MLPlanClassifierConfig getAlgorithmConfig()
        Specified by:
        getAlgorithmConfig in interface IMLPlanBuilder<L extends org.api4.java.ai.ml.core.learner.ISupervisedLearner<org.api4.java.ai.ml.core.dataset.supervised.ILabeledInstance,​org.api4.java.ai.ml.core.dataset.supervised.ILabeledDataset<? extends org.api4.java.ai.ml.core.dataset.supervised.ILabeledInstance>>,​B extends AMLPlanBuilder<L,​B>>
      • withPortionOfDataReservedForSelection

        public B withPortionOfDataReservedForSelection​(double value)
      • getPortionOfDataReservedForSelectionPhase

        public double getPortionOfDataReservedForSelectionPhase()
        Specified by:
        getPortionOfDataReservedForSelectionPhase in interface IMLPlanBuilder<L extends org.api4.java.ai.ml.core.learner.ISupervisedLearner<org.api4.java.ai.ml.core.dataset.supervised.ILabeledInstance,​org.api4.java.ai.ml.core.dataset.supervised.ILabeledDataset<? extends org.api4.java.ai.ml.core.dataset.supervised.ILabeledInstance>>,​B extends AMLPlanBuilder<L,​B>>
      • getSafeGuardFactory

        public IEvaluationSafeGuardFactory getSafeGuardFactory()
        Specified by:
        getSafeGuardFactory in interface IMLPlanBuilder<L extends org.api4.java.ai.ml.core.learner.ISupervisedLearner<org.api4.java.ai.ml.core.dataset.supervised.ILabeledInstance,​org.api4.java.ai.ml.core.dataset.supervised.ILabeledDataset<? extends org.api4.java.ai.ml.core.dataset.supervised.ILabeledInstance>>,​B extends AMLPlanBuilder<L,​B>>
      • build

        public MLPlan<L> build​(org.api4.java.ai.ml.core.dataset.supervised.ILabeledDataset<?> dataset)
        Builds an ML-Plan object for the given dataset as input.
        Parameters:
        dataset - The dataset for which an ML-Plan object is to be built.
        Returns:
        The ML-Plan object configured with this builder.
      • checkPreconditionsForInitialization

        public void checkPreconditionsForInitialization()
      • build

        public MLPlan<L> build()
        Builds an ML-Plan object with the dataset provided earlier to this builder.
        Returns:
        The ML-Plan object configured with this builder.