jsat.classifiers.bayesian.graphicalmodel
Class DiscreteBayesNetwork
- java.lang.Object
-
- jsat.classifiers.bayesian.graphicalmodel.DiscreteBayesNetwork
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, Classifier
- Direct Known Subclasses:
- K2NetworkLearner
public class DiscreteBayesNetwork extends java.lang.Object implements Classifier
A class for representing a Baysian Network (BN) for discrete variables. A BN use a graph to representing the relations between variables, and these links are called the structure. The structure of a BN must be specified by an expert using thedepends(int, int)method. The target class should be specified as the parent of the variables which have a causal relationship to it. These children of the target class should then have their own children specified. Once the structure has been specified, the network can be trained and used for classification.
If the network structure has not been specified, or has no relationships for the target class, the BN will create an edge from the target class to every variable. If no edges were ever specified, this initialization of edges corresponds to aNaiveBayesimplementation.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field and Description static booleanDEFAULT_USE_PRIORSWhether or not the classifier should take into account the prior probabilities.
-
Constructor Summary
Constructors Constructor and Description DiscreteBayesNetwork()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description CategoricalResultsclassify(DataPoint data)Performs classification on the given data point.Classifierclone()voiddepends(int parent, int child)Adds a dependency relation ship between two variables that will be in the network.booleansupportsWeightedData()Indicates whether the model knows how to train using weighted data points.voidtrain(ClassificationDataSet dataSet)Trains the classifier and constructs a model for classification using the given data set.voidtrain(ClassificationDataSet dataSet, boolean parallel)Trains the classifier and constructs a model for classification using the given data set.
-
-
-
Field Detail
-
DEFAULT_USE_PRIORS
public static final boolean DEFAULT_USE_PRIORS
Whether or not the classifier should take into account the prior probabilities. Default value is true.- See Also:
- Constant Field Values
-
-
Method Detail
-
classify
public CategoricalResults classify(DataPoint data)
Description copied from interface:ClassifierPerforms classification on the given data point.- Specified by:
classifyin interfaceClassifier- Parameters:
data- the data point to classify- Returns:
- the results of the classification.
-
depends
public void depends(int parent, int child)Adds a dependency relation ship between two variables that will be in the network. The integer value corresponds the the index of the i'th categorical variable, where the class target's value is the number of categorical variables.- Parameters:
parent- the parent variable, which will be explained in part by the childchild- the child variable, which contributes to the conditional probability of the parent.
-
train
public void train(ClassificationDataSet dataSet, boolean parallel)
Description copied from interface:ClassifierTrains the classifier and constructs a model for classification using the given data set. If the training method knows how, it will used the threadPool to conduct training in parallel. This method will block until the training has completed.- Specified by:
trainin interfaceClassifier- Parameters:
dataSet- the data set to train onparallel-trueif multiple threads should be used to train the model.falseif it should be done in a single threaded manner.
-
train
public void train(ClassificationDataSet dataSet)
Description copied from interface:ClassifierTrains the classifier and constructs a model for classification using the given data set.- Specified by:
trainin interfaceClassifier- Parameters:
dataSet- the data set to train on
-
supportsWeightedData
public boolean supportsWeightedData()
Description copied from interface:ClassifierIndicates whether the model knows how to train using weighted data points. If it does, the model will train assuming the weights. The values returned by this method may change depending on the parameters set for the model.- Specified by:
supportsWeightedDatain interfaceClassifier- Returns:
- true if the model supports weighted data, false otherwise
-
clone
public Classifier clone()
- Specified by:
clonein interfaceClassifier- Overrides:
clonein classjava.lang.Object
-
-
DataMelt 3.0 © DataMelt by jWork.ORG