def _is_valid_sparse_format(obj):
    """Check if the object is in CSR sparse format (the only valid type for KNeighborsClassifier)"""
    if not _HAS_SCIPY:
        return False
    return isinstance(obj, sp.sparse.csr_matrix)
Check if the object is in CSR sparse format (the only valid type for KNeighborsClassifier)
coremltools/converters/sklearn/_k_neighbors_classifier.py