eis/eqpalg/.do_not_use/regression/frame.h

100 lines
2.5 KiB
C
Raw Permalink Normal View History

/**
* @file eqpalg/regression/frame.h
* @brief
* @author Cat (null.null.null@qq.com)
* @version 0.1
* @date 2021-07-08
*
* Company: Baosight Co. Ltd.
* DO NOT COPY/USE WITHOUT PERMISSION
*
*/
#pragma once
#include <vector>
#include <iostream>
#include <dlib/svm.h>
#include <log4cplus/LOG.h>
#include <chrono>
#include <utility>
#include <tuple>
#include <eqpalg/regression/krr.h>
#include <eqpalg/regression/train_result.h>
namespace regression {
using namespace std;
using namespace dlib;
/**
* @brief
*/
struct Frame {
// 用来为dlib提供输入的数据类型
using SampleType = matrix<
double>; ///< 因为有一维数据作为label下方的LabelsType所以需要输入的rows
///< -1
using Label = std::vector<double>; ///< 用来当作拟合目标数据y的输出集合
using TrSample = std::vector<SampleType>; ///< 拟合数据x的输入集合
private:
std::chrono::system_clock::duration train_time_cost_; ///< 训练所花费时间
std::chrono::system_clock::duration
regression_func_time_cost_; ///< 回归函数所花费时间
/**
* @todo
* 使
*
*/
// 设置两种回归函数
std::unique_ptr<Krr> krr_;
// typename krls_t<rows - 1, cols>::TrainedResult krls_result_;
int best_regression_type = -1; ///< 默认回归函数无效
const std::string rule_id_;
const size_t dims_;
public:
Frame(const std::string& ruleId, size_t dims);
/**
* @brief Destroy the Frame object
*/
~Frame() = default;
/**
* @brief
* @param data My Param doc
* @return int
*/
int load(const SampleWindow& data);
protected:
/**
* @brief
* @param gama gama
* @param tr_samples -x
* @param tr_labels y
*/
int train_and_test_regression(const double gama, const TrSample& tr_samples,
const Label& tr_labels);
public:
/**
* @brief
* @param data -x
* @return double
*/
double predict(const SamplePoint& data);
/**
* @brief
* @return true
* @return false
*/
bool valid();
};
} // namespace regression