OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MLModelMetadata Class Reference

#include <MLModelMetadata.h>

+ Collaboration diagram for MLModelMetadata:

Public Member Functions

 MLModelMetadata (const std::string &model_name, const MLModelType model_type, const std::string &model_type_str, const int64_t num_logical_features, const int64_t num_features, const int64_t num_categorical_features, const int64_t num_numeric_features, const std::string &model_metadata_json)
 
void extractModelMetadata (const std::string &model_metadata_json, const int64_t num_logical_features)
 
const std::string & getModelName () const
 
const MLModelType getModelType () const
 
const std::string & getModelTypeStr () const
 
int64_t getNumLogicalFeatures () const
 
int64_t getNumFeatures () const
 
int64_t getNumCategoricalFeatures () const
 
int64_t getNumNumericFeatures () const
 
const std::string & getPredicted () const
 
const std::vector< std::string > & getFeatures () const
 
const std::string & getTrainingQuery () const
 
double getDataSplitTrainFraction () const
 
double getDataSplitEvalFraction () const
 
const std::vector< int64_t > & getFeaturePermutations () const
 

Private Attributes

const std::string model_name_
 
const MLModelType model_type_
 
const std::string model_type_str_
 
const int64_t num_logical_features_
 
const int64_t num_features_
 
const int64_t num_categorical_features_
 
const int64_t num_numeric_features_
 
std::string predicted_
 
std::vector< std::string > features_
 
std::string training_query_
 
double data_split_train_fraction_ {1.0}
 
double data_split_eval_fraction_ {0.0}
 
std::vector< int64_t > feature_permutations_
 

Detailed Description

Definition at line 24 of file MLModelMetadata.h.

Constructor & Destructor Documentation

MLModelMetadata::MLModelMetadata ( const std::string &  model_name,
const MLModelType  model_type,
const std::string &  model_type_str,
const int64_t  num_logical_features,
const int64_t  num_features,
const int64_t  num_categorical_features,
const int64_t  num_numeric_features,
const std::string &  model_metadata_json 
)
inline

Definition at line 26 of file MLModelMetadata.h.

References extractModelMetadata().

34  : model_name_(model_name)
35  , model_type_(model_type)
36  , model_type_str_(model_type_str)
37  , num_logical_features_(num_logical_features)
38  , num_features_(num_features)
39  , num_categorical_features_(num_categorical_features)
40  , num_numeric_features_(num_numeric_features) {
41  extractModelMetadata(model_metadata_json, num_logical_features);
42  }
const int64_t num_categorical_features_
const int64_t num_numeric_features_
void extractModelMetadata(const std::string &model_metadata_json, const int64_t num_logical_features)
const int64_t num_features_
const std::string model_type_str_
const MLModelType model_type_
const int64_t num_logical_features_
const std::string model_name_

+ Here is the call graph for this function:

Member Function Documentation

void MLModelMetadata::extractModelMetadata ( const std::string &  model_metadata_json,
const int64_t  num_logical_features 
)

Definition at line 23 of file MLModelMetadata.cpp.

References data_split_eval_fraction_, data_split_train_fraction_, feature_permutations_, features_, predicted_, and training_query_.

Referenced by MLModelMetadata().

24  {
25  rapidjson::Document model_metadata_doc;
26  model_metadata_doc.Parse(model_metadata_json.c_str());
27  if (model_metadata_doc.HasMember("predicted") &&
28  model_metadata_doc["predicted"].IsString()) {
29  predicted_ = model_metadata_doc["predicted"].GetString();
30  }
31  if (model_metadata_doc.HasMember("training_query") &&
32  model_metadata_doc["training_query"].IsString()) {
33  training_query_ = model_metadata_doc["training_query"].GetString();
34  }
35  if (model_metadata_doc.HasMember("features") &&
36  model_metadata_doc["features"].IsArray()) {
37  const rapidjson::Value& features_array = model_metadata_doc["features"];
38  for (const auto& feature : features_array.GetArray()) {
39  features_.emplace_back(feature.GetString());
40  }
41  } else {
42  features_.resize(num_logical_features, "");
43  }
44  if (model_metadata_doc.HasMember("data_split_train_fraction") &&
45  model_metadata_doc["data_split_train_fraction"].IsDouble()) {
46  // Extract the double value
48  model_metadata_doc["data_split_train_fraction"].GetDouble();
49  }
50  if (model_metadata_doc.HasMember("data_split_eval_fraction") &&
51  model_metadata_doc["data_split_eval_fraction"].IsDouble()) {
52  // Extract the double value
54  model_metadata_doc["data_split_eval_fraction"].GetDouble();
55  }
56  if (model_metadata_doc.HasMember("feature_permutations") &&
57  model_metadata_doc["feature_permutations"].IsArray()) {
58  const rapidjson::Value& feature_permutations_array =
59  model_metadata_doc["feature_permutations"];
60  for (const auto& feature_permutation : feature_permutations_array.GetArray()) {
61  feature_permutations_.emplace_back(feature_permutation.GetInt64());
62  }
63  }
64 }
double data_split_eval_fraction_
std::string training_query_
double data_split_train_fraction_
std::vector< std::string > features_
std::vector< int64_t > feature_permutations_
std::string predicted_

+ Here is the caller graph for this function:

double MLModelMetadata::getDataSplitEvalFraction ( ) const
inline

Definition at line 58 of file MLModelMetadata.h.

References data_split_eval_fraction_.

58 { return data_split_eval_fraction_; }
double data_split_eval_fraction_
double MLModelMetadata::getDataSplitTrainFraction ( ) const
inline

Definition at line 57 of file MLModelMetadata.h.

References data_split_train_fraction_.

double data_split_train_fraction_
const std::vector<int64_t>& MLModelMetadata::getFeaturePermutations ( ) const
inline

Definition at line 59 of file MLModelMetadata.h.

References feature_permutations_.

59  {
60  return feature_permutations_;
61  }
std::vector< int64_t > feature_permutations_
const std::vector<std::string>& MLModelMetadata::getFeatures ( ) const
inline

Definition at line 55 of file MLModelMetadata.h.

References features_.

Referenced by ShowModelFeatureDetailsCommand::prepareLogicalValues().

55 { return features_; }
std::vector< std::string > features_

+ Here is the caller graph for this function:

const std::string& MLModelMetadata::getModelName ( ) const
inline

Definition at line 47 of file MLModelMetadata.h.

References model_name_.

47 { return model_name_; }
const std::string model_name_
const MLModelType MLModelMetadata::getModelType ( ) const
inline

Definition at line 48 of file MLModelMetadata.h.

References model_type_.

Referenced by ShowModelFeatureDetailsCommand::prepareLogicalValues().

48 { return model_type_; }
const MLModelType model_type_

+ Here is the caller graph for this function:

const std::string& MLModelMetadata::getModelTypeStr ( ) const
inline

Definition at line 49 of file MLModelMetadata.h.

References model_type_str_.

49 { return model_type_str_; }
const std::string model_type_str_
int64_t MLModelMetadata::getNumCategoricalFeatures ( ) const
inline

Definition at line 52 of file MLModelMetadata.h.

References num_categorical_features_.

52 { return num_categorical_features_; }
const int64_t num_categorical_features_
int64_t MLModelMetadata::getNumFeatures ( ) const
inline

Definition at line 51 of file MLModelMetadata.h.

References num_features_.

51 { return num_features_; }
const int64_t num_features_
int64_t MLModelMetadata::getNumLogicalFeatures ( ) const
inline

Definition at line 50 of file MLModelMetadata.h.

References num_logical_features_.

50 { return num_logical_features_; }
const int64_t num_logical_features_
int64_t MLModelMetadata::getNumNumericFeatures ( ) const
inline

Definition at line 53 of file MLModelMetadata.h.

References num_numeric_features_.

53 { return num_numeric_features_; }
const int64_t num_numeric_features_
const std::string& MLModelMetadata::getPredicted ( ) const
inline

Definition at line 54 of file MLModelMetadata.h.

References predicted_.

54 { return predicted_; }
std::string predicted_
const std::string& MLModelMetadata::getTrainingQuery ( ) const
inline

Definition at line 56 of file MLModelMetadata.h.

References training_query_.

56 { return training_query_; }
std::string training_query_

Member Data Documentation

double MLModelMetadata::data_split_eval_fraction_ {0.0}
private

Definition at line 75 of file MLModelMetadata.h.

Referenced by extractModelMetadata(), and getDataSplitEvalFraction().

double MLModelMetadata::data_split_train_fraction_ {1.0}
private

Definition at line 74 of file MLModelMetadata.h.

Referenced by extractModelMetadata(), and getDataSplitTrainFraction().

std::vector<int64_t> MLModelMetadata::feature_permutations_
private

Definition at line 76 of file MLModelMetadata.h.

Referenced by extractModelMetadata(), and getFeaturePermutations().

std::vector<std::string> MLModelMetadata::features_
private

Definition at line 72 of file MLModelMetadata.h.

Referenced by extractModelMetadata(), and getFeatures().

const std::string MLModelMetadata::model_name_
private

Definition at line 64 of file MLModelMetadata.h.

Referenced by getModelName().

const MLModelType MLModelMetadata::model_type_
private

Definition at line 65 of file MLModelMetadata.h.

Referenced by getModelType().

const std::string MLModelMetadata::model_type_str_
private

Definition at line 66 of file MLModelMetadata.h.

Referenced by getModelTypeStr().

const int64_t MLModelMetadata::num_categorical_features_
private

Definition at line 69 of file MLModelMetadata.h.

Referenced by getNumCategoricalFeatures().

const int64_t MLModelMetadata::num_features_
private

Definition at line 68 of file MLModelMetadata.h.

Referenced by getNumFeatures().

const int64_t MLModelMetadata::num_logical_features_
private

Definition at line 67 of file MLModelMetadata.h.

Referenced by getNumLogicalFeatures().

const int64_t MLModelMetadata::num_numeric_features_
private

Definition at line 70 of file MLModelMetadata.h.

Referenced by getNumNumericFeatures().

std::string MLModelMetadata::predicted_
private

Definition at line 71 of file MLModelMetadata.h.

Referenced by extractModelMetadata(), and getPredicted().

std::string MLModelMetadata::training_query_
private

Definition at line 73 of file MLModelMetadata.h.

Referenced by extractModelMetadata(), and getTrainingQuery().


The documentation for this class was generated from the following files: