public static int [ ] toClassificationVector ( Iterable < MLClassificationRecord > data ) { final List < Integer > responseVariables = new ArrayList <> ( ) ; final List < Object > classifications = new ArrayList <> ( ) ; for ( MLClassificationRecord record : data ) { final Object classification = record . getClassification ( ) ; int classificationIndex = classifications . indexOf ( classification ) ; if ( classificationIndex == - 1 ) { classifications . add ( classification ) ; classificationIndex = classifications . size ( ) - 1 ; } responseVariables . add ( classificationIndex ) ; } final int [ ] y = responseVariables . stream ( ) . mapToInt ( i -> i ) . toArray ( ) ; return y ; }
Generates a vector of classifications for each record .