function(options, callback) {
      var data = options.data;
      var target = options.target;
      var features = options.features;
      var featureTypes = options.featureTypes;

      featureTypes.forEach(function(f) {
        if (['number','category'].indexOf(f) === -1) {
          callback(new Error('Unrecognized feature type'));
          return;
        }
      });

      var targets = unique(data.map(function(d) {
        return d[d.length-1];
      }));
      this.features = features;
      this.targets = targets;
      this.target = target

      var classify = this.classify.bind(this)

      var model = {
        features: this.features,
        targets: this.targets,

        // model is the generated tree structure
        model: this._c45(data, target, features, featureTypes, 0),

        classify: function (sample) {
          return classify(this.model, sample)
        },

        toJSON: function() {
          return JSON.stringify(this.model)
        }
      };

      this.model = model.model

      callback(null, model);
    }
function(options, callback) {
      var data = options.data;
      var target = options.target;
      var features = options.features;
      var featureTypes = options.featureTypes;

      featureTypes.forEach(function(f) {
        if (['number','category'].indexOf(f) === -1) {
          callback(new Error('Unrecognized feature type'));
          return;
        }
      });

      var targets = unique(data.map(function(d) {
        return d[d.length-1];
      }));
      this.features = features;
      this.targets = targets;
      this.target = target

      var classify = this.classify.bind(this)

      var model = {
        features: this.features,
        targets: this.targets,

        
        model: this._c45(data, target, features, featureTypes, 0),

        classify: function (sample) {
          return classify(this.model, sample)
        },

        toJSON: function() {
          return JSON.stringify(this.model)
        }
      };

      this.model = model.model

      callback(null, model);
    }
function ( options , callback ) { var data = options . data ; var target = options . target ; var features = options . features ; var featureTypes = options . featureTypes ; featureTypes . forEach ( function ( f ) { if ( [ 'number' , 'category' ] . indexOf ( f ) === - 1 ) { callback ( new Error ( 'Unrecognized feature type' ) ) ; return ; } } ) ; var targets = unique ( data . map ( function ( d ) { return d [ d . length - 1 ] ; } ) ) ; this . features = features ; this . targets = targets ; this . target = target var classify = this . classify . bind ( this ) var model = { features : this . features , targets : this . targets , // model is the generated tree structure model : this . _c45 ( data , target , features , featureTypes , 0 ) , classify : function ( sample ) { return classify ( this . model , sample ) } , toJSON : function ( ) { return JSON . stringify ( this . model ) } } ; this . model = model . model callback ( null , model ) ; }
train

@param {object} options
@param {array} options.data - training data
@param {string} options.target - class label
@param {array} options.features - features names
@param {array} options.featureTypes - features type (ie 'category', 'number')
@param {function} callback - callback, containing error and model as parameters
train