package inference

import "github.com/apache/beam/sdks/v2/go/pkg/beam/transforms/xlang/inference"

Package inference has the cross language implementation of RunInference API implemented in Python SDK. An expansion service for python external transforms can be started by running

$ python -m apache_beam.runners.portability.expansion_service_main -p $PORT_FOR_EXPANSION_SERVICE

Index

Functions

func SklearnModel

func SklearnModel(modelURI string, opts ...sklearnConfig) sklearn

SklearnModel configures the parameters required to perform RunInference transform on Sklearn Model. It returns an sklearn object which should be used to call RunInference transform. ModelURI is the required parameter indicating the path to the sklearn model.

Example:
  modelURI := "gs://storage/model"
  model := inference.SklearnModel(modelURI)
  prediction := model.RunInference(s, input, inference.WithExpansionAddr("localhost:9000"))

func WithArgs

func WithArgs(args []string) runInferenceOption

WithArgs set arguments for the RunInference transform parameters.

func WithExpansionAddr

func WithExpansionAddr(expansionAddr string) runInferenceOption

WithExpansionAddr provides URL for Python expansion service.

func WithExtraPackages

func WithExtraPackages(extraPackages []string) runInferenceOption

WithExtraPackages is used to specify additional packages when using an automated expansion service. Packages required to run the required Model are included implicitly, eg: scikit-learn, pandas for Sklearn Model Handler.

Types

type PredictionResult

type PredictionResult struct {
	Example   []int64 `beam:"example"`
	Inference int32   `beam:"inference"`
}

PredictionResult represents the result of a prediction obtained from Python's RunInference API.

Source Files

inference.go

Version
v2.66.0 (latest)
Published
Jun 23, 2025
Platform
linux/amd64
Imports
9 packages
Last checked
1 day ago

Tools for package owners.