这个学期要学DM&ML,用的是《数据挖掘算法原理与实现》王振武 本着造福同学的思想,开一个DM&ML的笔记系列,打算给书上的源代码添加一点注释,方便阅读和理解。
前置知识要求:
离散数学,概率论(主要是关于贝叶斯定理已经相关的知识,这里其实书上有简略的介绍,有一点概率论基础的同学基本就可以看懂书上的一些证明过程了),C++,STL
具体实现:
// bys.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
/*hiro:
stdafx的英文全称为:
Standard Application Framework Extensions(标准应用程序框架的扩展)。
所谓头文件预编译,就是把一个工程(Project)中使用的一些MFC标准头
文件(如Windows.H、Afxwin.H)预先编译,以后该工程编译时,
不再编译这部分头文件,仅仅使用预编译的结果。这样可以加快编译速度,节省时间。
*/
#include <stdio.h>
#include <tchar.h>
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
using namespace std;
vector<string> split(const string& src,const string& delimiter); //根据定界符分离字符串
void rejudge(); //重新判断原输入数据的类别
vector<vector<string> > vect; //二维容器
map<string,int> category_bak; //存放类别
map<string,double> pro_map; //存放各种概率的map容器
int main()
{
string strLine;
ifstream readfile("weather.txt");
if(!readfile) //打开文件失败!
{
cout<<"Fail to open file weather!"<<endl;
cout<<getchar();
return 0;
}
else
{
cout<<"读取原始数据如下:"<<endl;
vector<vector<string> >::size_type st_x; //二维容器x坐标
vector<string>::size_type st_y; //二维容器y坐标
vector&