Table Of Contents

Previous topic

Generic Data Structure

Next topic

Inference Methods

Parameter Learning

All learners are stored in a dictionary in probrem.learners, and they are loaded using the name of the learner class (e.g. CPDTabularLearner) using the method ui.config.loadLearner()

CPD Learners

The parameters of a PRM model are the conditional probability distributions (CPDs or local distributions), they are learned using the module learners.cpdlearners.

This module contains classes that are used to learn conditional probability distributions (CPDs) for attributes. The basic CPD class is prm.localdistributions.CPD which can be implemented for different CPD representations. prm.localdistributions.CPDTabular stores the CPD as a matrix, whereas prm.localdistributions.CPDTree stores the CPD in a decision tree (not implemented yet).

class learners.cpdlearners.CPDLearner[source]

Abstract class that is used to learn the conditional probability distributions for a PRM using the data linked in the data interface.

class learners.cpdlearners.CPDTabularLearner[source]

The CPDTabularLearner learns the local distributions for all probabilistic attributes and stores them in tabular form prm.localdistributions.CPDTabular. It loads all the necessary data for each attribute in one query using the data interface.

learnCPDs(saveDistributions=False, forceLearning=False)[source]

Depending on which method is standard for learning CPDs, either learnCPDsCount() or learnCPDsFull() is executed.

learnCPDsCount(saveDistributions=False, forceLearning=False)[source]

Learns the conditional probability distributions for all probabilistic attributes by counting the occurences on the data side. If the data interface connects to a SQL based database this can easily be done using the COUNT statement. The data is retrieved by calling the data interface method data.sqliteinterface.loadCountCPDdata()

Parameters:
  • saveDistributions – If True, saves the learned CPDs to disk and prints the XML line that needs to be added to the PRM specification to the standard output
  • forceLearning – If True, the CPDs are learned even if there are distributions that could be loaded from disk
learnCPDsFull(saveDistributions=False, forceLearning=False)[source]

Learns the conditional probability distributions for all probabilistic attributes by iterating over a big table counting the occurences on the way. If the data interface connects to a SQL based database, the result set is a big table in the form [valAttr, valPa1, valPa2, etc.]. The data is retrieved by calling the data interface method data.sqliteinterface.loadFullCPDdata()

Parameters:
  • saveDistributions – If True, saves the learned CPDs to disk and prints the XML line that needs to be added to the PRM specification to the standard output
  • forceLearning – If True, the CPDs are learned even if there are distributions that could be loaded from disk
loglikelihood()[source]

Computes the log likelihood for the learned CPDs. As aggregation is possibly required, it uses the method data.sqliteinterface.loadFullAggCPDdata() to retrieve the data.