The distribution called itself torus-ml while shipping a package directory named concrete, so the name a user installs and the name they import disagreed — and most of the tree already said torus.ml, which could not resolve against src/concrete. Moved src/concrete to src/torus and pointed the include at it. The dependency was Zama's concrete-python from their index. It is torus-fhe from ours, which is what luxfhe/torus already ships: that frontend declares torus-fhe and ships a torus/fhe module, so every 'from torus.fhe' in this tree was already naming our compiler and only the dependency lagged. Two distributions share one namespace, which is the shape the upstream this forked from used and the reason the split works: torus-fhe gives torus.fhe, torus-ml gives torus.ml. Swept every other spelling — identifiers, enum members, workflow variables, filenames, notebooks. LICENSE and NOTICE keep the upstream attribution a fork owes; the figures carry the old name in JPEG metadata a text sweep cannot reach.
4.6 KiB
module torus.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 Torus 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 Torus 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.