Refactor Classifier classes

This commit is contained in:
2023-11-12 18:35:29 +01:00
parent c7372b7fc7
commit 0059e269dd
12 changed files with 133 additions and 83 deletions

View File

@@ -1,5 +1,5 @@
#ifndef PYCLASSIFER_H
#define PYCLASSIFER_H
#ifndef PYCLASSIFIER_H
#define PYCLASSIFIER_H
#include "boost/python/detail/wrap_python.hpp"
#include <boost/python/numpy.hpp>
#include <nlohmann/json.hpp>
@@ -17,15 +17,16 @@ namespace pywrap {
public:
PyClassifier(const std::string& module, const std::string& className);
virtual ~PyClassifier();
PyClassifier& fit(torch::Tensor& X, torch::Tensor& y, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states);
PyClassifier& fit(torch::Tensor& X, torch::Tensor& y);
torch::Tensor predict(torch::Tensor& X);
double score(torch::Tensor& X, torch::Tensor& y);
std::string version();
PyClassifier& fit(torch::Tensor& X, torch::Tensor& y, const std::vector<std::string>& features, const std::string& className, std::map<std::string, std::vector<int>>& states) override;
PyClassifier& fit(torch::Tensor& X, torch::Tensor& y) override;
torch::Tensor predict(torch::Tensor& X) override;
double score(torch::Tensor& X, torch::Tensor& y) override;
std::string version() override;
std::string sklearnVersion() override;
std::string callMethodString(const std::string& method);
void setHyperparameters(const nlohmann::json& hyperparameters) override;
protected:
void checkHyperparameters(const std::vector<std::string>& validKeys, const nlohmann::json& hyperparameters);
void checkHyperparameters(const std::vector<std::string>& validKeys, const nlohmann::json& hyperparameters) override;
nlohmann::json hyperparameters;
private:
PyWrap* pyWrap;
@@ -35,4 +36,4 @@ namespace pywrap {
bool fitted;
};
} /* namespace pywrap */
#endif /* PYCLASSIFER_H */
#endif /* PYCLASSIFIER_H */