Is it appropriate to use the point order produced by np.where() as input for an SVM baseline? #34684
Replies: 1 comment
|
The main issue is the representation, not the SVM.
For an ordered-curve representation, trace the skeleton itself: build 8-neighbour pixel adjacency, start at a degree-1 endpoint for an open curve, and walk neighbours in order. A closed curve has no degree-1 endpoint, so choose a deterministic start point and direction. If the classifier should ignore start point and direction, canonicalize the sequence or augment with rotations/reversal. For a point-set baseline, do not construct a One caution: βopen versus closedβ is directly encoded by endpoint count after skeletonization. If the intended experiment is few-shot shape generalization, report that simple topological baseline too; otherwise a more complex model may appear to learn geometry when it is mostly recovering endpoints. |
Uh oh!
There was an error while loading. Please reload this page.
Is it appropriate to use the point order produced by
np.where()as input for an SVM baseline?γSVM.pyI am conducting a few-shot learning experiment to classify open curves and closed curves.
I am using an SVM as a baseline, but I would like to ask whether my input representation and the ordering of the points are appropriate.
Experimental setup
Current SVM pipeline
In my code, I first generate the curves as raster images.
I then extract the coordinates of the pixels belonging to the curve using:
These coordinates are then passed to
LineString:and the resulting line is resampled based on its length.
Conceptually, the pipeline is:
The issue is the ordering of the coordinates returned by
np.where().The order is determined by the raster image traversal order, rather than by actually following the curve from one point to the next.
Therefore, the sequence
may contain an artificial ordering introduced by the preprocessing step, rather than information that is intrinsic to the geometry of the curve.
Difference from CNNs
This also raises a question about the difference between this representation and the input representation used by CNNs.
With a CNN, the usual pipeline is:
The 2D spatial arrangement of the pixels is directly used as input. In this case, the spatial arrangement is part of the image structure, so we would not normally randomly shuffle the pixels before feeding the image to the CNN.
In my SVM experiment, however, I use:
Therefore, I am wondering whether the spatial arrangement used by a CNN and the ordering of coordinates produced by
np.where()should be considered fundamentally different types of information.Experiment with shuffled points
To investigate whether the SVM depends on the point ordering produced by
np.where(), I also performed an experiment in which I randomly shuffled the points before giving them to the SVM:The classification performance changed substantially when the points were shuffled.
This makes me suspect that the SVM may be relying on the ordering of the points produced by
np.where(), rather than learning the geometric distinction between open and closed curves.Questions
I would like to ask the following:
Is it appropriate, for an SVM baseline, to use the coordinate order produced by
np.where()directly as the input sequence forLineStringand subsequent resampling?If the ordering is simply a consequence of the raster image traversal order, would allowing the SVM to use this ordering as a feature be considered a problematic experimental design?
Is using
shuffle_points=Truean appropriate diagnostic experiment for testing whether the model depends on this artificial ordering?In a CNN, the spatial arrangement of pixels is directly part of the input representation. In my SVM pipeline, however, I convert the raster image into a sequence of 2D coordinates. Is it correct to treat these two types of ordering information differently?
If my goal is to evaluate whether a model can learn the geometric concept of open vs. closed curves under few-shot conditions, should the input to the SVM instead be represented as an order-invariant 2D point set, rather than using the ordering introduced by
np.where()?I am particularly interested in whether this is a problem with the SVM itself, or whether the main issue is the vector representation and preprocessing before the data are given to the SVM.
numpy==2.0.2
opencv-python==4.10.0
scipy==1.14.1
scikit-learn==1.6.1
matplotlib
networkx
shapely
Score : train 12 : test 10000
Accuracy : 0.8836
Precision : 0.9339
Recall : 0.8506
F1-score : 0.8903
All reactions