You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2022/06/10 17:49:27 UTC

[GitHub] [beam] yeandy commented on a diff in pull request #21795: Merge ModelLoader and InferenceRunner into same class.

yeandy commented on code in PR #21795:
URL: https://github.com/apache/beam/pull/21795#discussion_r894767368


##########
sdks/python/apache_beam/ml/inference/sklearn_inference.py:
##########
@@ -41,36 +40,20 @@ class ModelFileType(enum.Enum):
   JOBLIB = 2
 
 
-class SklearnInferenceRunner(InferenceRunner[numpy.ndarray,
-                                             PredictionResult,
-                                             BaseEstimator]):
-  def run_inference(
-      self, batch: List[numpy.ndarray], model: BaseEstimator,
-      **kwargs) -> Iterable[PredictionResult]:
-    # vectorize data for better performance
-    vectorized_batch = numpy.stack(batch, axis=0)
-    predictions = model.predict(vectorized_batch)
-    return [PredictionResult(x, y) for x, y in zip(batch, predictions)]
-
-  def get_num_bytes(self, batch: List[numpy.ndarray]) -> int:
-    """Returns the number of bytes of data for a batch."""
-    return sum(sys.getsizeof(element) for element in batch)
-
-
-class SklearnModelLoader(ModelLoader[numpy.ndarray,
-                                     PredictionResult,
-                                     BaseEstimator]):
-  """ Implementation of the ModelLoader interface for scikit learn.
+class SklearnModelHandler(ModelHandler[numpy.ndarray,
+                                       PredictionResult,
+                                       BaseEstimator]):
+  """ Implementation of the ModelHandler interface for scikit learn.

Review Comment:
   nit
   ```suggestion
     """ Implementation of the ModelHandler interface for scikit-learn.
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org