Commit d19ff92d authored by Thomas Purcell's avatar Thomas Purcell
Browse files

Set up for cmake script to automatically insert Doxygen comments as python doc_strings

parent 101762c1
......@@ -27,6 +27,8 @@
#endif
typedef std::shared_ptr<ModelNode> model_node_ptr;
// DocString: cls_model
/**
* @brief Class to store the models found from SISSO
*
......@@ -64,6 +66,7 @@ public:
*/
Model(std::vector<double> prop_train, std::vector<double> prop_test, std::vector<model_node_ptr> feats, std::vector<int> task_sizes_train, std::vector<int> task_sizes_test);
// DocString: model_init_str
/**
* @brief Construct a model from a training output file
* @details Reads in all of the data from the output file and recreates the model object
......@@ -72,6 +75,7 @@ public:
*/
Model(std::string train_file);
// DocString: model_init_str_str
/**
* @brief Construct a model from a training and testing output file
* @details Reads in all of the data from the output files and recreates the model object
......@@ -92,6 +96,7 @@ public:
*/
std::vector<std::string> populate_model(std::string filename, bool train);
// DocString: model_str
/**
* @brief Convert the model to a string
......@@ -100,46 +105,53 @@ public:
std::string toString() const;
/**
* @brief Accessor function to _prop_test_est
* @brief Accessor function to the estimated property values
*/
inline std::vector<double> predict(){return _prop_test_est;}
/**
* @brief Accessor function to _prop_train_est
* @brief Accessor function to predict property values
*/
inline std::vector<double> predict_train(){return _prop_train_est;}
/**
* @brief Copy the error into a new array
* @brief Copy the error into a new array
*
* @param res pointer to the beginning of the vector to store the residual
*/
inline void copy_error(double* res){std::copy_n(_train_error.data(), _n_samp_train, res);}
// DocString: model_rmse
/**
* @brief The training rmse of the model
*/
inline double rmse(){return util_funcs::norm(_train_error.data(), _n_samp_train) / std::sqrt(static_cast<double>(_n_samp_train));}
// DocString: model_test_rmse
/**
* @brief The testing rmse of the model
*/
inline double test_rmse(){return util_funcs::norm(_test_error.data(), _n_samp_test) / std::sqrt(static_cast<double>(_n_samp_test));}
// DocString: model_n_samp_train
/**
* @brief Total number of samples being trained on
*/
inline int n_samp_train(){return _n_samp_train;}
// DocString: model_n_samp_test
/**
* @brief Total number of samples being tested
*/
inline int n_samp_test(){return _n_samp_test;}
// DocString: model_n_dim
/**
* @brief The dimensionality of the data
*/
inline int n_dim(){return _n_dim;}
// DocString: model_max_ae
/**
* @brief The max Absolute error of the training data
*/
......@@ -148,6 +160,7 @@ public:
return std::abs(*std::max_element(_train_error.data(), _train_error.data() + _n_samp_train, [](double d1, double d2){return std::abs(d1) < std::abs(d2);}));
}
// DocString: model_test_max_ae
/**
* @brief The max Absolute error of the testing data
*/
......@@ -166,6 +179,7 @@ public:
void to_file(std::string filename, bool train = true, std::vector<int> test_inds = {});
#ifdef PY_BINDINGS
// DocString: model_coefs
/**
* @brief Python Accessor functions to the coefficient array
* @return The coefficients as a python list
......@@ -178,6 +192,7 @@ public:
return coef_lst;
}
// DocString: model_feats
/**
* @brief Python Accessor functions to the features
* @return A python list containing all of the features
......@@ -190,38 +205,44 @@ public:
return feat_lst;
}
// DocString: model_prop_train_est
/**
* @brief Python Accessor function to _prop_train_est
* @brief Python Accessor function to the estimation of the property
* @return _prop_train_est as a numpy ndarray
*/
inline np::ndarray prop_train_est(){return python_conv_utils::to_ndarray<double>(_prop_train_est);}
// DocString: model_prop_test_est
/**
* @brief Python Accessor function to _prop_test_est
* @brief Python Accessor function to the estimation of the properties test values
* @return _prop_test_est as a numpy ndarray
*/
inline np::ndarray prop_test_est(){return python_conv_utils::to_ndarray<double>(_prop_test_est);}
// DocString: model_prop_train
/**
* @brief Python Accessor function to _prop_train
* @brief Python Accessor function to the property to be learned
* @return _prop_train as a numpy ndarray
*/
inline np::ndarray prop_train(){return python_conv_utils::to_ndarray<double>(_prop_train);}
// DocString: model_prop_test
/**
* @brief Python Accessor function to _prop_test
* @brief Python Accessor function to the test values for the property
* @return _prop_test as a numpy ndarray
*/
inline np::ndarray prop_test(){return python_conv_utils::to_ndarray<double>(_prop_test);}
// DocString: model_train_error
/**
* @brief Python Accessor function to _train_error
* @brief Python Accessor function to the training error
* @return _train_error as a numpy ndarray
*/
inline np::ndarray train_error(){return python_conv_utils::to_ndarray<double>(_train_error);}
// DocString: model_test_error
/**
* @brief Python Accessor function to _test_error
* @brief Python Accessor function to the test error
* @return _test_error as a numpy ndarray
*/
inline np::ndarray test_error(){return python_conv_utils::to_ndarray<double>(_test_error);}
......
......@@ -18,6 +18,7 @@
namespace py = boost::python;
#endif
// DocString: cls_sisso_reg
/**
* @brief SISSO Regressor class, performs the SISSO algorithm and stores all selected models
*
......@@ -140,18 +141,21 @@ public:
*/
inline std::vector<std::vector<Model>> models(){return _models;}
// DocString: sisso_reg_n_samp
/**
* @brief Acessor function for n_samp
* @brief Acessor function to the number of samples per feature
*/
inline int n_samp(){return _n_samp;}
// DocString: sisso_reg_n_dim
/**
* @brief Acessor function for n_dim
* @brief Acessor function to the maximum model dimensionality
*/
inline int n_dim(){return _n_dim;}
// DocString: sisso_reg_n_residual
/**
* @brief Acessor function for n_residual
* @brief Acessor function to the number of residuals each iteration of SIS acts on
*/
inline int n_residual(){return _n_residual;}
......@@ -180,6 +184,7 @@ public:
int n_residual
);
// DocString: sisso_reg_init_list
/**
* @brief Constructor for the Regressor that takes in python objects (cpp definition in <python/descriptor_identifier/SISSORegressor.cpp)
*
......@@ -203,38 +208,43 @@ public:
int n_residual
);
// DocString: sisso_reg_models_py
/**
* @brief Python Accessor function to models (cpp definition in <python/descriptor_identifier/SISSORegressor.cpp)
* @brief Python Accessor function to the selected model (cpp definition in <python/descriptor_identifier/SISSORegressor.cpp)
* @return models as a python list
*/
py::list models_py();
// DocString: sisso_reg_prop_py
/**
* @brief Python Accessor function to prop
* @brief Python Accessor function to the property to be learned
* @return prop as a numpy array
*/
inline np::ndarray prop_py(){return python_conv_utils::to_ndarray<double>(_prop);}
// DocString: sisso_reg_prop_test_py
/**
* @brief Python Accessor function to prop_test
* @brief Python Accessor function to the test values for the property
* @return prop_test as a numpy array
*/
inline np::ndarray prop_test_py(){return python_conv_utils::to_ndarray<double>(_prop_test);}
// DocString: sisso_reg_task_sizes_train
/**
* @brief Python Accessor function to task_sizes_train
* @brief Python Accessor function to the number of samples per task in the training set
* @return task_sizes_train as a python list
*/
inline py::list task_sizes_train(){python_conv_utils::to_list<int>(_task_sizes_train);}
// DocString: sisso_reg_task_sizes_test
/**
* @brief Python Accessor function to task_sizes_test
* @brief Python Accessor function to the number of samples per task in the test set
* @return task_sizes_test as a python list
*/
inline py::list task_sizes_test(){python_conv_utils::to_list<int>(_task_sizes_test);}
/**
* @brief Python Accessor function to error
* @brief Python Accessor function to the error associated with the last tested model
* @return error as a numpy array
*/
inline np::ndarray error_py(){return python_conv_utils::to_ndarray<double>(_error);}
......
......@@ -28,6 +28,7 @@
namespace py = boost::python;
#endif
// DocString: cls_feat_space
/**
* @brief Feature Space for SISSO calculations
* @details Stores and performs all feature calculations for SIS
......@@ -93,6 +94,11 @@ public:
double max_abs_feat_val=1e50
);
/**
* @brief Initialize the feature set given a property vector
*
* @param prop The property trying to be learned
*/
void initialize_fs(std::vector<double> prop);
/**
......@@ -102,77 +108,85 @@ public:
void generate_feature_space(std::vector<double>& prop);
/**
* @brief Accessor function for _phi_selected
* @brief Accessor function to the selected feature space
*/
inline std::vector<node_ptr> phi_selected(){return _phi_selected;};
/**
* @brief Accessor function for _phi
* @brief Accessor function to the full feature space
*/
inline std::vector<node_ptr> phi(){return _phi;};
/**
* @brief Accessor function for _phi_0
* @brief Accessor function to the initial feature space
*/
inline std::vector<node_ptr> phi0(){return _phi_0;};
/**
* @brief Accessor function for _scores
* @brief Accessor function to the vector of projection scores for SIS
*/
inline std::vector<double> scores(){return _scores;}
/**
* @brief Accessor function for _mpi_comm
* @brief Accessor function to the MPI Communicator
*/
inline std::shared_ptr<MPI_Interface> mpi_comm(){return _mpi_comm;}
/**
* @brief Accessor function for _mpi_comm
* @brief Accessor function to the vector storing the number of samples in each task
*/
inline std::vector<int> task_sizes(){return _task_sizes;}
// DocString: feat_space_feature_space_file
/**
* @brief Accessor function for _feature_space_file
* @brief Accessor function to the feature space filename
*/
inline std::string feature_space_file(){return _feature_space_file;}
// DocString: feat_space_l_bound
/**
* @brief Accessor function for _l_bound
* @brief Accessor function to the minimum absolute value of the feature
*/
inline double l_bound(){return _l_bound;}
// DocString: feat_space_u_bound
/**
* @brief Accessor function for _u_bound
* @brief Accessor function to the maximum absolute value of the feature
*/
inline double u_bound(){return _u_bound;}
// DocString: feat_space_max_phi
/**
* @brief Accessor function for _max_phi
* @brief Accessor function to the maximum rung of the feature space
*/
inline int max_phi(){return _max_phi;}
// DocString: feat_space_n_sis_select
/**
* @brief Accessor function for _n_sis_select
* @brief Accessor function to the number of features selected in each SIS step
*/
inline int n_sis_select(){return _n_sis_select;}
// DocString: feat_space_n_samp
/**
* @brief Accessor function for _n_samp
* @brief Accessor function to the number of samples per feature
*/
inline int n_samp(){return _n_samp;}
// DocString: feat_space_n_feat
/**
* @brief Accessor function for _n_feat
* @brief Accessor function to the number of features in the feature space
*/
inline int n_feat(){return _n_feat;}
// DocString: feat_space_n_rung_store
/**
* @brief Accessor function for _n_rung_store
* @brief Accessor function to the number of rungs whose feature training data is stored in memory
*/
inline int n_rung_store(){return _n_rung_store;}
// DocString: feat_space_n_rung_generate
/**
* @brief Accessor function for _n_rung_generate
* @brief Accessor function to the number of rungs to be generated on the fly during SIS
*/
inline int n_rung_generate(){return _n_rung_generate;}
......@@ -234,6 +248,7 @@ public:
*/
void sis(std::vector<double>& prop);
// DocString: feat_space_feat_in_phi
/**
* @brief Is a feature in this process' _phi?
*
......@@ -300,6 +315,7 @@ public:
double max_abs_feat_val=1e50
);
// DocString: feat_space_sis_arr
/**
* @brief Wrapper function for SIS using a numpy array
*
......@@ -310,6 +326,8 @@ public:
std::vector<double> prop_vec = python_conv_utils::from_ndarray<double>(prop);
sis(prop_vec);
}
// DocString: feat_space_sis_list
/**
* @brief Wrapper function for SIS using a python list
*
......@@ -321,38 +339,44 @@ public:
sis(prop_vec);
}
// DocString: feat_space_phi_selected_py
/**
* @brief Python Accesor function to _phi_selected (cpp definition in <python/feature_creation/FeatureSpace.cpp>)
* @brief Python Accesor function to the selected feature space (cpp definition in <python/feature_creation/FeatureSpace.cpp>)
* @return _phi_selected as a python list
*/
py::list phi_selected_py();
// DocString: feat_space_phi0_py
/**
* @brief Python Accesor function to _phi0 (cpp definition in <python/feature_creation/FeatureSpace.cpp>)
* @brief Python Accesor function to the initial feature space (cpp definition in <python/feature_creation/FeatureSpace.cpp>)
* @return _phi0 as a python list
*/
py::list phi0_py();
// DocString: feat_space_scores_py
/**
* @brief Python Accesor function to _scores
* @brief Python Accesor function to the vector of projection scores for SIS
* @return _scores as a numpy array
*/
inline np::ndarray scores_py(){return python_conv_utils::to_ndarray<double>(_scores);};
// DocString: feat_space_task_sizes_py
/**
* @brief Python Accesor function to _task_sizes
* @brief Python Accesor function to the vector storing the number of samples in each task
* @return _task_sizes as a python list
*/
inline py::list task_sizes_py(){return python_conv_utils::to_list<int>(_task_sizes);};
// DocString: feat_space_allowed_ops_py
/**
* @brief Python Accesor function to _allowed_ops
* @brief Python Accesor function to the list of allowed operator nodes
* @return _allowed_ops as a python list
*/
inline py::list allowed_ops_py(){return python_conv_utils::to_list<std::string>(_allowed_ops);}
// DocString: feat_space_start_gen_py
/**
* @brief Python Accesor function to _start_gen
* @brief Python Accesor function to list storing when each generation starts in phi
* @return _start_gen as a python list
*/
inline py::list start_gen_py(){return python_conv_utils::to_list<int>(_start_gen);}
......
......@@ -24,6 +24,7 @@
namespace py = boost::python;
#endif
// DocString: cls_feat_node
/**
* @brief Node that describe the leaves of the operator graph (Initial features in Phi_0)
*/
......@@ -125,16 +126,19 @@ public:
*/
~FeatureNode();
// DocString: feat_node_expr_1
/**
* @brief Get the string expression used to represent the primary feature
*/
inline std::string expr(){return _expr;}
// DocString: feat_node_expr_const
/**
* @brief Get the string expression used to represent the primary feature
*/
inline std::string expr()const{return _expr;}
// DocString: feat_node_unit
/**
* @brief The unit of the primary feature
*/
......@@ -150,6 +154,7 @@ public:
*/
inline std::vector<double> test_value(){return _test_value;}
// DocString: feat_node_set_value
/**
* @brief Set the value for the feature inside of the value storage arrays
*
......@@ -157,6 +162,7 @@ public:
*/
inline void set_value(int offset = -1){std::copy_n(_value.data(), _n_samp, value_ptr());}
// DocString: feat_node_set_test_value
/**
* @brief Set the test values for the feature inside of the value storage arrays
*
......@@ -164,11 +170,13 @@ public:
*/
inline void set_test_value(int offset = -1){if(!_selected) std::copy_n(_test_value.data(), _n_test_samp, test_value_ptr());}
// DocString: feat_node_is_nan
/**
* @brief Check if the feature contains NaN
*/
inline bool is_nan(){return std::any_of(value_ptr(), value_ptr() + _n_samp, [](double d){return !std::isfinite(d);});}
// DocString: feat_node_is_const
/**
* @brief Check if feature is constant
*/
......@@ -198,6 +206,7 @@ public:
inline double* test_value_ptr(int offset = 0){return node_value_arrs::get_test_value_ptr(_arr_ind, _feat_ind, offset);}
// DocString: feat_node_rung
/**
* @brief return the rung of the feature
*
......
......@@ -11,6 +11,7 @@
#include <feature_creation/node/FeatureNode.hpp>
// DocString: cls_model_node
/**
* @brief Node that describe the leaves of the operator graph (Initial features in Phi_0)
*/
......@@ -84,6 +85,7 @@ public:
*/
~ModelNode();
// DocString: model_node_set_value
/**
* @brief Set the value for the feature inside of the value storage arrays
*
......@@ -91,6 +93,7 @@ public:
*/
inline void set_value(int offset = -1){return;}
// DocString: model_node_set_test_value
/**
* @brief Set the test values for the feature inside of the value storage arrays
*
......@@ -98,11 +101,13 @@ public:
*/
inline void set_test_value(int offset = -1){return;}
// DocString: model_node_is_nan
/**
* @brief Check if the feature contains NaN
*/
inline bool is_nan(){return false;}
// DocString: model_node_is_const
/**
* @brief Check if feature is constant
*/
......@@ -128,6 +133,7 @@ public:
inline double* test_value_ptr(int offset = -1){return _test_value.data();}
// DocString: model_node_rung
/**
* @brief return the rung of the feature
*
......
......@@ -31,6 +31,7 @@
namespace np = boost::python::numpy;
#endif
// DocString: cls_node
/**
* @brief Base class for a Node
* @details Class used to describe a Node on the feature graph. Features are treated as an operation graph, these are the nodes on that graph.
......@@ -113,6 +114,7 @@ public:
*/
virtual ~Node();
// DocString: node_reindex_1
/**
* @brief Reindex the feature
* @details re-index the feature to be continuous
......@@ -122,6 +124,7 @@ public:
*/
inline void reindex(int ind){_feat_ind = ind; _arr_ind = ind;}
// DocString: node_reindex_2
/**
* @brief Reindex the feature
* @details re-index the feature to be continuous
......@@ -131,26 +134,31 @@ public:
*/
inline void reindex(int ind, int arr_ind){_feat_ind = ind; _arr_ind = arr_ind;}
// DocString: node_samp
/**
* @brief Acesssor function to get the number of samples
*/
inline int n_samp(){return _n_samp;}
// DocString: node_test_samp
/**
* @brief Acesssor function to get the number of samples in the test set
*/
inline int n_test_samp(){return _n_test_samp;}
// DocString: node_feat_ind
/**
* @brief Accessor function to get the feature ind
*/
inline int feat_ind(){return _feat_ind;}
// DocString: node_arr_ind
/**
* @brief Accessor function to get the feature array index
*/
inline int arr_ind(){return _arr_ind;}
// DocString: node_selected
/**
* @brief Accessor function to _selected
* @return True if this feature was selected
......@@ -164,6 +172,7 @@ public:
*/
inline void set_selected(bool sel){_selected = sel;}
// DocString: node_d_mat_ind
/**
* @brief Setter function for _d_mat_ind
*
......@@ -176,11 +185,13 @@ public:
*/
inline int d_mat_ind(){return _d_mat_ind;}
// DocString: node_expr
/**
* @brief Get the expression for the overall feature (From root node down)