Ejemplo n.º 1
0
def setup_predict_data_feeder(X, batch_size=-1):
    """Returns an iterable for feeding into predict step.

    Args:
        X: numpy, pandas, Dask array or iterable.
        batch_size: Size of batches to split data into.
            If negative, returns one batch of full size.

    Returns:
        List or iterator of parts of data to predict on.
    """
    if HAS_DASK:
        X = extract_dask_data(X)
    if HAS_PANDAS:
        X = extract_pandas_data(X)
    if _is_iterable(X):
        return _batch_data(X, batch_size)
    if len(X.shape) == 1:
        X = np.reshape(X, (-1, 1))
    if batch_size > 0:
        n_batches = int(math.ceil(float(len(X)) / batch_size))
        return [
            X[i * batch_size:(i + 1) * batch_size] for i in xrange(n_batches)
        ]
    return [X]
Ejemplo n.º 2
0
def _data_type_filter(X, y):
    """Filter data types into acceptable format"""
    if HAS_PANDAS:
        X = extract_pandas_data(X)
        y = extract_pandas_labels(y)
    if HAS_DASK:
        X = extract_dask_data(X)
        y = extract_dask_labels(y)
    return X, y
def _data_type_filter(X, y):
    """Filter data types into acceptable format"""
    if HAS_DASK:
        X = extract_dask_data(X)
        y = extract_dask_labels(y)
    if HAS_PANDAS:
        X = extract_pandas_data(X)
        y = extract_pandas_labels(y)
    return X, y
Ejemplo n.º 4
0
 def _predict(self, X):
     if not self._initialized:
         raise NotFittedError()
     if HAS_PANDAS:
         X = extract_pandas_data(X)
     if HAS_DASK:
         X = extract_dask_data(X)
     if len(X.shape) == 1:
         X = np.reshape(X, (-1, 1))
     pred = self._session.run(self._model_predictions,
                              feed_dict={self._inp.name: X})
     return pred
Ejemplo n.º 5
0
 def _predict(self, X):
     if not self._initialized:
         raise NotFittedError()
     if HAS_PANDAS:
         X = extract_pandas_data(X)
     if HAS_DASK:
         X = extract_dask_data(X)
     if len(X.shape) == 1:
         X = np.reshape(X, (-1, 1))
     pred = self._session.run(self._model_predictions,
                              feed_dict={
                                  self._inp.name: X
                              })
     return pred
def setup_predict_data_feeder(X, batch_size=-1):
    """Returns an iterable for feeding into predict step.

    Args:
        X: numpy, pandas, Dask array or iterable.
        batch_size: Size of batches to split data into.
            If negative, returns one batch of full size.

    Returns:
        List or iterator of parts of data to predict on.
    """
    if HAS_DASK:
        X = extract_dask_data(X)
    if HAS_PANDAS:
        X = extract_pandas_data(X)
    if _is_iterable(X):
        return _batch_data(X, batch_size)
    if len(X.shape) == 1:
        X = np.reshape(X, (-1, 1))
    return [X]