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

📄 tree.cpp

📁 一个含有朴素贝耶斯分类方法和决策树分类方法的源代码
💻 CPP
字号:
// Tree.cpp : implementation file
//

#include "stdafx.h"
#include "HeartDM.h"
#include "Tree.h"

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

/////////////////////////////////////////////////////////////////////////////
// CTree

IMPLEMENT_DYNCREATE(CTree, CView)

CTree::CTree()
{
}

CTree::~CTree()
{
}


BEGIN_MESSAGE_MAP(CTree, CView)
	//{{AFX_MSG_MAP(CTree)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTree drawing

void CTree::OnDraw(CDC* pDC)
{
	CDocument* pDoc = GetDocument();
	// TODO: add draw code here
}

/////////////////////////////////////////////////////////////////////////////
// CTree diagnostics

#ifdef _DEBUG
void CTree::AssertValid() const
{
	CView::AssertValid();
}

void CTree::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CTree message handlers


int CTree::tree()
{
	if(m_thal==6)
	{
		if(m_nomv<=0)
			result=1;
		else
			result=2;
	}
    if(m_thal==3)
	{
		if(m_nomv>0)
		{
			if(m_cpt==1||m_cpt==2||m_cpt==3)
				result=1;
		    if(m_cpt==4)
				result=2;
		}
		if(m_nomv<=0)
		{
			if(m_rbp<=156)
				result=1;
			if(m_rbp>156)
			{
				if(m_age<=62)
					result=2;
				if(m_age>62)
					result=1;
			}
		}
	}//thal=3
	if(m_thal==7)
	{
		if(m_cpt==2)
		{
			if(m_op<=0.1)
				result=1;
			else
				result=2;
		}
		if(m_cpt==3)
		{
			if(m_op>1.9)
				result=2;
			if(m_op<=1.9)
			{
				if(m_sope>1)
				{
					if(m_rbp<=122)
						result=1;
					else
						result=2;
				}
				else if(m_sope<=1)
					result=1;
			}
		}
		if(m_cpt==4)
		{
			if(m_op>0.6)
				result=2;
			if(m_op<=0.6)
			{
				if(m_rer==1||m_rer==2)
					result=2;
				if(m_rer==0)
				{
					if(m_mhra>151)
					{
						if(m_nomv<=0)
							result=1;
						else
							result=2;
					}
					else
						result=1;
				}
			}
		else
			result=1;//cpt=1
		}
	}//thal=7
	return result;
}

void CTree::addValue(int age, int sex, int cpt, float rbp, float sci, int fbu, int rer, float mhra, int eia, float op, float sope, float nomv, int thal)
{

	m_age=age;
	m_sex=sex;
	m_cpt=cpt;
	m_rbp=rbp;
	m_sci=sci;
	m_fbu=fbu;
	m_rer=rer;
	m_mhra=mhra;
	m_eia=eia;
	m_op=op;
	m_sope=sope;
	m_nomv=nomv;
	m_thal=thal;
}

⌨️ 快捷键说明

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