Red de conocimiento informático - Aprendizaje de código fuente - Algoritmo de minería de datos

Algoritmo de minería de datos

El resultado de la primera pregunta:

#include?lt;stdio.hgt;

#define?DATALEN?27

int?datos[DATALEN]=

{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};

int? nSmoothByMeans[ DATALEN]={0};

int?nSmoothByMedians[DATALEN]={0};

int?nSmoothByByBoundaries[DATALEN]={0};

void?SmoothByMeans(int?profundidad)

{

int?i=0, j=0;

int?sum=0?,? media= 0;

para(i=0;ilt;27;i=i 3)

{

para?(j=i;jlt; i profundidad ; j )

{

suma =datos[j];

}

media?=?suma/profundidad;

p>

for?(j=i;jlt;i profundidad;j)

{

nSmoothByMeans[j]=media;

}

suma?=?0;

}

}

void?SmoothByMedians(int?profundidad)

{

int?i=0,j=0;

for(i=1;ilt;27;i=i 3)

{

p>

para?(j=i-1; jlt; i profundidad; j )

{

nSmoothByMedians[j]= datos[i];

}

}

}

void?SmoothByBoundaries(int?profundidad)

{

int?i=0,j=0;

for(i=0;ilt;27;i)

{

nSmoothByBoundaries[i]=datos [i];

}

para?(i=1; ilt; 27; i=i 3)

{

si?(datos[i]-datos[i-1]gt;datos[i 1]-datos[i])

{

nSmoothByByBoundaries[i]=datos[i 1];

}

else

{

nSmoothByByBoundaries[i]=datos[ i-1];

}

}

}

void?main()

{

int?profundidad?=?3;

int?i=0;

int?j=0;

SmoothByMeans(3);

SmoothByMedians(3);

SmoothByByBoundaries(3);

printf("Datos originales:\n");

for(i=0 , j=1;ilt;27;i=i 3, j)

{

printf("Bin?d?:?d,d , d\n",

j, datos[i], datos[i 1], datos[i 2]);

}

printf( "Usar promedio:\n");

for(i=0, j=1; ilt; 27; i=i 3, j)

{

printf("Bin?d?:?d, d, d\n",

j, nSmoothByMeans[i], nSmoothByMeans[i 1], nSmoothByMeans[ i 2]);

}

printf("Usar mediana:\n");

for(i=0, j=1; ilt ;27 ; i=i 3, j)

{

printf("Bin?d?:?d, d, d\n",

j, nSmoothByMedians[i], nSmoothByMedians[i 1], nSmoothByMedians[i 2]);

}

printf("Usar valor de límite: \ n"

para (i=0, j=1; ilt; 27; i=i 3, j)

{

<); p> printf("Bin?d?:?d, d, d\n",

j, nSmoothByBoundaries[i], nSmoothByBoundaries[i 1], nSmoothByBoundaries[i 2]);

}

}