com.actelion.research.util.datamodel.ModelXYClassLabel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of openchemlib Show documentation
Show all versions of openchemlib Show documentation
Open Source Chemistry Library
package com.actelion.research.util.datamodel;
import java.util.ArrayList;
import java.util.List;
/**
*
*
* ModelXYClassLabel
* @author Modest von Korff
* 02.01.2019 MvK: Start implementation
*/
public class ModelXYClassLabel extends ModelXYIndex {
// Class label. To enable a controlled leave out cross validation.
public List liClassLabel;
public ModelXYClassLabel() {
}
/**
* Deep copy constructor
* @param dataXY
*/
public ModelXYClassLabel(ModelXYClassLabel dataXY) {
super(dataXY);
if(dataXY.liClassLabel!=null) {
liClassLabel = new ArrayList(dataXY.X.rows());
for (int index : dataXY.liClassLabel) {
liClassLabel.add(index);
}
}
}
public ModelXYClassLabel sub(List liIndexRow){
ModelXYClassLabel modelDataXY = new ModelXYClassLabel();
modelDataXY.X = X.getSubMatrix(liIndexRow);
modelDataXY.Y = Y.getSubMatrix(liIndexRow);
modelDataXY.liIndex = new ArrayList<>(liIndexRow);
return modelDataXY;
}
public void sub(List liIndexRow, ModelXYClassLabel modelXYIndex){
for (int i = 0; i < liIndexRow.size(); i++) {
int index = liIndexRow.get(i);
double [] a = X.getRow(index);
modelXYIndex.X.setRow(i, a);
double [] b = Y.getRow(index);
modelXYIndex.Y.setRow(i, b);
}
}
@Override
public ModelXYClassLabel getDeepClone() {
return new ModelXYClassLabel(this);
}
}