public static LabeledPoint pointOf ( Collection < Writable > writables ) { double [ ] ret = new double [ writables . size ( ) - 1 ] ; int count = 0 ; double target = 0 ; for ( Writable w : writables ) { if ( count < writables . size ( ) - 1 ) ret [ count ++ ] = Float . parseFloat ( w . toString ( ) ) ; else target = Float . parseFloat ( w . toString ( ) ) ; } if ( target < 0 ) throw new IllegalStateException ( "Target must be >= 0" ) ; return new LabeledPoint ( target , Vectors . dense ( ret ) ) ; }
Returns a labeled point of the writables where the final item is the point and the rest of the items are features