test.c
来自「贝叶斯分类程序,iris数据集,很有用,已测试」· C语言 代码 · 共 82 行
C
82 行
#include "global.h"
void main()
{
double choice;
int type;
double test_attri[ATTRIBUTENUM];
IrisData();
MeanEstimation();
CovarianceEstimation();
ReverseMatrix();
printf("*************************贝叶斯分类器建立完毕:****************************\n\n");
while(1)
{
printf("****分类(1):****\n");
printf("****退出(2):****\n");
scanf("%lf",&(choice));
if(choice==1)
{
printf("输入属性值:\n");
printf("setal_length:\n");
scanf("%lf",&(test_attri[0]));
printf("setal_width:\n");
scanf("%lf",&(test_attri[1]));
printf("petal_length:\n");
scanf("%lf",&(test_attri[2]));
printf("petal_width:\n");
scanf("%lf",&(test_attri[3]));
type=ClassiFier(test_attri);
switch(type)
{
case IRIS_SETOSA:
printf("所属类别:\n\n******Iris_setosa******\n");
break;
case IRIS_VERSICOLOR:
printf("所属类别:\n\n******Iris_versicolor******\n");
break;
case IRIS_VERGINICA:
printf("所属类别:\n\n******Iris_verginica******\n");
break;
default:
printf("%d\n",type);
}
}
else if(choice==2)
{
break;
}
else
{
//printf("%d\n",choice);
printf("重新输入!!!\n");
}
printf("\n");
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?