最近阅读机器学习的决策树,突发奇想写了一下ID3实现,未完待续,保存下来等有时间接着写,大体框架是这样
目前还未写样例运行,未实例化
实现指导如下:
#include <iostream>
#include <string>
#include <decisionTree.h>
using namespace std;
int main()
{
AA attr;
DD sample;
decisionTree *m=new decisionTree();
NODE *root;
m->TreeGenerate(sample,attr,root);
}
#ifndef DECISIONTREE_H
#define DECISIONTREE_H
#define MAX 10000
#include <string.h>
#include <iostream>
#include <vector>
using namespace std;
struct A{
int id; //属性ID
string name; //属性名字
int value; //属性值
};
struct AA
{
int a_num; //属性集的大小
vector<A> aa; //属性集
vector<bool> canUse;
};
struct D //(xi,yi)
{
int x_num; // 属性X的长度
int y_num; // y的类别个数
vector<A> x;// xi向量值
int y; // yi值
};
struct DD //样本集
{
int d_num;
vector<D> dd;
};
struct re_A{ //返回属性值信息
int id