BALL 1.5.0
Loading...
Searching...
No Matches
BALL::QSAR::NBModel Class Reference

#include <BALL/QSAR/nBModel.h>

Inheritance diagram for BALL::QSAR::NBModel:
BALL::QSAR::BayesModel BALL::QSAR::ClassificationModel BALL::QSAR::Model

Public Member Functions

Constructors and Destructors
 NBModel (const QSARData &q)
 ~NBModel ()
Accessors
void train ()
Eigen::VectorXd predict (const vector< double > &substance, bool transform=1)
void saveToFile (string filename)
void readFromFile (string filename)
vector< doublegetParameters () const
void setParameters (vector< double > &v)
bool isTrained ()
vector< doublecalculateProbabilities (int activitiy_index, int feature_index, double feature_value)
int getNoResponseVariables ()
Public Member Functions inherited from BALL::QSAR::BayesModel
 BayesModel (const QSARData &q)
Public Member Functions inherited from BALL::QSAR::ClassificationModel
 ClassificationModel (const QSARData &q)
 ~ClassificationModel ()
virtual void operator= (ClassificationModel &m)
std::vector< int > getClassLabels ()
Public Member Functions inherited from BALL::QSAR::Model
 Model (const QSARData &q)
virtual ~Model ()
virtual void operator= (const Model &m)
void copyData (const Model &m)
void copyDescriptorIDs (const Model &m)
void readTrainingData ()
void deleteDescriptorIDs ()
virtual bool optimizeParameters (int, int)
bool optimizeParameters (int k)
virtual double calculateStdErr ()
std::multiset< unsigned int > * getDescriptorIDs ()
void setDataSource (const QSARData *q)
const Eigen::MatrixXd * getDescriptorMatrix ()
const vector< string > * getSubstanceNames ()
const vector< string > * getDescriptorNames ()
const Eigen::MatrixXd getDescriptorTransformations ()
const Eigen::MatrixXd getYTransformations ()
const Eigen::MatrixXd * getY ()
void setDescriptorIDs (const std::multiset< unsigned int > &sl)
const stringgetType ()
void getUnnormalizedFeatureValue (int compound, int feature, double &return_value)
void getUnnormalizedResponseValue (int compound, int response, double &return_value)

Additional Inherited Members

ClassificationValidationvalidation
const QSARDatadata
Validationmodel_val
Protected Member Functions inherited from BALL::QSAR::ClassificationModel
void readClassInformationFromFile (std::ifstream &input, int no_classes)
void saveClassInformationToFile (std::ofstream &out)
void readLabels ()
void equalSpaceDiscretization (unsigned int bins, Eigen::MatrixXd &discretization_information)
void equalSpaceDiscretizationTestData (Eigen::VectorXd &compound, unsigned int bins, const Eigen::MatrixXd &discretization_information)
Protected Member Functions inherited from BALL::QSAR::Model
void readMatrix (Eigen::MatrixXd &mat, std::ifstream &in, unsigned int lines, unsigned int col)
void readVector (Eigen::RowVectorXd &vec, std::ifstream &in, unsigned int no_cells, bool column_vector)
void readModelParametersFromFile (std::ifstream &in)
void saveModelParametersToFile (std::ofstream &out)
virtual void saveDescriptorInformationToFile (std::ofstream &out)
virtual void readDescriptorInformationFromFile (std::ifstream &in, int no_descriptors, bool transformation)
void readResponseTransformationFromFile (std::ifstream &in, int no_y)
void saveResponseTransformationToFile (std::ofstream &out)
Eigen::VectorXd getSubstanceVector (const vector< double > &substance, bool transform)
Eigen::VectorXd getSubstanceVector (const Eigen::VectorXd &substance, bool transform)
void backTransformPrediction (Eigen::VectorXd &pred)
void addLambda (Eigen::MatrixXd &matrix, double &lambda)
void readDescriptorInformation ()
Protected Attributes inherited from BALL::QSAR::BayesModel
double min_prob_diff_
double undef_act_class_id_
std::vector< int > labels_
std::vector< int > no_substances_
void(ClassificationModel::* discretizeFeatures )(unsigned int bins, Eigen::MatrixXd &discretization_information)
void(ClassificationModel::* discretizeTestDataFeatures )(Eigen::VectorXd &compound, unsigned int bins, const Eigen::MatrixXd &discretization_information)
int default_no_opt_steps_
Eigen::MatrixXd descriptor_matrix_
vector< stringsubstance_names_
vector< stringdescriptor_names_
Eigen::MatrixXd descriptor_transformations_
Eigen::MatrixXd y_transformations_
Eigen::MatrixXd Y_
String type_
std::multiset< unsigned int > descriptor_IDs_

Detailed Description

class for Naive Bayes

Definition at line 27 of file nBModel.h.

Constructor & Destructor Documentation

◆ NBModel()

BALL::QSAR::NBModel::NBModel ( const QSARData & q)

◆ ~NBModel()

BALL::QSAR::NBModel::~NBModel ( )

Member Function Documentation

◆ calculateProbabilities()

vector< double > BALL::QSAR::NBModel::calculateProbabilities ( int activitiy_index,
int feature_index,
double feature_value )
virtual

calculate the probability for the specified feature to assume the given value for each class

Returns
a probability for each class

Implements BALL::QSAR::BayesModel.

◆ getNoResponseVariables()

int BALL::QSAR::NBModel::getNoResponseVariables ( )
virtual

returns the number of response variables for which this model has been trained

Implements BALL::QSAR::BayesModel.

◆ getParameters()

vector< double > BALL::QSAR::NBModel::getParameters ( ) const
virtual

Reimplemented from BALL::QSAR::Model.

◆ isTrained()

bool BALL::QSAR::NBModel::isTrained ( )
virtual

◆ predict()

Eigen::VectorXd BALL::QSAR::NBModel::predict ( const vector< double > & substance,
bool transform = 1 )
virtual

Predicts the activities of a given substance

Parameters
substancethe substance which activity is to be predicted in form of a vecor containing the values for all descriptors (if neccessary, relevant descriptors will be selected automatically)
transformdetermines whether the values for each descriptor of the given substance should be transformed before prediction of activity.
If (transform==1): each descriptor value is transformed according to the centering of the respective column of QSARData.descriptor_matrix used to train this model.
If the substance to be predicted is part of the same input data (e.g. same SD-file) as the training data (as is the case during cross validation), transform should therefore be set to 0.
Returns
a RowVector containing one value for each predicted activity

Implements BALL::QSAR::Model.

◆ readFromFile()

void BALL::QSAR::NBModel::readFromFile ( string filename)
virtual

reconstruct a saved Model from a file

Implements BALL::QSAR::Model.

◆ saveToFile()

void BALL::QSAR::NBModel::saveToFile ( string filename)
virtual

save Model to a file

Implements BALL::QSAR::Model.

◆ setParameters()

void BALL::QSAR::NBModel::setParameters ( vector< double > & )
virtual

sets the model parameters according to the given values.

Reimplemented from BALL::QSAR::Model.

◆ train()

void BALL::QSAR::NBModel::train ( )
virtual

Starts training the model.

Implements BALL::QSAR::Model.