⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 example.cpp

📁 运用贝叶斯网编的一个识别垃圾邮件的程序
💻 CPP
字号:
#include <stdio.h>
#include<iostream.h>
#include "BrowseDir.h"
#include"Parameter.h"
#include"Evaluate.h"
#include <conio.h> 
#include<fstream.h>
#include<iomanip.h>

#if 1
int main()
{
	char Select1;
	cout <<"是否启动训练(N(No),Y(Yes)):";
	cin >>Select1;
	if(Select1 == 'y' || Select1 == 'Y' )
	{
		char temp[40];
		memset(temp,0,40);
		strcpy(temp,Path);
		
		char RoughSet[2][100];
		strcat(temp,"Junk1");          //Junk为垃圾邮件集合     
		strcpy(RoughSet[0],temp);      
		
		strcpy(temp,Path);
		strcat(temp,"Normail");
		strcpy(RoughSet[1],temp);       //Normail正常邮件集合
		
		for (int i = 0; i < 2; i++)
		{
			CBrowseDir statdir;
			if (!statdir.SetInitDir(RoughSet[i]))
			{
				puts("目录不存在。");
				return 0;
			} 
			
			//开始遍历
			statdir.BeginBrowse("*.txt");
			statdir.mergesort();
			
			strcpy(temp,Path);
			strcat(temp,"KeyInfo.dat");
			statdir.WriteInfo(temp);
			//cout << "success! " << endl;
		}
		
		CBrowseDir a1;
		a1.ExtractFeature("KeyInfo.dat","Feature.dat");
	}

	double Result[2][2]; 
	CEvaluate a;

	TestKeyWordNumber =200;
	a.m_nFileCount = 0;
	a.m_nAccuracy = 0;
	a.BeginBrowse("*.txt");
	Result[0][0] = a.GetAccuracy();
	Result[0][1] = a.GetFileCount();
	
	CEvaluate b;		
	TestKeyWordNumber = 200;
	b.m_nFileCount = 0;
	b.m_nAccuracy = 0;
	b.BeginBrowse("*.txt");
	b.GetAccuracy();
	Result[1][0] = b.GetAccuracy();
	Result[1][1] = b.GetFileCount();

	char Select2;
	cout <<"是否启动反馈机制(N(No),Y(Yes)):";
	cin >>Select2;
	if(Select2 == 'y' || Select2 == 'Y' )
	{		
		CEvaluate c;
		CBrowseDir a1;
		a1.ExtractFeature("KeyInfo.dat","Feature.dat");	
	}


	cout << "召回率(Recall):     Recall   = A/(A+C) * 100% " 
		<< Result[0][0] /Result[0][1] << endl; 
	cout << "正确率(Precision): Precision = A/(A+B) * 100 % " 
		<< Result[0][0] /(Result[0][0] + Result[1][1] - Result[1][0])	<< endl;	
	cout << "精确率(Accuracy): Accuracy=(A+D)/N * 100%  " 
		<< (Result[0][0] + Result[1][0]) /(Result[0][1] + Result[1][1]) << endl;
	cout << "虚报率(Fallout): Fallout = B/(B + D) * 100%  "
		<<(Result[1][1] - Result[1][0]) /Result[1][1] << endl;


	return 0;
}

#endif


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -