fcapy.ml.decision_lattice

This module provides ‘DecisionLatticeClassifier’ and ‘DecisionLatticeRegressor’ classes to use ‘ConceptLattice’ in a DecisionTree-like manner

Classes

DecisionLatticeClassifier([algo, …])

A class which combines DecisionTree ideas with Concept Lattice to solve Classification tasks

DecisionLatticePredictor([algo, …])

An abstract class to inherit ‘DecisionLatticeClassifier’ and ‘DecisionLatticeRegressor’ from

DecisionLatticeRegressor([algo, …])

A class which combines DecisionTree ideas with Concept Lattice to solve Regression tasks

class fcapy.ml.decision_lattice.DecisionLatticeClassifier(algo='Sofia', use_generators=False, algo_params=None, generators_algo='approximate', random_state=None)

A class which combines DecisionTree ideas with Concept Lattice to solve Classification tasks

fit(context):

Construct a concept lattice based on context and calculate interestingness measures to predict the context.target values (Inherited from DecisionLatticePredictor class)

predict(context)

Predict context.target labels based on context.data (Inherited from DecisionLatticePredictor class)

predict_proba(context)

Predict probabilities of context.target labels based on context.data

property algo_params

Dictionary of algorithm specific parameters

average_concepts_class_probabilities(concepts_i)

Average predictions of concepts with indexes concepts_i to get a final probability prediction

average_concepts_predictions(concepts_i)

Average label predictions of concepts with indexes concepts_i to get a final prediction

calc_concept_prediction_metrics(c_i, Y)

Calculate the target prediction for concept c_i based on ground truth targets Y

property class_names

Class names of the target values

compute_generators(context, algo, use_tqdm)

Compute generators of closed intents of concepts from the ConceptLattice

Parameters
  • context (FormalContext or MVContext) – A context to compute generators on

  • algo (str of {‘exact’, ‘approximate’}) – An algorithm to compute generators of closed intents. ‘exact’ works in exponential time but shows good result approximate works in a matter of milliseconds but shows awful result

  • use_tqdm (bool) – A flag whether to visualize the progress of the algorithm by tqdm bar

fit(context: fcapy.mvcontext.mvcontext.MVContext, use_tqdm=False)

Fit a DecisionLattice to the context

Parameters
  • context (FormalContext or MVContext) – A training context. Target values should be kept in context.target property

  • use_tqdm (bool) – A flag whether to visualize algorithm progress with tqdm bar

property lattice

The ConceptLattice used by the DecisionLattice model

predict(context: fcapy.mvcontext.mvcontext.MVContext, use_tqdm=False)

Use fitted model to predict target values of a context

Parameters
  • context (FormalContext or MVContext) – A context to predict

  • use_tqdm (bool) – A flag whether to visualize algorithm progress with tqdm bar

Returns

predictions – Prediction of target values for a given context

Return type

list of float

predict_proba(context: fcapy.mvcontext.mvcontext.MVContext)

Predict a target probability prediction for objects of context context

property use_generators

A flag whether to use closed intents of concepts (if set False) or their generators (o/w)

Can be changed after the model is fitted to the data

class fcapy.ml.decision_lattice.DecisionLatticePredictor(algo='Sofia', use_generators=False, algo_params=None, generators_algo='approximate', random_state=None)

An abstract class to inherit ‘DecisionLatticeClassifier’ and ‘DecisionLatticeRegressor’ from

fit(context):

Construct a concept lattice based on context and calculate interestingness measures to predict the context.target values

predict(context)

Predict context.target variables based on context.data

property algo_params

Dictionary of algorithm specific parameters

average_concepts_predictions(concepts_i)

Abstract function to instantiate in subclasses. Calculate an average prediction of a subset of concepts

calc_concept_prediction_metrics(c_i, Y)

Abstract function to instantiate in subclasses. Calculate the concept measure used for target prediction

compute_generators(context, algo, use_tqdm)

Compute generators of closed intents of concepts from the ConceptLattice

Parameters
  • context (FormalContext or MVContext) – A context to compute generators on

  • algo (str of {‘exact’, ‘approximate’}) – An algorithm to compute generators of closed intents. ‘exact’ works in exponential time but shows good result approximate works in a matter of milliseconds but shows awful result

  • use_tqdm (bool) – A flag whether to visualize the progress of the algorithm by tqdm bar

fit(context: fcapy.mvcontext.mvcontext.MVContext, use_tqdm=False)

Fit a DecisionLattice to the context

Parameters
  • context (FormalContext or MVContext) – A training context. Target values should be kept in context.target property

  • use_tqdm (bool) – A flag whether to visualize algorithm progress with tqdm bar

property lattice

The ConceptLattice used by the DecisionLattice model

predict(context: fcapy.mvcontext.mvcontext.MVContext, use_tqdm=False)

Use fitted model to predict target values of a context

Parameters
  • context (FormalContext or MVContext) – A context to predict

  • use_tqdm (bool) – A flag whether to visualize algorithm progress with tqdm bar

Returns

predictions – Prediction of target values for a given context

Return type

list of float

property use_generators

A flag whether to use closed intents of concepts (if set False) or their generators (o/w)

Can be changed after the model is fitted to the data

class fcapy.ml.decision_lattice.DecisionLatticeRegressor(algo='Sofia', use_generators=False, algo_params=None, generators_algo='approximate', random_state=None)

A class which combines DecisionTree ideas with Concept Lattice to solve Regression tasks

fit(context):

Construct a concept lattice based on context and calculate interestingness measures to predict the context.target values (Inherited from DecisionLatticePredictor class)

predict(context)

Predict context.target labels based on context.data (Inherited from DecisionLatticePredictor class)

property algo_params

Dictionary of algorithm specific parameters

average_concepts_predictions(concepts_i)

Average label predictions of concepts with indexes concepts_i to get a final prediction

calc_concept_prediction_metrics(c_i, Y)

Calculate the target prediction for concept `c_i based on ground truth targets Y

compute_generators(context, algo, use_tqdm)

Compute generators of closed intents of concepts from the ConceptLattice

Parameters
  • context (FormalContext or MVContext) – A context to compute generators on

  • algo (str of {‘exact’, ‘approximate’}) – An algorithm to compute generators of closed intents. ‘exact’ works in exponential time but shows good result approximate works in a matter of milliseconds but shows awful result

  • use_tqdm (bool) – A flag whether to visualize the progress of the algorithm by tqdm bar

fit(context: fcapy.mvcontext.mvcontext.MVContext, use_tqdm=False)

Fit a DecisionLattice to the context

Parameters
  • context (FormalContext or MVContext) – A training context. Target values should be kept in context.target property

  • use_tqdm (bool) – A flag whether to visualize algorithm progress with tqdm bar

property lattice

The ConceptLattice used by the DecisionLattice model

predict(context: fcapy.mvcontext.mvcontext.MVContext, use_tqdm=False)

Use fitted model to predict target values of a context

Parameters
  • context (FormalContext or MVContext) – A context to predict

  • use_tqdm (bool) – A flag whether to visualize algorithm progress with tqdm bar

Returns

predictions – Prediction of target values for a given context

Return type

list of float

property use_generators

A flag whether to use closed intents of concepts (if set False) or their generators (o/w)

Can be changed after the model is fitted to the data