public class KNN extends Metodo
Modifier and Type | Field and Description |
---|---|
protected InstanceSet |
referencia
Data structures
|
clasesTest, clasesTrain, datosTest, datosTrain, entradas, ficheroSalida, ficheroTest, ficheroTraining, ficheroValidation, nEntradas, nominalDistance, nominalTrain, nulosTrain, realTest, realTrain, relation, salida, stdDev, test, training
Constructor and Description |
---|
KNN(InstanceSet dataset,
int value_k)
Parameter constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
configuracion(int value_k)
Configures the KNN algorithm setting the k value and the outliers thershold k values as
the 80% of k.
|
static int |
differentClass(int nvec,
int classE,
double[][] conj,
double[] ejemplo)
Returns the number of neighbours of the example given that differ in the class value.
|
static double |
distancia(double[] ej1,
double[] ej2)
Computes the Euclidean distance between the two examples given.
|
void |
ejecutar(int[] outliers,
int[] ExamplesClass)
Executes the KNN algorithm on the training dataset to obtain the outliers during the classification.
|
leerConfiguracion, normalizar
protected InstanceSet referencia
public KNN(InstanceSet dataset, int value_k)
dataset
- Training dataset.value_k
- number of nearest neighbours cosidered.public void ejecutar(int[] outliers, int[] ExamplesClass)
outliers
- Number of outliers for each classes.ExamplesClass
- Number of instances for each original classes.public void configuracion(int value_k)
value_k
- number of neighbors considered.public static int differentClass(int nvec, int classE, double[][] conj, double[] ejemplo)
nvec
- number of neighbours considered.classE
- original class of the example.conj
- Training dataset.ejemplo
- example to evaluate.public static double distancia(double[] ej1, double[] ej2)
ej1
- first given example.ej2
- second given example.