def convert(model, input_name, output_name):
    """Convert a scikit KNeighborsClassifier to protobuf format.

    Parameters
    ----------
    model : KNeighborsClassifier
        A trained scikit-learn KNeighborsClassifier model.

    input_name: str
        Name of the input column.

    output_name: str
        Name of the output column.

    Returns
    -------
    model_spec: An object of type Model_pb.
        Protobuf representation of the model
    """
    if not (_HAS_SKLEARN):
        raise RuntimeError(
            "scikit-learn not found. scikit-learn conversion API is disabled."
        )

    _sklearn_util.check_expected_type(model, sklearn_class)

    _check_fitted(model)
    _check_algorithm(model)
    _check_weighting_scheme(model)
    _check_distance_metric(model)

    return _MLModel(_convert_k_neighbors_classifier(model, input_name, output_name))
Convert a scikit KNeighborsClassifier to protobuf format.

    Parameters
    ----------
    model : KNeighborsClassifier
        A trained scikit-learn KNeighborsClassifier model.

    input_name: str
        Name of the input column.

    output_name: str
        Name of the output column.

    Returns
    -------
    model_spec: An object of type Model_pb.
        Protobuf representation of the model
    
coremltools/converters/sklearn/_k_neighbors_classifier.py