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

📄 tool.cpp

📁 对比分类器的测试数据和输出结果
💻 CPP
字号:
// Tool.cpp: implementation of the CTool class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "precision.h"
#include "Tool.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CTool::CTool()
{

}

CTool::~CTool()
{

}

void CTool::Pr()
{
    int count1=0;
	int count2=0;
	int count3=0;
	CStdioFile fTest("test_data.txt",CFile::modeRead);
	CStringList listTest;
	CString strLine;
	while(fTest.ReadString(strLine))
	{
		int index=strLine.Find(" ");
		strLine=strLine.Left(index);
		listTest.AddTail(strLine);
	}
	CStdioFile fOutput("output.txt",CFile::modeRead);
	CStringList listOutput;
	while(fOutput.ReadString(strLine))
	{
		listOutput.AddTail(strLine);
	}
	POSITION pos1=listTest.GetHeadPosition();
	POSITION pos2=listOutput.GetHeadPosition();
	while(pos1&&pos2)
	{
		CString strTest=listTest.GetNext(pos1);
        CString strOutput=listOutput.GetNext(pos2);
		if(strOutput=="+1"||strOutput=="1")
		{
			count2++;
			if(strOutput==strTest)
				count1++;
		}
		if(strTest=="+1"||strTest=="1")
		{
			count3++;
		}
	}
    float fPrecision=(float)count1/(float)count2;
	float fRecall=(float)count1/(float)count3;
	float fF=(2*fRecall*fPrecision)/(fRecall+fPrecision);
	CString strPr;
	strPr.Format("%f",fPrecision);
	CString strCount1;
	CString strCount2;
	strCount1.Format("%d",count1);
	strCount2.Format("%d",count2);
	CString strResult=strPr;
	strResult+=" "+strCount1+"/"+strCount2;
	CString strRec;
	strRec.Format("%f",fRecall);
	strResult=strResult+" "+"R:"+strRec;
	CString strF;
	strF.Format("%f",fF);
	strResult=strResult+" "+"F:"+strF;
	AfxMessageBox(strResult);
}

⌨️ 快捷键说明

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