com.actelion.research.calc.regression.knn.ParameterKNN Maven / Gradle / Ivy
Show all versions of openchemlib Show documentation
package com.actelion.research.calc.regression.knn;
import com.actelion.research.calc.regression.ConstantsRegressionMethods;
import com.actelion.research.calc.regression.ParameterRegressionMethod;
import java.io.File;
import java.io.IOException;
import java.util.List;
/**
* ParameterKNN
* Modest v. Korff
*
* Created by korffmo1 on 06.12.18.
*/
public class ParameterKNN extends ParameterRegressionMethod {
public static final String TAG_NEIGHBOURS="Neighbours";
private int neighbours;
public ParameterKNN() {
super(ConstantsRegressionMethods.MODEL_KNN);
setNeighbours(KNNRegression.NEIGHBOURS);
}
public ParameterKNN(int neighbours) {
super(ConstantsRegressionMethods.MODEL_KNN);
setNeighbours(neighbours);
}
public int getNeighbours() {
return neighbours;
}
public void setNeighbours(int neighbours) {
this.neighbours = neighbours;
properties.setProperty(TAG_NEIGHBOURS, Integer.toString(neighbours));
}
@Override
public int compareTo(ParameterRegressionMethod o) {
int cmp = 0;
ParameterKNN parameterKNN = (ParameterKNN)o;
if(neighbours>parameterKNN.neighbours) {
cmp=1;
}else if(neighbours getHeader(){
List li = ParameterRegressionMethod.getHeader();
li.add(TAG_NEIGHBOURS);
return li;
}
public static void main(String[] args) throws IOException {
File dir = new File("/home/korffmo1/tmp/tmp00");
File fiProp = new File(dir, "knn.properties");
ParameterKNN parameterKNN = new ParameterKNN();
parameterKNN.setNeighbours(3);
parameterKNN.write(fiProp);
ParameterKNN parameterKNNIn = new ParameterKNN();
parameterKNNIn.read(fiProp);
System.out.println(parameterKNNIn.toString());
}
}