I am trying classify an input graph (a 2D point sequence) into one of the predefined graphs (A,B,C etc) using machine learning. The goal is to identify which type of graph the input graph belongs to.


I have done classification of single data points before, but I have never classified sequences of data like graphs before. The only way I could think of is calculating 'mean squared error' between input & each of A,B,C graphs and choose the category with the lowest error.

3 example outputs might look like this.

input graph belongs to type A (confidence: 82%)
input graph belongs to type C (confidence: 68%)
input graph doesn't belong to any type (max confidence: 12%)

How can I achieve this using classification techniques or any other accurate way?


1 Answer 1


The wording of your question makes it seems as if you only want to answer the question is the current graph to a specific graph A,B or C. If this is the case, machine learning might not be the best approach and in fact I would say your MSE based approach is probably a good starting place. If this is the case You may want to calculate the performance of this approach and see if it meets your needs. If you have a bunch of examples of graphs that are class A,B, and C then machine learning a probably good approach.

If you have a bunch of examples of each class then you'll first need to calculate a set of features on each graph before you can apply machine learning techniques. After calculating the value of each feature on the graph you'll have a feature vector. From this point, the classification problem should be the same as the "single" data point problems you've already encountered.

Example features:

  • Min or max x or y value
  • The average slope of the series
  • Path length of the series
  • Maximum curvature of the series
  • Coefficients from a polynomial fit

The tsfresh package will calculate a bunch of features for time series and help you sort out the relevant ones so its probably a good place to start.

Good luck!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.