FeatureSpace.hpp 21.2 KB
Newer Older
1
// Copyright 2021 Thomas A. R. Purcell
2
//
3
4
5
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
6
//
7
//     http://www.apache.org/licenses/LICENSE-2.0
8
//
9
10
11
12
13
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
14

15
/** @file feature_creation/feature_space/FeatureSpace.hpp
16
 *  @brief Defines the class for creating/operating on a feature space in SISSO
17
 *
18
 *  @author Thomas A. R. Purcell (tpurcell90)
19
20
21
 *  @bug No known bugs.
 */

Thomas Purcell's avatar
Thomas Purcell committed
22
23
24
#ifndef FEATURE_SPACE
#define FEATURE_SPACE

25
#include <boost/filesystem.hpp>
Thomas Purcell's avatar
Thomas Purcell committed
26

27
#include <utility>
Thomas Purcell's avatar
Thomas Purcell committed
28

Thomas Purcell's avatar
Thomas Purcell committed
29
#include "feature_creation/node/utils.hpp"
30
#include "inputs/InputParser.hpp"
Thomas Purcell's avatar
Thomas Purcell committed
31
32

#include "mpi_interface/MPI_Interface.hpp"
33
#include "mpi_interface/MPI_Ops.hpp"
Thomas Purcell's avatar
Thomas Purcell committed
34
35
#include "mpi_interface/serialize_tuple.h"

Thomas Purcell's avatar
Thomas Purcell committed
36
#include "utils/project.hpp"
37
#include "mpi_interface/MPI_Interface.hpp"
Thomas Purcell's avatar
Thomas Purcell committed
38

39
40
41
42
#ifdef PY_BINDINGS
    namespace np = boost::python::numpy;
    namespace py = boost::python;
#endif
43

44
// DocString: cls_feat_space
45
/**
46
 * @brief Feature Space for SISSO calculations. It stores and performs all actions on the feature space for SISSO.
47
48
 *
 */
Thomas Purcell's avatar
Thomas Purcell committed
49
50
class FeatureSpace
{
Thomas Purcell's avatar
Thomas Purcell committed
51
52
    std::vector<node_ptr> _phi_selected; //!< A vector containing all of the selected features
    std::vector<node_ptr> _phi; //!< A vector containing all features generated (Not including those created on the Fly during SIS)
53
    std::vector<node_ptr> _phi_0; //!< A vector containing all of the Primary features
54

55
    #ifdef PARAMETERIZE
Thomas Purcell's avatar
Thomas Purcell committed
56
57
58
59
60
61
62
63
    std::vector<node_ptr> _phi_reparam; //!< A vector containing the features created when reparameterizating using the residuals
    std::vector<int> _end_no_params; //!< A vector containing the indexes of each rung where parameterized nodes start
    std::vector<int> _start_rung_reparam; //!< A vector containing the indexes of each rung where parameterized nodes start

    std::vector<un_param_op_node_gen> _un_param_operators; //!< Vector containing all parameterized unary operators with free parameters
    std::vector<bin_param_op_node_gen> _com_bin_param_operators; //!< Vector containing all parameterized commutable binary operators with free parameters
    std::vector<bin_param_op_node_gen> _bin_param_operators; //!< Vector containing all parameterized binary operators with free parameters
    std::vector<std::string> _allowed_param_ops; //!< Vector containing all allowed operators strings for operators with free parameters
64
    #endif
65

Thomas Purcell's avatar
Thomas Purcell committed
66
67
68
69
    std::vector<std::string> _allowed_ops; //!< Vector containing all allowed operators strings
    std::vector<un_op_node_gen> _un_operators; //!< Vector containing all unary operators
    std::vector<bin_op_node_gen> _com_bin_operators; //!< Vector containing all commutable binary operators
    std::vector<bin_op_node_gen> _bin_operators; //!< Vector containing all binary operators
70

71
    std::vector<double> _prop_train; //!< The value of the property vector for each training sample
Thomas Purcell's avatar
Thomas Purcell committed
72
    std::vector<double> _scores; //!< The projection scores for each feature
73

74
    const std::vector<int> _task_sizes_train; //!< Number of training samples per task
Thomas Purcell's avatar
Thomas Purcell committed
75
76
77
78
    std::vector<int> _start_rung; //!< Vector containing the indexes where each rung starts in _phi
    const std::string _project_type; //!< The type of LossFunction to use when projecting the features onto a property
    const std::string _feature_space_file; //!< File to output the computer readable representation of the selected features to
    const std::string _feature_space_summary_file; //!< File to output the human readable representation of the selected features to
79
    const std::string _phi_out_file; //!< Filename of the file to output the feature set to
80

Thomas Purcell's avatar
Thomas Purcell committed
81
82
    std::function<bool(const double*, const int, const double, const std::vector<double>&, const double, const int, const int)> _is_valid; //!< Function used to determine of a feature is too correlated to previously selected features
    std::function<bool(const double*, const int, const double, const std::vector<node_ptr>&, const std::vector<double>&, const double)> _is_valid_feat_list; //!< Function used to determine of a feature is too correlated to previously selected features within a given list
83

Thomas Purcell's avatar
Thomas Purcell committed
84
    std::shared_ptr<MPI_Interface> _mpi_comm; //!< the MPI communicator for the calculation
85

86
    const double _cross_cor_max; //!< Maximum cross-correlation used for selecting features
Thomas Purcell's avatar
Thomas Purcell committed
87
88
    const double _l_bound; //!< The lower bound for the maximum absolute value of the features
    const double _u_bound; //!< The upper bound for the maximum absolute value of the features
89

Thomas Purcell's avatar
Thomas Purcell committed
90
91
92
    int _n_rung_store; //!< The number of rungs to calculate and store the value of the features for all samples
    int _n_feat; //!< Total number of features in the feature space
    int _max_rung; //!< Maximum rung for the feature creation
93

Thomas Purcell's avatar
Thomas Purcell committed
94
    const int _n_sis_select; //!< Number of features to select during each SIS iteration
95
    const int _n_samp_train; //!< Number of samples in the training set
Thomas Purcell's avatar
Thomas Purcell committed
96
    const int _n_rung_generate; //!< Either 0 or 1, and is the number of rungs to generate on the fly during SIS
97

98
    #ifdef PARAMETERIZE
Thomas Purcell's avatar
Thomas Purcell committed
99
    int _max_param_depth; //!< The maximum depth in the binary expression tree to set non-linear optimization
100
101
    bool _reparam_residual; //!< If True then reparameterize features using the residuals of each model
    #endif
Thomas Purcell's avatar
Thomas Purcell committed
102
public:
Thomas Purcell's avatar
Thomas Purcell committed
103

104
    // DocString: feat_space_init
105
    /**
106
     * @brief Construct a FeatureSpace using an InputParser object
107
     *
108
     * @param inputs InputParser object used to build the FeatureSpace
109
     */
110
    FeatureSpace(InputParser inputs);
111

112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
    /**
     * @brief FeatureSpace constructor that uses a file containing postfix feature expressions to describe all features in Phi, and a primary feature setn <python/feature_creation/FeatureSpace.cpp>)
     *
     * @param feature_file The file containing the postfix expressions of all features in the FeatureSpace
     * @param phi_0 The set of primary features
     * @param prop List containing the property vector (training data only)
     * @param task_sizes_train The number of samples in the training data per task
     * @param project_type The type of loss function/projection operator to use
     * @param n_sis_select The number of features to select during each SIS step
     * @param cross_corr_max The maximum allowed cross-correlation value between selected features
     */
    FeatureSpace(
        std::string feature_file,
        std::vector<node_ptr> phi_0,
        std::vector<double> prop,
        std::vector<int> task_sizes_train,
        std::string project_type="regression",
        int n_sis_select=1,
        double cross_corr_max=1.0,
        std::vector<int> excluded_inds = std::vector<int>()
    );

    /**
     * @brief Destructor
     */
    ~FeatureSpace();

139
    /**
Thomas Purcell's avatar
Thomas Purcell committed
140
     * @brief Populate the operator lists using _allowed_ops and _allowed_param_ops
141
142
143
144
     */
    void set_op_lists();

    /**
Thomas Purcell's avatar
Thomas Purcell committed
145
     * @brief Create SIS output files and write their headers
146
     */
147
    void initialize_fs_output_files() const;
Thomas Purcell's avatar
Thomas Purcell committed
148

149
    /**
Thomas Purcell's avatar
Thomas Purcell committed
150
     * @brief Populate _phi using _phi_0 and the allowed operators up to (_max_rung - _n_rung_generate)^th rung
151
     */
Thomas Purcell's avatar
Thomas Purcell committed
152
153
154
155
156
157
    void generate_feature_space(
        std::vector<node_ptr>& feat_set,
        std::vector<int>& start_rung,
        const std::vector<double>& prop,
        bool reparam = false
    );
Thomas Purcell's avatar
Thomas Purcell committed
158

159
    /**
Thomas Purcell's avatar
Thomas Purcell committed
160
     * @brief A vector containing all of the selected features
161
     */
162
    inline std::vector<node_ptr> phi_selected() const {return _phi_selected;};
163
164

    /**
Thomas Purcell's avatar
Thomas Purcell committed
165
     * @brief A vector containing all features generated (Not including those created on the Fly during SIS)
166
     */
167
    inline std::vector<node_ptr> phi() const {return _phi;};
168
169

    /**
Thomas Purcell's avatar
Thomas Purcell committed
170
     * @brief A vector containing all of the Primary features
171
     */
172
    inline std::vector<node_ptr> phi0() const {return _phi_0;};
173
174

    /**
Thomas Purcell's avatar
Thomas Purcell committed
175
     * @brief The projection scores for each feature in _phi
176
     */
177
    inline std::vector<double> scores() const {return _scores;}
178

179
    /**
180
     * @brief The MPI Communicator
181
     */
182
    inline std::shared_ptr<MPI_Interface> mpi_comm() const {return _mpi_comm;}
183

184
    /**
Thomas Purcell's avatar
Thomas Purcell committed
185
     * @brief Number of training samples per task
186
     */
187
    inline std::vector<int> task_sizes_train() const {return _task_sizes_train;}
188

189
    // DocString: feat_space_feature_space_file
190
    /**
Thomas Purcell's avatar
Thomas Purcell committed
191
     * @brief Filename of the file to output the computer readable representation of the selected features to
192
     */
193
    inline std::string feature_space_file() const {return _feature_space_file;}
194

Thomas Purcell's avatar
Thomas Purcell committed
195
196
197
198
199
200
    // DocString: feat_space_feature_space_file
    /**
     * @brief Filename of the file to output the human readable representation of the selected features to
     */
    inline std::string feature_space_summary_file() const {return _feature_space_summary_file;}

201
    // DocString: feat_space_l_bound
202
    /**
Thomas Purcell's avatar
Thomas Purcell committed
203
     * @brief The mlower bound for the maximum absolute value of the features
204
     */
205
    inline double l_bound() const {return _l_bound;}
206

207
    // DocString: feat_space_u_bound
208
    /**
Thomas Purcell's avatar
Thomas Purcell committed
209
     * @brief The upper bound for the maximum absolute value of the features
210
     */
211
    inline double u_bound() const {return _u_bound;}
212

Thomas Purcell's avatar
Thomas Purcell committed
213
    // DocString: feat_space_max_rung
214
    /**
Thomas Purcell's avatar
Thomas Purcell committed
215
     * @brief The maximum rung for the feature creation
216
     */
Thomas Purcell's avatar
Thomas Purcell committed
217
    inline int max_rung() const {return _max_rung;}
218

219
    // DocString: feat_space_n_sis_select
220
    /**
Thomas Purcell's avatar
Thomas Purcell committed
221
     * @brief The number of features to select during each SIS iteration
222
     */
223
    inline int n_sis_select() const {return _n_sis_select;}
224

225
    // DocString: feat_space_n_samp_train
226
    /**
Thomas Purcell's avatar
Thomas Purcell committed
227
     * @brief The nuumber of samples in the training set
228
     */
229
    inline int n_samp_train() const {return _n_samp_train;}
230

231
    // DocString: feat_space_n_feat
232
    /**
Thomas Purcell's avatar
Thomas Purcell committed
233
     * @brief The total number of features in the feature space
234
     */
235
    inline int n_feat() const {return _n_feat;}
236

237
    // DocString: feat_space_n_rung_store
238
    /**
Thomas Purcell's avatar
Thomas Purcell committed
239
     * @brief The number of rungs to calculate and store the value of the features for all samples
240
     */
241
    inline int n_rung_store() const {return _n_rung_store;}
242

243
    // DocString: feat_space_n_rung_generate
244
    /**
245
     * @brief Either 0 or 1, and is the number of rungs to generate on the fly during SIS
246
     */
247
    inline int n_rung_generate() const {return _n_rung_generate;}
248

Thomas Purcell's avatar
Thomas Purcell committed
249
250
    /**
     * @brief Generate a new set of non-parameterized features from a single feature
Thomas Purcell's avatar
Thomas Purcell committed
251
     * @details Perform all valid algebraic operations on the passed feature and all features that appear before it in _phi.
Thomas Purcell's avatar
Thomas Purcell committed
252
253
     *
     * @param feat The feature to spawn new features from
Thomas Purcell's avatar
Thomas Purcell committed
254
255
     * @param feat_set The feature set to pull features from for binary operations
     * @param start The point in feat_set to begin pulling features from for binary operations
Thomas Purcell's avatar
Thomas Purcell committed
256
     * @param feat_ind starting index for the next feature generated
Thomas Purcell's avatar
Thomas Purcell committed
257
258
     * @param l_bound lower bound for the maximum absolute value of the feature
     * @param u_bound upper bound for the maximum abosulte value of the feature
Thomas Purcell's avatar
Thomas Purcell committed
259
260
261
262
     */
    void generate_non_param_feats(
        std::vector<node_ptr>::iterator& feat,
        std::vector<node_ptr>& feat_set,
263
        const std::vector<node_ptr>::iterator& start,
Thomas Purcell's avatar
Thomas Purcell committed
264
265
266
267
268
        unsigned long int& feat_ind,
        const double l_bound=1e-50,
        const double u_bound=1e50
    );

269
270
271
272
273
274
    // DocString: feat_space_output_phi
    /**
     * @brief Output the feature set to a file of a passed filename
     */
    void output_phi();

275
#ifdef PARAMETERIZE
276
    /**
Thomas Purcell's avatar
Thomas Purcell committed
277
     * @brief Generate a new set of parameterized features from a single feature
Thomas Purcell's avatar
Thomas Purcell committed
278
     * @details Perform all valid algebraic operations on the passed feature and all features that appear before it in _phi.
279
280
     *
     * @param feat The feature to spawn new features from
Thomas Purcell's avatar
Thomas Purcell committed
281
282
     * @param feat_set The feature set to pull features from for binary operations
     * @param start The point in feat_set to begin pulling features from for binary operations
283
284
     * @param feat_ind starting index for the next feature generated
     * @param optimizer The object used to optimize the parameterized features
Thomas Purcell's avatar
Thomas Purcell committed
285
286
     * @param l_bound lower bound for the maximum absolute value of the feature
     * @param u_bound upper bound for the maximum abosulte value of the feature
287
     */
Thomas Purcell's avatar
Thomas Purcell committed
288
    void generate_param_feats(
289
290
        std::vector<node_ptr>::iterator& feat,
        std::vector<node_ptr>& feat_set,
291
        const std::vector<node_ptr>::iterator& start,
292
293
        unsigned long int& feat_ind,
        std::shared_ptr<NLOptimizer> optimizer,
294
295
        const double l_bound=1e-50,
        const double u_bound=1e50
296
    );
Thomas Purcell's avatar
Thomas Purcell committed
297

298
    /**
Thomas Purcell's avatar
Thomas Purcell committed
299
     * @brief Generate a new set of parameterized features for the residuals
300
301
     *
     * @param feat The feature to spawn new features from
Thomas Purcell's avatar
Thomas Purcell committed
302
     * @param feat_set The feature set to pull features from for binary operations
303
     * @param feat_ind starting index for the next feature generated
Thomas Purcell's avatar
Thomas Purcell committed
304
     * @param optimizer The object used to optimize the parameterized features
Thomas Purcell's avatar
Thomas Purcell committed
305
306
     * @param l_bound lower bound for the maximum absolute value of the feature
     * @param u_bound upper bound for the maximum abosulte value of the feature
307
     */
Thomas Purcell's avatar
Thomas Purcell committed
308
    void generate_reparam_feats(
309
310
311
        std::vector<node_ptr>::iterator& feat,
        std::vector<node_ptr>& feat_set,
        unsigned long int& feat_ind,
Thomas Purcell's avatar
Thomas Purcell committed
312
        std::shared_ptr<NLOptimizer> optimizer,
313
314
        const double l_bound=1e-50,
        const double u_bound=1e50
315
    );
316
#endif
317

318
    /**
Thomas Purcell's avatar
Thomas Purcell committed
319
     * @brief Generate the final rung of features on the fly and calculate their projection scores for SISat can be selected by SIS.
320
     *
Thomas Purcell's avatar
Thomas Purcell committed
321
322
323
     * @param loss The LossFunction used to project over all of the features
     * @param phi_selected The set of features that would be selected excluding the final rung
     * @param scores_selected The projection scores of all features in phi_selected
324
     */
Thomas Purcell's avatar
Thomas Purcell committed
325
    void generate_and_project(std::shared_ptr<LossFunction> loss, std::vector<node_ptr>& phi_selected, std::vector<double>& scores_selected);
326

327
    /**
328
     * @brief Perform Sure-Independence Screening over the FeatureSpace. The features are ranked using a projection operator constructed using _project_type and the Property vector
329
     *
330
     * @param prop Vector containing the property vector (training data only)
331
     */
332
    void sis(const std::vector<double>& prop);
333

Thomas Purcell's avatar
Thomas Purcell committed
334
    /**
335
     * @brief Perform Sure-Independence Screening over the FeatureSpace. The features are ranked using a projection operator defined in loss
Thomas Purcell's avatar
Thomas Purcell committed
336
     *
337
     * @param loss The LossFunction used to project over all of the features
Thomas Purcell's avatar
Thomas Purcell committed
338
339
340
     */
    void sis(std::shared_ptr<LossFunction> loss);

341
    // DocString: feat_space_feat_in_phi
342
343
344
    /**
     * @brief Is a feature in this process' _phi?
     *
345
     * @param ind (int) The index of the feature
Thomas Purcell's avatar
Thomas Purcell committed
346
     *
347
     * @return True if feature is in this rank's _phi
348
     */
349
    inline bool feat_in_phi(int ind) const {return (ind >= _phi[0]->feat_ind()) && (ind <= _phi.back()->feat_ind());}
350

351
352
353
354
    // DocString: feat_space_remove_feature
    /**
     * @brief Remove a feature from phi
     *
Thomas Purcell's avatar
Thomas Purcell committed
355
     * @param ind (int) index of feature to remove
356
     */
357
    void remove_feature(const int ind);
358

359
360
361
362
363
364
365
366
367
368
369
370
371
    #ifdef PARAMETERIZE
    // DocString: feat_space_param_feats_allowed
    /**
     * @brief True if built with -DBUILD_PARAMS (used for python tests)
     */
    bool parameterized_feats_allowed() const {return true;}
    #else
    // DocString: feat_space_param_feats_allowed
    /**
     * @brief True if built with -DBUILD_PARAMS (used for python tests)
     */
    bool parameterized_feats_allowed() const {return false;}
    #endif
372
373
    // Python Interface Functions
    #ifdef PY_BINDINGS
Thomas Purcell's avatar
Thomas Purcell committed
374

375
    // DocString: feat_space_init_file_np_array
376
    /**
377
     * @brief FeatureSpace constructor that uses a file containing postfix feature expressions to describe all features in Phi, and a primary feature setn <python/feature_creation/FeatureSpace.cpp>)
378
     *
379
380
381
     * @param feature_file (str) The file containing the postfix expressions of all features in the FeatureSpace
     * @param phi_0 (list) The set of primary features
     * @param prop (np.ndarray) List containing the property vector (training data only)
382
     * @param task_sizes_train (list) The number of samples in the training data per task
383
384
385
     * @param project_type (str) The type of loss function/projection operator to use
     * @param n_sis_select (int) The number of features to select during each SIS step
     * @param cross_corr_max (double) The maximum allowed cross-correlation value between selected features
386
     * @param excluded_inds (list) The list of primary feature indexes to not include in any features
387
388
389
390
391
     */
    FeatureSpace(
        std::string feature_file,
        py::list phi_0,
        np::ndarray prop,
392
        py::list task_sizes_train,
Thomas Purcell's avatar
Thomas Purcell committed
393
        std::string project_type="regression",
394
        int n_sis_select=1,
395
396
        double cross_corr_max=1.0,
        py::list excluded_inds = py::list()
397
398
    );

399
    // DocString: feat_space_init_file_py_list
400
    /**
401
     * @brief FeatureSpace constructor that uses a file containing postfix feature expressions to describe all features in Phi, and a primary feature setn <python/feature_creation/FeatureSpace.cpp>)
402
     *
403
404
405
     * @param feature_file (str) The file containing the postfix expressions of all features in the FeatureSpace
     * @param phi_0 (list) The set of primary features
     * @param prop (list) List containing the property vector (training data only)
406
     * @param task_sizes_train (list) The number of samples in the training data per task
407
408
409
     * @param project_type (str) The type of loss function/projection operator to use
     * @param n_sis_select (int) The number of features to select during each SIS step
     * @param cross_corr_max (double) The maximum allowed cross-correlation value between selected features
410
     * @param excluded_inds (list) The list of primary feature indexes to not include in any features
411
412
413
414
415
     */
    FeatureSpace(
        std::string feature_file,
        py::list phi_0,
        py::list prop,
416
        py::list task_sizes_train,
Thomas Purcell's avatar
Thomas Purcell committed
417
        std::string project_type="regression",
418
        int n_sis_select=1,
419
420
        double cross_corr_max=1.0,
        py::list excluded_inds = py::list()
421
422
423
424
    );

    // DocString: feat_space_sis_arr
    /**
425
     * @brief Perform Sure-Independence Screening over the FeatureSpace. The features are ranked using a projection operator constructed using _project_type and the Property vector
426
     *
427
     * @param prop (np.ndarray) Array containing the property vector (training data only)
428
429
430
431
432
433
434
435
436
     */
    inline void sis(np::ndarray prop)
    {
        std::vector<double> prop_vec = python_conv_utils::from_ndarray<double>(prop);
        sis(prop_vec);
    }

    // DocString: feat_space_sis_list
    /**
437
     * @brief Perform Sure-Independence Screening over the FeatureSpace. The features are ranked using a projection operator constructed using _project_type and the Property vector
438
     *
439
     * @param prop (list) List containing the property vector (training data only)
440
441
442
443
444
445
446
447
448
     */
    inline void sis(py::list prop)
    {
        std::vector<double> prop_vec = python_conv_utils::from_list<double>(prop);
        sis(prop_vec);
    }

    // DocString: feat_space_phi_selected_py
    /**
Thomas Purcell's avatar
Thomas Purcell committed
449
     * @brief A list containing all of the selected features
450
451
452
453
454
     */
    py::list phi_selected_py();

    // DocString: feat_space_phi0_py
    /**
Thomas Purcell's avatar
Thomas Purcell committed
455
     * @brief A list containing all features generated (Not including those created on the Fly during SIS)
456
     */
Thomas Purcell's avatar
Thomas Purcell committed
457
    py::list phi_py();
458
459
460

    // DocString: feat_space_phi_py
    /**
Thomas Purcell's avatar
Thomas Purcell committed
461
     * @brief A list containing all of the Primary features
462
     */
Thomas Purcell's avatar
Thomas Purcell committed
463
    py::list phi0_py();
464
465
466

    // DocString: feat_space_scores_py
    /**
467
     * @brief An array of all stored projection scores from SIS
468
469
470
     */
    inline np::ndarray scores_py(){return python_conv_utils::to_ndarray<double>(_scores);};

471
    // DocString: feat_space_task_sizes_train_py
472
    /**
473
     * @brief A list of the number of samples in each task for the training data
474
     */
475
    inline py::list task_sizes_train_py(){return python_conv_utils::to_list<int>(_task_sizes_train);};
476
477
478

    // DocString: feat_space_allowed_ops_py
    /**
479
     * @brief The list of allowed operators
480
481
482
     */
    inline py::list allowed_ops_py(){return python_conv_utils::to_list<std::string>(_allowed_ops);}

483
484
485
486
487
488
489
490
491
492
493
494
495
    #ifdef PARAMETERIZE
    // DocString: feat_space_allowed_ops_py
    /**
     * @brief The list of allowed operators
     */
    inline py::list allowed_param_ops_py(){return python_conv_utils::to_list<std::string>(_allowed_param_ops);}
    #else
    // DocString: feat_space_allowed_ops_py
    /**
     * @brief The list of allowed operators
     */
    inline py::list allowed_param_ops_py(){return python_conv_utils::to_list<std::string>({});}
    #endif
Thomas Purcell's avatar
Thomas Purcell committed
496
    // DocString: feat_space_start_rung_py
497
    /**
498
     * @brief A list containing the index of the first feature of each rung in the feature space.
499
     */
Thomas Purcell's avatar
Thomas Purcell committed
500
    inline py::list start_rung_py(){return python_conv_utils::to_list<int>(_start_rung);}
501
502
503

    // DocString: feat_space_get_feature
    /**
504
     * @brief Access the feature in _phi with an index ind
505
     *
506
     * @param ind (int) The index of the feature to get
507
508
     * @return A ModelNode of the feature at index ind
     */
509
    inline ModelNode get_feature(const int ind) const {return ModelNode(_phi[ind]);}
510
    #endif
Thomas Purcell's avatar
Thomas Purcell committed
511
512
};

513
#endif