def get_input_dimension(model):
    """Get the input dimension for the model"""
    _check_fitted(model)
    number_of_dimensions = 0
    if _is_algorithm_brute(model):
        number_of_dimensions = model._fit_X.shape[1]
    elif _is_algorithm_kd_tree(model):
        npdata = np.asarray(model._tree.data)
        number_of_dimensions = len(npdata[0])
    else:
        raise TypeError(
            "KNeighbors algorithm not supported for CoreML conversion: {}".format(
                model.algorithm
            )
        )
    return number_of_dimensions
Get the input dimension for the model
coremltools/converters/sklearn/_k_neighbors_classifier.py