Ai
1 Star 0 Fork 1

Tzewa Lam/MLCode

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
RTrees.h 781 Bytes
一键复制 编辑 原始数据 按行查看 历史
Tzewa Lam 提交于 2024-02-20 15:05 +08:00 . modified RTrees
#pragma once
#include <vector>
#include <opencv2/ml/ml.hpp>
class RTree
{
private:
int _size = 0; // 数据集大小
int _dim = 0; // 数据集维度,属性个数
// 测试测试:(特征向量,响应值)
std::vector<std::pair<std::vector<double>, double>> testData;
cv::Ptr<cv::ml::RTrees> model;
cv::Ptr<cv::ml::TrainData> trainDataPtr = nullptr;
public:
/*
* @brief 创建模型
*/
void create();
/*
* @brief 从CSV中导入训练集,其实可以使用 cv::ml::loadFromCSV 函数
* @brief 默认开头为标题,且最后一列为标签
* @param path 数据集路径
*/
bool loadTrainDataFromCSV(std::string const &path);
/*
* @brief 从CSV中导入测试集
* @param path 数据集路径
*/
bool loadTestDataFromCSV(std::string const &path);
/*
* @brief 训练
*/
void train();
/*
* @brief 测试
*/
void test();
};
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/fingsinz/mlcode.git
git@gitee.com:fingsinz/mlcode.git
fingsinz
mlcode
MLCode
master

搜索帮助