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

📄 mysmo.h

📁 对支持向量机svm算法的改进算法
💻 H
字号:
// mysmo.h: interface for the mysmo class.
//
//////////////////////////////////////////////////////////////////////
#ifndef MYSMO_H
#define MYSMO_H

class mysmo  
{
public:
	float m_sigma; //Sigma of kernel function
	float m_C; //Penalty factor (HIGH->high penalty for wrong side)
	float m_tolerance; //Tolerance in KKT condition
	float m_eps; //Break limit
	float m_b; //Threshold (begin at 0)	
	float * m_x; //The training points	
	float * m_y; //Classification of training points
	float precision;
	unsigned int m_xNum; //Number of training points
	
	int		indicator_function(float *v);//Returns 1 or -1 as class. for v
	float	decision_function(float * v);//Calculates the decision func. at v
	int		testing(char * fileName,unsigned int number);
	int		LMToFile(char * fileName);
	int		readPoint(char * FileName,unsigned int number,unsigned int dimession);
	int		pointToFile(char * FileName,float * instance ,float * y,unsigned int number);	
	int		scale(char * FileName,unsigned int number,unsigned int dimession);
	int		skipToFile(char * FileName,float * x ,float * y,unsigned int number);
	int		skip(char * FileName,unsigned int number,unsigned int dimession);
	void	RenormalizeData(float * instance,unsigned int number);
	int		createSmo();
	void	freeCsmo();
	byte	getFileName(char * dest,const char * source);
	mysmo(float c,float tolerance,float eps);
	virtual ~mysmo();	
	
private:
	int		allocMemory(unsigned int number,unsigned int dimession);
	void	initCsmo();
	int		tryLM(int i1);
	float	kernel(int i1, int i2);//The kernel function
	int		optimize( int i1, int i2 );
	float	dot_product(int i1, int i2);//Dot product x*y
	float	learned_func(int k);//The learned function w*x - b= sum(ai*yi*ki) -b
	int		scaleToFile(char * FileName,float * x ,float * y,unsigned int number);
	float	drand48();	
	float * m_a; //Lagrange multipliers (LM)
	float * m_w; //Weight vector	
	float * m_self_dot_product; //vector of dot prod x*x for all x
	float * m_e; //vector of prediction error Ei
	int		m_end_support_i; //Support vectors are from 0...end_support_i	
	float	m_two_sigma_squared;	
	float * m_testIns; //The training points
	float * m_errInsIndex;//testing err instance's index
	float * m_max;
	float * m_min;	
	unsigned int m_testNum;	//number of testing points
	unsigned int m_dimension; //dimension of points	
};

#endif // !defined(AFX_MYSMO_H__5C8FAA21_E7D6_4A25_B443_B0370E8FBEAE__INCLUDED_)

⌨️ 快捷键说明

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