@Override
    public void train(final Matrix matrix) {
        List<List<Double>> data = matrix.getData();
        for (int colIndex = 0; colIndex < data.get(0).size(); colIndex++){
            if (matrix.getColumnAttributes(colIndex).getColumnType()== ColumnAttributes.ColumnType.CATEGORICAL){
                Counter<Double> counter = new Counter<Double>();
                for (int rowIndex = 0; rowIndex < data.size(); rowIndex++){
                    Double value = data.get(rowIndex).get(colIndex);
                    if(!value.equals(Matrix.UNKNOWN_VALUE)){
                        counter.increment(data.get(rowIndex).get(colIndex));
                    }
                }
                columnCentroids.add(colIndex, counter.getMax());
            }
            else if (matrix.getColumnAttributes(colIndex).getColumnType()== ColumnAttributes.ColumnType.CONTINUOUS){
                Double total = 0.0;
                for (int rowIndex = 0; rowIndex < data.size(); rowIndex++){
                    Double value = data.get(rowIndex).get(colIndex);
                    if(!value.equals(Matrix.UNKNOWN_VALUE)){
                        total+=data.get(rowIndex).get(colIndex);
                    }
                }
                Double average = total/data.size();
                columnCentroids.add(colIndex, average);
            }
        }

    }