Predict using an model in a local or GCS directory.
166590
def predict(model_dir, image_files, resize, show_image):
    """"""

    from . import _predictor

    images = _util.load_images(image_files, resize=resize)
    labels_and_scores = _predictor.predict(model_dir, images)
    results = zip(image_files, images, labels_and_scores)
    ret = _util.process_prediction_results(results, show_image)
    return ret
119804
def predict(self, x, *args, **kwargs):
        
        if not self.model:
            raise Exception('Not trained. Train first')

        points = self._dimensionality_check(x, ext='points')

        return self.execute(points, *args, **kwargs)[0]
1273264
def predict(model, x):
    
    if not hasattr(x, "chunks") and hasattr(x, "to_dask_array"):
        x = x.to_dask_array()
    assert x.ndim == 2
    if len(x.chunks[1]) > 1:
        x = x.rechunk(chunks=(x.chunks[0], sum(x.chunks[1])))
    func = partial(_predict, model)
    xx = np.zeros((1, x.shape[1]), dtype=x.dtype)
    dt = model.predict(xx).dtype
    return x.map_blocks(func, chunks=(x.chunks[0], (1,)), dtype=dt).squeeze()
890048
def cloud_batch_predict(training_dir, prediction_input_file, output_dir, mode, batch_size,
                        shard_files, output_format):
  """"""
  # from . import predict as predict_module
  from .prediction import predict as predict_module

  if mode == 'evaluation':
    model_dir = os.path.join(training_dir, 'evaluation_model')
  elif mode == 'prediction':
    model_dir = os.path.join(training_dir, 'model')
  else:
    raise ValueError('mode must be evaluation or prediction')

  if not file_io.file_exists(model_dir):
    raise ValueError('Model folder %s does not exist' % model_dir)

  _assert_gcs_files([training_dir, prediction_input_file, output_dir])

  cmd = ['predict.py',
         '--cloud',
         '--project-id=%s' % _default_project(),
         '--predict-data=%s' % prediction_input_file,
         '--trained-model-dir=%s' % model_dir,
         '--output-dir=%s' % output_dir,
         '--output-format=%s' % output_format,
         '--batch-size=%s' % str(batch_size),
         '--shard-files' if shard_files else '--no-shard-files',
         '--extra-package=%s' % _TF_GS_URL,
         '--extra-package=%s' % _PROTOBUF_GS_URL,
         '--extra-package=%s' % _package_to_staging(output_dir)
         ]

  return predict_module.main(cmd)
757401
def is_dataset_on_gcs(dataset_name):
  """"""
  dir_name = posixpath.join(GCS_DATASETS_DIR, dataset_name)
  return len(gcs_files(prefix_filter=dir_name)) > 2
352592
def dM(self, k, t, param, Mkt, tips=None, gaps=None):
        """"""
        assert 0 <= k < self.ncats
        assert ((param in self.freeparams) or (param == 't') or (
                param == self.distributedparam))
        assert param not in self.distributionparams
        return self._models[k].dM(t, param, Mkt, tips=tips, gaps=gaps)
514090
def predict_withGradients(self, X):
        
        if X.ndim==1: X = X[None,:]
        m, v = self.model.predict(X)
        v = np.clip(v, 1e-10, np.inf)
        dmdx, dvdx = self.model.predictive_gradients(X)
        dmdx = dmdx[:,:,0]
        dsdx = dvdx / (2*np.sqrt(v))

        return m, np.sqrt(v), dmdx, dsdx
823376
def predict(self, v=None, X=None):
        """"""
        if X is None:
            X = v
            v = None
        m = self.model(v=v)
        return m.predict(X)
916775
def load(cls, sc, path):
        """"""
        java_model = sc._jvm.org.apache.spark.mllib.regression.IsotonicRegressionModel.load(
            sc._jsc.sc(), path)
        py_boundaries = _java2py(sc, java_model.boundaryVector()).toArray()
        py_predictions = _java2py(sc, java_model.predictionVector()).toArray()
        return IsotonicRegressionModel(py_boundaries, py_predictions, java_model.isotonic)
1168471
def _default_output_dir():
  """"""
  try:
    dataset_name = gin.query_parameter("inputs.dataset_name")
  except ValueError:
    dataset_name = "random"
  dir_name = "{model_name}_{dataset_name}_{timestamp}".format(
      model_name=gin.query_parameter("train.model").configurable.name,
      dataset_name=dataset_name,
      timestamp=datetime.datetime.now().strftime("%Y%m%d_%H%M"),
  )
  dir_path = os.path.join("~", "trax", dir_name)
  print()
  trax.log("No --output_dir specified")
  return dir_path
1288928
def predict(self, X):
        
        logprob, responsibilities = self.score_samples(X)
        return responsibilities.argmax(axis=1)
135487
private ModelMetrics makeModelMetrics(SharedTreeModel model, Frame fr, Frame adaptedFr, Frame preds) {
    ModelMetrics mm;
    if (model._output.nclasses() == 2 && _computeGainsLift) {
      assert preds != null : "Predictions were pre-created";
      mm = _mb.makeModelMetrics(model, fr, adaptedFr, preds);
    } else {
      boolean calculatePreds = preds == null && model._parms._distribution == DistributionFamily.huber;
      // FIXME: PUBDEV-4992 we should avoid doing full scoring!
      if (calculatePreds) {
        Log.warn("Going to calculate predictions from scratch. This can be expensive for large models! See PUBDEV-4992");
        preds = model.score(fr);
      }
      mm = _mb.makeModelMetrics(model, fr, null, preds);
      if (calculatePreds && (preds != null))
        preds.remove();
    }
    return mm;
  }
1277226
function predictOne(inst) {
      
      // have each tree predict and average out all votes
      var dec=0;
      for(var i=0;i<this.numTrees;i++) {
        dec += this.trees[i].predictOne(inst);
      }
      dec /= this.numTrees;
      return dec;
}
1101482
def get_predictions_under_consistency(instance):
    '''
    
    '''
    inst   = instance.to_file()
    prg    = [ prediction_prg, inst, exclude_sol([]) ]
    solver = GringoClasp(clasp_options='--project --enum-mode cautious')
    models = solver.run(prg, collapseTerms=True, collapseAtoms=False)
    os.unlink(inst)
    os.unlink(prg[2])
    return whatsnew(instance,models[0])
481142
def predict(self, X):
        
        logger.info('predicting ...')
        ps = self.predict_raw(X)

        return sigm(ps[:, 0])
443890
def get_prediction(self, features=None, tag=None, namespaces=None):
        """"""
        if features is not None:
            namespace = Namespace(features=features)
            self.add_namespace(namespace)
        result = self.send_example(tag=tag, namespaces=namespaces)
        return result
333212
def _to_predictor(self, pred_parameter=None):
        """"""
        predictor = _InnerPredictor(booster_handle=self.handle, pred_parameter=pred_parameter)
        predictor.pandas_categorical = self.pandas_categorical
        return predictor