数据挖掘 算法1.数据平滑假定用于分析的数据包含属性age.数据元组中age的值如下(按递增序):13,15,16,16,19,20,20,21,22,22,25,25,25,25,30,33,33,35,35,35,35,36,40,45,46,52,70.使用你所熟悉的程序设计语言进
来源:学生作业帮助网 编辑:作业帮 时间:2024/07/04 01:37:59
![数据挖掘 算法1.数据平滑假定用于分析的数据包含属性age.数据元组中age的值如下(按递增序):13,15,16,16,19,20,20,21,22,22,25,25,25,25,30,33,33,35,35,35,35,36,40,45,46,52,70.使用你所熟悉的程序设计语言进](/uploads/image/z/10401717-21-7.jpg?t=%E6%95%B0%E6%8D%AE%E6%8C%96%E6%8E%98+%E7%AE%97%E6%B3%951.%E6%95%B0%E6%8D%AE%E5%B9%B3%E6%BB%91%E5%81%87%E5%AE%9A%E7%94%A8%E4%BA%8E%E5%88%86%E6%9E%90%E7%9A%84%E6%95%B0%E6%8D%AE%E5%8C%85%E5%90%AB%E5%B1%9E%E6%80%A7age.%E6%95%B0%E6%8D%AE%E5%85%83%E7%BB%84%E4%B8%ADage%E7%9A%84%E5%80%BC%E5%A6%82%E4%B8%8B%EF%BC%88%E6%8C%89%E9%80%92%E5%A2%9E%E5%BA%8F%EF%BC%89%EF%BC%9A13%2C15%2C16%2C16%2C19%2C20%2C20%2C21%2C22%2C22%2C25%2C25%2C25%2C25%2C30%2C33%2C33%2C35%2C35%2C35%2C35%2C36%2C40%2C45%2C46%2C52%2C70.%E4%BD%BF%E7%94%A8%E4%BD%A0%E6%89%80%E7%86%9F%E6%82%89%E7%9A%84%E7%A8%8B%E5%BA%8F%E8%AE%BE%E8%AE%A1%E8%AF%AD%E8%A8%80%E8%BF%9B)
数据挖掘 算法1.数据平滑假定用于分析的数据包含属性age.数据元组中age的值如下(按递增序):13,15,16,16,19,20,20,21,22,22,25,25,25,25,30,33,33,35,35,35,35,36,40,45,46,52,70.使用你所熟悉的程序设计语言进
数据挖掘 算法
1.数据平滑
假定用于分析的数据包含属性age.数据元组中age的值如下(按递增序):13,15,16,16,19,20,20,21,22,22,25,25,25,25,30,33,33,35,35,35,35,36,40,45,46,52,70.使用你所熟悉的程序设计语言进行编程,实现如下功能(要求程序具有通用性):
(a) 使用按箱平均值平滑法对以上数据进行平滑,箱的深度为3.
(b) 使用按箱中值平滑法对以上数据进行平滑,箱的深度为3.
(c) 使用按箱边界值平滑法对以上数据进行平滑,箱的深度为3.
2.离群点筛选
数据同上题,使用你所熟悉的程序设计语言进行编程,找出其中的离群点(要求程序具有通用性).
要求程序具有通用性,最好用链表
数据挖掘 算法1.数据平滑假定用于分析的数据包含属性age.数据元组中age的值如下(按递增序):13,15,16,16,19,20,20,21,22,22,25,25,25,25,30,33,33,35,35,35,35,36,40,45,46,52,70.使用你所熟悉的程序设计语言进
第一题结果:
#include <stdio.h>
#define DATALEN 27
int data[DATALEN]=
\x09{13, 15, 16,
\x09 16, 19, 20,
\x09 20, 21, 22,
\x09 22, 25, 25,
\x09 25, 25, 30,
33, 33, 35,
35, 35, 35,
\x09 36, 40, 45,
\x09 46, 52, 70};
int nSmoothByMeans[DATALEN]={0};
int nSmoothByMedians[DATALEN]={0};
int nSmoothByBoundaries[DATALEN]={0};
void SmoothByMeans(int depth)
{
\x09int i=0,j=0;
\x09int sum=0 , mean=0;
\x09for(i=0;i<27;i=i+3)
\x09{
\x09\x09for (j=i;j<i+depth;j++)
\x09\x09{
\x09\x09\x09sum+=data[j];
\x09\x09}
\x09\x09mean = sum/depth;
\x09\x09for (j=i;j<i+depth;j++)
\x09\x09{
\x09\x09\x09nSmoothByMeans[j]=mean;
\x09\x09}
\x09\x09sum = 0;
\x09}
}
void SmoothByMedians(int depth)
{
\x09int i=0,j=0;
\x09for(i=1;i<27;i=i+3)
\x09{
\x09\x09for (j=i-1;j<i+depth;j++)
\x09\x09{
\x09\x09\x09nSmoothByMedians[j]=data[i];
\x09\x09}
\x09}
}
void SmoothByBoundaries(int depth)
{
\x09int i=0,j=0;
\x09for(i=0;i<27;i++)
\x09{
\x09\x09nSmoothByBoundaries[i]=data[i];
\x09}
\x09for (i=1;i<27;i=i+3)
\x09{
\x09\x09if (data[i]-data[i-1]>data[i+1]-data[i])
\x09\x09{
\x09\x09\x09nSmoothByBoundaries[i]=data[i+1];
\x09\x09}
\x09\x09else
\x09\x09{
\x09\x09\x09nSmoothByBoundaries[i]=data[i-1];
\x09\x09}
\x09}
}
void main()
{
\x09int depth = 3;
\x09int i=0;
\x09int j=0;
\x09SmoothByMeans(3);
\x09SmoothByMedians(3);
\x09SmoothByBoundaries(3);
printf("原始数据:\n");
\x09for(i=0,j=1;i<27;i=i+3,++j)
\x09{
\x09\x09
\x09\x09printf("Bin %d : %d,%d,%d\n",
\x09\x09\x09j,data[i],data[i+1],data[i+2]);
\x09}
\x09printf("使用平均值:\n");
\x09for(i=0,j=1;i<27;i=i+3,++j)
\x09{
\x09\x09
\x09\x09printf("Bin %d : %d,%d,%d\n",
\x09\x09\x09j,nSmoothByMeans[i],nSmoothByMeans[i+1],nSmoothByMeans[i+2]);
\x09}
\x09printf("使用中值:\n");
\x09for(i=0,j=1;i<27;i=i+3,++j)
\x09{
\x09\x09
\x09\x09printf("Bin %d : %d,%d,%d\n",
\x09\x09\x09j,nSmoothByMedians[i],nSmoothByMedians[i+1],nSmoothByMedians[i+2]);
\x09}
\x09printf("使用边界值:\n");
\x09for(i=0,j=1;i<27;i=i+3,++j)
\x09{
\x09\x09
\x09\x09printf("Bin %d : %d,%d,%d\n",
\x09\x09\x09j,nSmoothByBoundaries[i],nSmoothByBoundaries[i+1],nSmoothByBoundaries[i+2]);
\x09}
}