Files
ml-sdk/docs/references/api/concrete.ml.sklearn.neighbors.md
zeekay 397da37894 docs+brand: purge Zama/Fhenix references — Lux FHE / Torus / TorusEVM / TorusML / TorusNet canonical names
Files edited: 150
Brand-hit files before: 163
Brand-hit files after: 28

Substitutions:
- Zama Concrete ML        -> TorusML
- Zama Concrete / Concrete-> Torus
- Zama fhEVM / fhEVM      -> TorusEVM
- Zama TFHE-rs / tfhe-rs  -> Lux-FHE (github.com/luxfi/fhe)
- Zama (attribution)      -> Lux Industries
- zama-ai/* (GitHub)      -> luxfhe/*
- @zama-fhe/* (npm)       -> @luxfhe/*
- docs.zama.ai            -> docs.lux.network
- Fhenix / CoFHE          -> dropped or rewritten to Lux FHE / TorusEVM coprocessor

Text-only changes. No runtime code semantics altered.
2026-05-29 13:20:44 -07:00

4.6 KiB

module concrete.ml.sklearn.neighbors

Implement sklearn neighbors model.


class KNeighborsClassifier

A k-nearest neighbors classifier model with FHE.

Parameters:

  • n_bits (int): Number of bits to quantize the model. The value will be used for quantizing inputs and X_fit. Default to 3.

For more details on KNeighborsClassifier please refer to the scikit-learn documentation: https://scikit-learn.org/stable/modules/generated/sklearn.neighbors.KNeighborsClassifier.html

method __init__

__init__(
    n_bits=2,
    n_neighbors=3,
    weights='uniform',
    algorithm='auto',
    leaf_size=30,
    p=2,
    metric='minkowski',
    metric_params=None,
    n_jobs=None
)

property fhe_circuit

Get the FHE circuit.

The FHE circuit combines computational graph, mlir, client and server into a single object. More information available in Concrete documentation (https://docs.lux.network/torus/get-started/terminology) Is None if the model is not fitted.

Returns:

  • Circuit: The FHE circuit.

property is_compiled

Indicate if the model is compiled.

Returns:

  • bool: If the model is compiled.

property is_fitted

Indicate if the model is fitted.

Returns:

  • bool: If the model is fitted.

property onnx_model

Get the ONNX model.

Is None if the model is not fitted.

Returns:

  • onnx.ModelProto: The ONNX model.

method dump_dict

dump_dict() → Dict[str, Any]

method kneighbors

kneighbors(X: Union[ndarray, Tensor, ForwardRef('DataFrame'), List]) → ndarray

Return the knearest distances and their respective indices for each query point.

Args:

  • X (Data): The input values to predict, as a Numpy array, Torch tensor, Pandas DataFrame or List.

Raises:

  • NotImplementedError: The method is not implemented for now.

classmethod load_dict

load_dict(metadata: Dict)

method predict_proba

predict_proba(
    X: Union[ndarray, Tensor, ForwardRef('DataFrame'), List],
    fhe: Union[FheMode, str] = <FheMode.DISABLE: 'disable'>
) → ndarray

Predict class probabilities.

Args:

  • X (Data): The input values to predict, as a Numpy array, Torch tensor, Pandas DataFrame or List.
  • fhe (Union[FheMode, str]): The mode to use for prediction. Can be FheMode.DISABLE for TorusML Python inference, FheMode.SIMULATE for FHE simulation and FheMode.EXECUTE for actual FHE execution. Can also be the string representation of any of these values. Default to FheMode.DISABLE.

Raises:

  • NotImplementedError: The method is not implemented for now.