View on GitHub

ML

机器学习课程作业

一、实验内容

二、实验环境

三、理论知识

四、实验过程

1、parzen窗

int NPE::judgePar(string vec_str_in, float h)
{
	this->storage.reset();
	Matrix vec1 = this->userInputProcess(vec_str_in);
	float g = - FLT_MAX, temp = 0;//将g赋值为最小浮点数
	int victory = -1;
	for (int counter1 = 1; counter1 <= this->classSize; counter1++)
	{
		temp = 0;
		for (int counter2 = 0; counter2 < this->sampleSize; counter2++)
		{
			Matrix vec2 = vec1 - this->storage.readData();
			temp += exp(-(vec2.trans()*vec2).matrixToFloat()/(2*pow(h,2)));
		}
		if (temp > g)
		{
			g = temp;
			victory = counter1;
		}
	}
	return victory;
}
cout<<eDist(npe.userInputProcess("[1.55,2.66]"), npe.userInputProcess("[2,3]"));

五、遇到的问题

1、思路和算法都正确,结果不正确