@ Override public IModel train ( String trainMethodName , Object ... paramArgs ) throws DDFException { /** * Example signatures we must support: * <p/> * Unsupervised Training * <p/> * <code> * Kmeans.train(data: RDD[Array[Double]], k: Int, maxIterations: Int, runs: Int, initializationMode: String) * </code> * <p/> * Supervised Training * <p/> * <code> * LogisticRegressionWithSGD.train(input: RDD[LabeledPoint], numIterations: Int, stepSize: Double, miniBatchFraction: * Double, initialWeights: Array[Double]) * * SVM.train(input: RDD[LabeledPoint], numIterations: Int, stepSize: Double, regParam: Double, miniBatchFraction: * Double) * </code> */ // Build the argument type array if ( paramArgs == null ) paramArgs = new Object [ 0 ] ; // Locate the training method String mappedName = Config . getValueWithGlobalDefault ( this . getEngine ( ) , trainMethodName ) ; if ( ! Strings . isNullOrEmpty ( mappedName ) ) trainMethodName = mappedName ; TrainMethod trainMethod = new TrainMethod ( trainMethodName , MLClassMethods . DEFAULT_TRAIN_METHOD_NAME , paramArgs ) ; if ( trainMethod . getMethod ( ) == null ) { throw new DDFException ( String . format ( "Cannot locate method specified by %s" , trainMethodName ) ) ; } // Now we need to map the DDF and its column specs to the input format expected by the method we're invoking Object [ ] allArgs = this . buildArgsForMethod ( trainMethod . getMethod ( ) , paramArgs ) ; // Invoke the training method Object rawModel = trainMethod . classInvoke ( allArgs ) ; List < Schema . Column > columns = this . getDDF ( ) . getSchemaHandler ( ) . getColumns ( ) ; String [ ] trainedColumns = new String [ columns . size ( ) ] ; for ( int i = 0 ; i < columns . size ( ) ; i ++ ) { trainedColumns [ i ] = columns . get ( i ) . getName ( ) ; } for ( String col : trainedColumns ) { mLog . info ( ">>>>>> trainedCol = " + col ) ; } IModel model = this . newModel ( rawModel ) ; model . setTrainedColumns ( trainedColumns ) ; mLog . info ( ">>>> modelID = " + model . getName ( ) ) ; this . getManager ( ) . addModel ( model ) ; return model ; }
Runs a training algorithm on the entire DDF dataset .