// *************************************************************** // SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez // SPDX-FileType: SOURCE // SPDX-License-Identifier: MIT // *************************************************************** #ifndef FEATURE_SELECT_H #define FEATURE_SELECT_H #include #include #include "bayesnet/utils/BayesMetrics.h" namespace bayesnet { class FeatureSelect : public Metrics { public: // dataset is a n+1xm tensor of integers where dataset[-1] is the y std::vector FeatureSelect(const torch::Tensor& samples, const std::vector& features, const std::string& className, const int maxFeatures, const int classNumStates, const torch::Tensor& weights); virtual ~FeatureSelect() {}; virtual void fit() = 0; std::vector getFeatures() const; std::vector getScores() const; protected: void initialize(); void computeSuLabels(); double computeSuFeatures(const int a, const int b); double symmetricalUncertainty(int a, int b); double computeMeritCFS(); const torch::Tensor& weights; int maxFeatures; std::vector selectedFeatures; std::vector selectedScores; std::vector suLabels; std::map, double> suFeatures; bool fitted = false; }; } #endif