concrete.ml.sklearn.neighbors
Implement sklearn linear model.
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
__init__
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.zama.ai/concrete/getting-started/terminology_and_structure) 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.
dump_dict
load_dict
predict_proba
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 Concrete ML 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.