SeldonClassifier¶
- class SeldonClassifier(api_key=None, *, host=None, dataset_name='dataset', model='seldon-small', strategy=None, memory_optimization=False, preprocess=True, n_groups=None, column_names=None, selected_features=None, timeout_s=900, metadata=None, user=None, api_version=None, default_headers=None)¶
Sklearn-compatible classifier using the Neuralk API.
This classifier connects to either the Neuralk cloud API or an on-premise Seldon server. It follows the standard scikit-learn classifier interface and only accepts classification targets (binary or multiclass).
- Parameters:
api_key (str, optional) – API key for authentication (e.g., “nk_live_xxxx”). Required for cloud mode. If not provided, reads from the
NEURALK_API_KEYenvironment variable. Optional for on-premise mode.host (str, optional) – Base URL of the server. If not provided, uses the Neuralk cloud endpoint. When provided, enables on-premise mode which doesn’t require an API key.
dataset_name (str, default="dataset") – Name identifier for the dataset used in API requests.
model (str, default="seldon-small") – Model identifier to use for inference. Available models: - “seldon-flash”: Fastest model, optimized for low latency - “seldon-small”: Balanced model (default) - “seldon-large”: Most accurate model, recommended for complex tasks
strategy (str, optional) – Prompting strategy for group-wise processing.
memory_optimization (bool, default=False) – Enable server-side memory optimization.
preprocess (bool, default=True) – Enable server-side data preprocessing.
n_groups (int, optional) – Number of groups for the prompting strategy.
column_names (List[str], optional) – Column names corresponding to features in X.
selected_features (List[str], optional) – Features to use for grouping strategies.
timeout_s (int, default=900) – Request timeout in seconds.
metadata (dict, optional) – Optional metadata to include with requests.
user (str, optional) – Optional user identifier for request tracking.
api_version (str, optional) – Optional API version string to send as ‘Nicl-Version’ header.
default_headers (dict, optional) – Optional default headers to include with every request.
Examples
>>> from neuralk import SeldonClassifier >>> clf = SeldonClassifier(api_key="nk_live_xxxx") >>> clf.fit(X_train, y_train) >>> predictions = clf.predict(X_test) >>> probabilities = clf.predict_proba(X_test)