Skip to content

generic_tree, ValueError: Expected n_neighbors <= n_samples, but n_samples = 1, n_neighbors = 100 #8

@rseholland

Description

@rseholland

Hi @mattbv and @philwilkes ,

I'm getting the following error when trying to use generic_tree on some of my point clouds:

File "test_GT.py", line 19, in
tree_classified = generic_tree(tree_np)
File "/data/store05/students/masters/2021/data/ucfars4/tlseparation/tlseparation/scripts/automated_separation.py", line 669, in generic_tree
voxel_size * 1.77, False)
File "/data/store05/students/masters/2021/data/ucfars4/tlseparation/tlseparation/classification/path_detection.py", line 175, in voxel_path_detection
nbrs_threshold, verbose=verbose)
File "/data/store05/students/masters/2021/data/ucfars4/tlseparation/tlseparation/classification/path_detection.py", line 242, in detect_main_pathways
G = array_to_graph(point_cloud, base_id, 3, knn, nbrs_threshold, 0.02)
File "/data/store05/students/masters/2021/data/ucfars4/tlseparation/tlseparation/utility/shortpath.py", line 85, in array_to_graph
distances, indices = nbrs.kneighbors(arr)
File "/home/ucfaptv/opt/miniconda/envs/tlsep2/lib/python2.7/site-packages/sklearn/neighbors/base.py", line 347, in kneighbors
(train_size, n_neighbors)
ValueError: Expected n_neighbors <= n_samples, but n_samples = 1, n_neighbors = 100 .

I have checked to see if the point cloud has any rogue points far away from the tree but that didn't fix it. Some point clouds work and some don't but can't see any obvious difference between the ones that do and the ones that don't.

I'm using .ply files (ASCII format) then converting to a numpy, my code is as follows:

path = 'leaf-on/H_T24.ply'
tree = read_ply(path)
tree_np = tree.values
tree_classified = generic_tree(tree_np)
tree_leafoff = pd.DataFrame(tree_classified[0], columns = ['x','y','z'])
write_ply('leaf-off/H_T24.ply', tree_leafoff)

Any help would be greatly appreciated,

Ross

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions