Skip to content

8 Library API

agudys edited this page Apr 22, 2025 · 1 revision

RuleKit 2 was implemented in Java 1.8 programming language. Unlike first version, it does not depend on the RapidMiner. The main classes provided by our library is adaa.analytics.rules.logic.rulegenerator.ExpertRule.

The JavaDoc documentation for RuleKit can be found here

7.1. Developing a new algorithm

The base class of all rule induction algorithms which work according to separate-and-conquer heuristic is AbstractSeparateAndConquer class contained in adaa.analytics.rules.logic.induction package. In the package there are three non-abstract classes derived from it which allow generation of classification, regression, and survival rules:

  • ClassificationSnC,
  • RegressionSnC,
  • SurvivalSnC.

These classes represent general algorithm pipelines and require additional objects describing how to grow and prune a single rule. These are contained in:

  • ClassificationFinder,
  • RegressionFinder,
  • SurvivalFinder,

classes, all derived from AbstractFinder.

In order to develop a new induction algorithm, one can derive directly from AbstractSeparateAndConquer class or use existing separate and conquer scheme and provide own finder module derived from AbstractFinder (or use both). All aforementioned classes have variants which take into account user's knowledge:

  • ClassificationExpertSnC,
  • RegressionExpertSnC,
  • SurvivalExpertSnC.
  • ClassificationExpertFinder,
  • RegressionExpertFinder,
  • SurvivalExpertFinder.

They can be derived when user-guided induction is required (note, that if none is specified, they just invoke base class members).

After implementing own induction algorithm, one has to integrate it into adaa.analytics.rules.logic.rulegenerator.ExpertRule class. In particular, there is a method prepareSncAndFinder reponsible for creating proper algorithm variants (classification/regression/survival) depending on the type of the input data:

 private void prepareSncAndFinder(IExampleSet exampleSet, Knowledge knowledge, InductionParameters params)
    {
        if (exampleSet.getAttributes().getColumnByRole(SurvivalRule.SURVIVAL_TIME_ROLE) != null) {
            // survival problem
            params.setInductionMeasure(new LogRank());
            params.setPruningMeasure(new LogRank());
            params.setVotingMeasure(new LogRank());
            finder = new SurvivalLogRankExpertFinder(params);
            snc = new SurvivalLogRankExpertSnC((SurvivalLogRankExpertFinder) finder, params, knowledge);
        } else if (exampleSet.getAttributes().getLabel().isNominal()) {
            // expert mode in classification problems
            finder = new ClassificationExpertFinder(params, knowledge);
            snc = new ClassificationExpertSnC((ClassificationExpertFinder) finder, params, knowledge);
        } else {
            // expert mode in regression problems
            finder = new RegressionExpertFinder(params);
            snc = new RegressionExpertSnC((RegressionExpertFinder) finder, params, knowledge);
        }
        snc.setOperatorCommandProxy(operatorCommandProxy);
    }
}

This fragment can be modified by adding newly-implemented algorithm (e.g., on the basis of the value of some parameter of the operator).