Loading...
Searching...
No Matches
Model.h
Go to the documentation of this file.
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
#ifndef BALL_QSAR_MODEL_H
#define BALL_QSAR_MODEL_H
#ifndef BALL_QSAR_VALIDATION_H
#include <BALL/QSAR/validation.h>
#endif
#ifndef BALL_QSAR_QSARDATA_H
#include <BALL/QSAR/QSARData.h>
#endif
#ifndef BALL_QSAR_EXCEPTION_H
#include <BALL/QSAR/exception.h>
#endif
#ifndef BALL_MATHS_PARSEDFUNCTION_H
#include <BALL/MATHS/parsedFunction.h>
#endif
#include <vector>
#include <set>
#include <Eigen/Core>
namespace BALL
{
namespace QSAR
{
class BALL_EXPORT Model
{
public:
Model(const QSARData& q);
virtual ~Model();
virtual void operator=(const Model& m);
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
void copyData(const Model& m);
void copyDescriptorIDs(const Model& m);
void readTrainingData();
virtual Eigen::VectorXd predict(const vector<double>& substance, bool transform) =0;
void deleteDescriptorIDs();
virtual void train() =0;
virtual bool optimizeParameters(int /*k*/, int /*no_steps*/){return 0;};
bool optimizeParameters(int k);
virtual double calculateStdErr()
{return -1.0;};
virtual void setParameters(vector<double>& /*v*/){};
virtual vector<double> getParameters() const;
std::multiset<unsigned int>* getDescriptorIDs();
void setDataSource(const QSARData* q);
virtual void saveToFile(string filename) = 0;
virtual void readFromFile(string filename) = 0;
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 string* getType();
void getUnnormalizedFeatureValue(int compound, int feature, double& return_value);
void getUnnormalizedResponseValue(int compound, int response, double& return_value);
const QSARData* data;
Validation* model_val;
protected:
int default_no_opt_steps_;
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();
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::MatrixXd descriptor_matrix_;
vector<string> substance_names_;
vector<string> descriptor_names_;
Eigen::MatrixXd descriptor_transformations_;
Eigen::MatrixXd y_transformations_;
Eigen::MatrixXd Y_;
String type_;
std::multiset<unsigned int> descriptor_IDs_;
friend class Validation;
friend class RegressionValidation;
friend class ClassificationValidation;
friend class PCRModel;
friend class KPCRModel;
friend class FeatureSelection;
};
BALL_EXPORT Model* createNewModelFromFile(String model_file, const QSARData& q);
}
}
#endif // BALL_QSAR_MODEL_H
BALL_EXPORT
#define BALL_EXPORT
Definition COMMON/global.h:50
QSARData.h
exception.h
BALL::QSAR::Model
Definition Model.h:35
BALL::QSAR::Model::saveToFile
virtual void saveToFile(string filename)=0
BALL::QSAR::Model::getDescriptorNames
const vector< string > * getDescriptorNames()
BALL::QSAR::Model::readDescriptorInformationFromFile
virtual void readDescriptorInformationFromFile(std::ifstream &in, int no_descriptors, bool transformation)
BALL::QSAR::Model::getType
const string * getType()
BALL::QSAR::Model::descriptor_IDs_
std::multiset< unsigned int > descriptor_IDs_
Definition Model.h:232
BALL::QSAR::Model::getDescriptorMatrix
const Eigen::MatrixXd * getDescriptorMatrix()
BALL::QSAR::Model::addLambda
void addLambda(Eigen::MatrixXd &matrix, double &lambda)
BALL::QSAR::Model::descriptor_names_
vector< string > descriptor_names_
Definition Model.h:212
BALL::QSAR::Model::readVector
void readVector(Eigen::RowVectorXd &vec, std::ifstream &in, unsigned int no_cells, bool column_vector)
BALL::QSAR::Model::readFromFile
virtual void readFromFile(string filename)=0
BALL::QSAR::Model::getUnnormalizedFeatureValue
void getUnnormalizedFeatureValue(int compound, int feature, double &return_value)
BALL::QSAR::Model::getYTransformations
const Eigen::MatrixXd getYTransformations()
BALL::QSAR::Model::FeatureSelection
friend class FeatureSelection
Definition Model.h:240
BALL::QSAR::Model::setDataSource
void setDataSource(const QSARData *q)
BALL::QSAR::Model::Y_
Eigen::MatrixXd Y_
Definition Model.h:224
BALL::QSAR::Model::model_val
Validation * model_val
Definition Model.h:150
BALL::QSAR::Model::ClassificationValidation
friend class ClassificationValidation
Definition Model.h:237
BALL::QSAR::Model::getParameters
virtual vector< double > getParameters() const
BALL::QSAR::Model::~Model
virtual ~Model()
BALL::QSAR::Model::calculateStdErr
virtual double calculateStdErr()
Definition Model.h:93
BALL::QSAR::Model::getY
const Eigen::MatrixXd * getY()
BALL::QSAR::Model::optimizeParameters
virtual bool optimizeParameters(int, int)
Definition Model.h:89
BALL::QSAR::Model::KPCRModel
friend class KPCRModel
Definition Model.h:239
BALL::QSAR::Model::copyData
void copyData(const Model &m)
BALL::QSAR::Model::PCRModel
friend class PCRModel
Definition Model.h:238
BALL::QSAR::Model::operator=
virtual void operator=(const Model &m)
BALL::QSAR::Model::readResponseTransformationFromFile
void readResponseTransformationFromFile(std::ifstream &in, int no_y)
BALL::QSAR::Model::deleteDescriptorIDs
void deleteDescriptorIDs()
BALL::QSAR::Model::getSubstanceNames
const vector< string > * getSubstanceNames()
BALL::QSAR::Model::getDescriptorIDs
std::multiset< unsigned int > * getDescriptorIDs()
BALL::QSAR::Model::type_
String type_
Definition Model.h:227
BALL::QSAR::Model::getSubstanceVector
Eigen::VectorXd getSubstanceVector(const vector< double > &substance, bool transform)
BALL::QSAR::Model::setDescriptorIDs
void setDescriptorIDs(const std::multiset< unsigned int > &sl)
BALL::QSAR::Model::data
const QSARData * data
Definition Model.h:147
BALL::QSAR::Model::getDescriptorTransformations
const Eigen::MatrixXd getDescriptorTransformations()
BALL::QSAR::Model::backTransformPrediction
void backTransformPrediction(Eigen::VectorXd &pred)
BALL::QSAR::Model::getUnnormalizedResponseValue
void getUnnormalizedResponseValue(int compound, int response, double &return_value)
BALL::QSAR::Model::train
virtual void train()=0
BALL::QSAR::Model::y_transformations_
Eigen::MatrixXd y_transformations_
Definition Model.h:220
BALL::QSAR::Model::default_no_opt_steps_
int default_no_opt_steps_
Definition Model.h:159
BALL::QSAR::Model::readModelParametersFromFile
void readModelParametersFromFile(std::ifstream &in)
BALL::QSAR::Model::RegressionValidation
friend class RegressionValidation
Definition Model.h:236
BALL::QSAR::Model::saveModelParametersToFile
void saveModelParametersToFile(std::ofstream &out)
BALL::QSAR::Model::Validation
friend class Validation
Definition Model.h:235
BALL::QSAR::Model::setParameters
virtual void setParameters(vector< double > &)
Definition Model.h:97
BALL::QSAR::Model::saveDescriptorInformationToFile
virtual void saveDescriptorInformationToFile(std::ofstream &out)
BALL::QSAR::Model::descriptor_transformations_
Eigen::MatrixXd descriptor_transformations_
Definition Model.h:216
BALL::QSAR::Model::optimizeParameters
bool optimizeParameters(int k)
BALL::QSAR::Model::readMatrix
void readMatrix(Eigen::MatrixXd &mat, std::ifstream &in, unsigned int lines, unsigned int col)
BALL::QSAR::Model::copyDescriptorIDs
void copyDescriptorIDs(const Model &m)
BALL::QSAR::Model::getSubstanceVector
Eigen::VectorXd getSubstanceVector(const Eigen::VectorXd &substance, bool transform)
BALL::QSAR::Model::predict
virtual Eigen::VectorXd predict(const vector< double > &substance, bool transform)=0
BALL::QSAR::Model::descriptor_matrix_
Eigen::MatrixXd descriptor_matrix_
Definition Model.h:206
BALL::QSAR::Model::saveResponseTransformationToFile
void saveResponseTransformationToFile(std::ofstream &out)
BALL::QSAR::Model::readDescriptorInformation
void readDescriptorInformation()
BALL::QSAR::Model::Model
Model(const QSARData &q)
BALL::QSAR::Model::readTrainingData
void readTrainingData()
BALL::QSAR::Model::substance_names_
vector< string > substance_names_
Definition Model.h:209
BALL::QSAR::QSARData
Definition QSARData.h:56
BALL::String
Definition string.h:57
BALL::QSAR
Definition allModel.h:17
BALL::QSAR::createNewModelFromFile
BALL_EXPORT Model * createNewModelFromFile(String model_file, const QSARData &q)
BALL
Definition constants.h:13
parsedFunction.h
validation.h