build/modelscript.cjs.js
function grid_search(options = {}) {
  const config = Object.assign({}, {
    return_parameters: false,
    compare_score:'mean',
    sortAccuracyScore:'desc',
    parameters: {},
  }, options);
  const regressor = config.regression;
  const classification = config.classifier;
  const sortAccuracyScore = (!options.sortAccuracyScore && config.regression)
    ? 'asc'
    : config.sortAccuracyScore;
  
  // const scoreSorter = ;
  const gs = new GridSearch({
    params: config.parameters,
    run_callback: (params) => {
      if (config.regression) {
        config.regression = new regressor(params);
      } else {
        config.classifier = new classification(params);
      }
      const score = cross_validate_score(config);
      return (config.compare_score)
        ? util[config.compare_score](score)
        : score;
    },
  });
  gs.run();
  const accuracySorter = (sortAccuracyScore === 'desc')
    ? (a, b) => b.results - a.results
    : (a, b) => a.results - b.results;
  const results = gs._results.sort(accuracySorter);
  // GridSearch;
  return config.return_parameters
    ? results
    : results[ 0 ];
}
function grid_search(options = {}) {
  const config = Object.assign({}, {
    return_parameters: false,
    compare_score:'mean',
    sortAccuracyScore:'desc',
    parameters: {},
  }, options);
  const regressor = config.regression;
  const classification = config.classifier;
  const sortAccuracyScore = (!options.sortAccuracyScore && config.regression)
    ? 'asc'
    : config.sortAccuracyScore;
  
  // const scoreSorter = ;
  const gs = new GridSearch({
    params: config.parameters,
    run_callback: (params) => {
      if (config.regression) {
        config.regression = new regressor(params);
      } else {
        config.classifier = new classification(params);
      }
      const score = cross_validate_score(config);
      return (config.compare_score)
        ? util[config.compare_score](score)
        : score;
    },
  });
  gs.run();
  const accuracySorter = (sortAccuracyScore === 'desc')
    ? (a, b) => b.results - a.results
    : (a, b) => a.results - b.results;
  const results = gs._results.sort(accuracySorter);
  // GridSearch;
  return config.return_parameters
    ? results
    : results[ 0 ];
}
function grid_search ( options = { } ) { const config = Object . assign ( { } , { return_parameters : false , compare_score : 'mean' , sortAccuracyScore : 'desc' , parameters : { } , } , options ) ; const regressor = config . regression ; const classification = config . classifier ; const sortAccuracyScore = ( ! options . sortAccuracyScore && config . regression ) ? 'asc' : config . sortAccuracyScore ; // const scoreSorter = ;
 const gs = new GridSearch ( { params : config . parameters , run_callback : ( params ) => { if ( config . regression ) { config . regression = new regressor ( params ) ; } else { config . classifier = new classification ( params ) ; } const score = cross_validate_score ( config ) ; return ( config . compare_score ) ? util [ config . compare_score ] ( score ) : score ; } , } ) ; gs . run ( ) ; const accuracySorter = ( sortAccuracyScore === 'desc' ) ? ( a , b ) => b . results - a . results : ( a , b ) => a . results - b . results ; const results = gs . _results . sort ( accuracySorter ) ; // GridSearch;
 return config . return_parameters ? results : results [ 0 ] ; }
Used to test variance and bias of a prediction with parameter tuning
@memberOf cross_validation
@param {object} options
@param {function} options.classifier - instance of classification model used for training, or function to train a model. e.g. new DecisionTreeClassifier({ gainFunction: 'gini', }) or ml.KNN
@param {function} options.regression - instance of regression model used for training, or function to train a model. e.g. new RandomForestRegression({ nEstimators: 300, }) or ml.MultivariateLinearRegression
@return {number[]} Array of accucracy calculations
Used to test variance and bias of a prediction with parameter tuning