Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
knnctl.h
Package: Knn.rar [view]
Upload User: xmhs66
Upload Date: 2022-07-26
Package Size: 989k
Code Size: 1k
Category:
Bio-Recognize
Development Platform:
Visual C++
- /**********************************************************************
- * * filename: knnctl.h
- * * description: Knnctl类
- * * 1. 从文件中读取记录并解析到Mail类中
- * * 2. 对数据进行标准化
- * * 3. 求出错误率最小的K值
- * * student: Liwanjun
- * * data: 2010-03-29
- * **********************************************************************/
- #ifndef _KNNCTL_H
- #define _KNNCTL_H
- #include "mail.h"
- #include <vector>
- #include <utility>
- using std::vector;
- using std::string;
- using std::pair;
- class Knnctl
- {
- public:
- Knnctl();
- void readFile(string filename);
- void readFile(string filename, vector<Mail>& vec, bool istest);
- //将训练集分割为子训练集和子测试集
- void divideFile();
- //对数据进行[0,1]区间标准化
- void standard(vector<Mail>&, string filename);
- //计算向量间相似度,欧氏距离或向量夹角余弦
- void calSimi (vector<Mail>& svec, vector<Mail>& tvec);
- //确定最优的K值
- void calKno (vector<Mail>& svec, vector<Mail>& tvec);
- //对最终的训练集和测试集应用KNN
- void classification(vector<Mail>& svec, vector<Mail>& tvec);
- //经过解析的训练集
- vector<Mail> studyvec;
- //经过解析的测试集
- vector<Mail> testvec;
- private:
- //错误率最小的K值
- int kno;
- //直接从文件中读取的行字符串
- vector<string> recovec;
- //分类属性
- bool bSimi;
- };
- #endif