How can I find similarities in two graphs?2019 Community Moderator ElectionNetwork analysis classic datasetsUnion grouping in bipartite graphs?Multi Model data set Visualization PythonKernel on graphs and SVM : a weird interaction.Check similarity of table/csv of Product NamesValueError when doing validation with random forestsVoting patterns similaritiesAppropriate similarity measure that highlights symmetrical values of featuresKeras importing two images of same object for ConvLSTMHaving issues in converting dataframe to Bipartite graph

Can I run a new neutral wire to repair a broken circuit?

What does it mean to describe someone as a butt steak?

How do conventional missiles fly?

Why does ы have a soft sign in it?

numexpr behavior in math mode and/or TikZ

Why doesn't using multiple commands with a || or && conditional work?

What is the most common color to indicate the input-field is disabled?

Why was the shrinking from 8″ made only to 5.25″ and not smaller (4″ or less)?

Is it possible to create a QR code using text?

Gatling : Performance testing tool

Fully-Firstable Anagram Sets

How can saying a song's name be a copyright violation?

What killed these X2 caps?

How can I prevent hyper evolved versions of regular creatures from wiping out their cousins?

I'm going to France and my passport expires June 19th

How much of data wrangling is a data scientist's job?

Is there an expression that means doing something right before you will need it rather than doing it in case you might need it?

Is it possible to download Internet Explorer on my Mac running OS X El Capitan?

One verb to replace 'be a member of' a club

Why do ethics inherently matter?

Why is it a bad idea to hire a hitman to eliminate most corrupt politicians?

If human space travel is limited by the G force vulnerability, is there a way to counter G forces?

Issue with type force PATH search

I would say: "You are another teacher", but she is a woman and I am a man



How can I find similarities in two graphs?



2019 Community Moderator ElectionNetwork analysis classic datasetsUnion grouping in bipartite graphs?Multi Model data set Visualization PythonKernel on graphs and SVM : a weird interaction.Check similarity of table/csv of Product NamesValueError when doing validation with random forestsVoting patterns similaritiesAppropriate similarity measure that highlights symmetrical values of featuresKeras importing two images of same object for ConvLSTMHaving issues in converting dataframe to Bipartite graph










1












$begingroup$


Let's say that I have two 1 dimensional arrays, and when I plot the two arrays they look like this:



enter image description here



If you look at the top and bottom graphs, then you can see that the highlighted parts are very similar (in this case they're exactly the same). I need to find a way to find these sections using some sort of algorithm or method.



I've tried searching everywhere in the numpy and scikit docs, I even searched everywhere on stackexchange and couldn't find a solution for this problem. I don't think anyone published a solution for this yet.



Does anyone have any idea how I can find similar sections in two graphs? My dataset is a 1 dimensional data array for each graph, and I need a algorithm that tells me where the similar parts are. Just remember that the similar sections are never 100% the same, sometimes they're a little bit off and sometimes there's anomalies so a small part would be different but everything else will still look the same. Also you can ignore the curvature of the graph, that's irrelevant. Only the X and Y coordinates of the data points are important.



I can't read explanations that have a lot of maths inside of them and I also can't turn explanations that have a lot of maths into code, I'm still learning how to do that at University. But I'm really good at reading pseudo-code and other programming languages so please give me an answer with real code.










share|improve this question











$endgroup$
















    1












    $begingroup$


    Let's say that I have two 1 dimensional arrays, and when I plot the two arrays they look like this:



    enter image description here



    If you look at the top and bottom graphs, then you can see that the highlighted parts are very similar (in this case they're exactly the same). I need to find a way to find these sections using some sort of algorithm or method.



    I've tried searching everywhere in the numpy and scikit docs, I even searched everywhere on stackexchange and couldn't find a solution for this problem. I don't think anyone published a solution for this yet.



    Does anyone have any idea how I can find similar sections in two graphs? My dataset is a 1 dimensional data array for each graph, and I need a algorithm that tells me where the similar parts are. Just remember that the similar sections are never 100% the same, sometimes they're a little bit off and sometimes there's anomalies so a small part would be different but everything else will still look the same. Also you can ignore the curvature of the graph, that's irrelevant. Only the X and Y coordinates of the data points are important.



    I can't read explanations that have a lot of maths inside of them and I also can't turn explanations that have a lot of maths into code, I'm still learning how to do that at University. But I'm really good at reading pseudo-code and other programming languages so please give me an answer with real code.










    share|improve this question











    $endgroup$














      1












      1








      1


      1



      $begingroup$


      Let's say that I have two 1 dimensional arrays, and when I plot the two arrays they look like this:



      enter image description here



      If you look at the top and bottom graphs, then you can see that the highlighted parts are very similar (in this case they're exactly the same). I need to find a way to find these sections using some sort of algorithm or method.



      I've tried searching everywhere in the numpy and scikit docs, I even searched everywhere on stackexchange and couldn't find a solution for this problem. I don't think anyone published a solution for this yet.



      Does anyone have any idea how I can find similar sections in two graphs? My dataset is a 1 dimensional data array for each graph, and I need a algorithm that tells me where the similar parts are. Just remember that the similar sections are never 100% the same, sometimes they're a little bit off and sometimes there's anomalies so a small part would be different but everything else will still look the same. Also you can ignore the curvature of the graph, that's irrelevant. Only the X and Y coordinates of the data points are important.



      I can't read explanations that have a lot of maths inside of them and I also can't turn explanations that have a lot of maths into code, I'm still learning how to do that at University. But I'm really good at reading pseudo-code and other programming languages so please give me an answer with real code.










      share|improve this question











      $endgroup$




      Let's say that I have two 1 dimensional arrays, and when I plot the two arrays they look like this:



      enter image description here



      If you look at the top and bottom graphs, then you can see that the highlighted parts are very similar (in this case they're exactly the same). I need to find a way to find these sections using some sort of algorithm or method.



      I've tried searching everywhere in the numpy and scikit docs, I even searched everywhere on stackexchange and couldn't find a solution for this problem. I don't think anyone published a solution for this yet.



      Does anyone have any idea how I can find similar sections in two graphs? My dataset is a 1 dimensional data array for each graph, and I need a algorithm that tells me where the similar parts are. Just remember that the similar sections are never 100% the same, sometimes they're a little bit off and sometimes there's anomalies so a small part would be different but everything else will still look the same. Also you can ignore the curvature of the graph, that's irrelevant. Only the X and Y coordinates of the data points are important.



      I can't read explanations that have a lot of maths inside of them and I also can't turn explanations that have a lot of maths into code, I'm still learning how to do that at University. But I'm really good at reading pseudo-code and other programming languages so please give me an answer with real code.







      python scikit-learn similarity graphs numpy






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 24 at 10:17







      user3254198

















      asked Feb 24 at 8:58









      user3254198user3254198

      1062




      1062




















          2 Answers
          2






          active

          oldest

          votes


















          0












          $begingroup$

          Well, you need to first define what your threshold for 'similar' is, and also what length of similarity is meaningful to you.



          One way of achieving this is by taking a 'slice' of the first set of coordinates, and comparing them against each slice of the same size in the second set. If all values are within a certain threshold distance, bingo.



          You can then repeat this with the next slice of coordinates from set #1.



          e.g. here is an O(n2) implementation:



          slice_len = 10
          thresh = 2
          overlap_x1 = []
          overlap_x2 = []

          for i in range(len(x1)-slice_len):
          for j in range(len(x2)-slice_len):
          # checking the y coords are all at most 'threshold' far away
          if max(abs(y1[i:i+slice_len]-y2[j:j+slice_len])) < thresh:
          # Adding the similar x-coords to the containers
          overlap_x1.append(x1[i:i+slice_len])
          overlap_x2.append(x2[i:i+slice_len])

          # Converting arrays to ordered sets to remove duplicates from overlap
          # Since they are x-coords, they are monotonic increasing, order is preserved
          overlap_x1 = OrderedSet(overlap_x1)
          overlap_x2 = OrderedSet(overlap_x2)





          share|improve this answer









          $endgroup$




















            0












            $begingroup$

            This can be solved in simply O(1) complexity using Deep learning technique called oneshot learning. If you are to find the exact match, we are going to set the cosine similarity to 1 and convolve the kernel over the second image and calculate the difference with the first image to find the difference. Read further about one_shot learning here.






            share|improve this answer











            $endgroup$













              Your Answer





              StackExchange.ifUsing("editor", function ()
              return StackExchange.using("mathjaxEditing", function ()
              StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
              StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
              );
              );
              , "mathjax-editing");

              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "557"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: false,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













              draft saved

              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f46128%2fhow-can-i-find-similarities-in-two-graphs%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              0












              $begingroup$

              Well, you need to first define what your threshold for 'similar' is, and also what length of similarity is meaningful to you.



              One way of achieving this is by taking a 'slice' of the first set of coordinates, and comparing them against each slice of the same size in the second set. If all values are within a certain threshold distance, bingo.



              You can then repeat this with the next slice of coordinates from set #1.



              e.g. here is an O(n2) implementation:



              slice_len = 10
              thresh = 2
              overlap_x1 = []
              overlap_x2 = []

              for i in range(len(x1)-slice_len):
              for j in range(len(x2)-slice_len):
              # checking the y coords are all at most 'threshold' far away
              if max(abs(y1[i:i+slice_len]-y2[j:j+slice_len])) < thresh:
              # Adding the similar x-coords to the containers
              overlap_x1.append(x1[i:i+slice_len])
              overlap_x2.append(x2[i:i+slice_len])

              # Converting arrays to ordered sets to remove duplicates from overlap
              # Since they are x-coords, they are monotonic increasing, order is preserved
              overlap_x1 = OrderedSet(overlap_x1)
              overlap_x2 = OrderedSet(overlap_x2)





              share|improve this answer









              $endgroup$

















                0












                $begingroup$

                Well, you need to first define what your threshold for 'similar' is, and also what length of similarity is meaningful to you.



                One way of achieving this is by taking a 'slice' of the first set of coordinates, and comparing them against each slice of the same size in the second set. If all values are within a certain threshold distance, bingo.



                You can then repeat this with the next slice of coordinates from set #1.



                e.g. here is an O(n2) implementation:



                slice_len = 10
                thresh = 2
                overlap_x1 = []
                overlap_x2 = []

                for i in range(len(x1)-slice_len):
                for j in range(len(x2)-slice_len):
                # checking the y coords are all at most 'threshold' far away
                if max(abs(y1[i:i+slice_len]-y2[j:j+slice_len])) < thresh:
                # Adding the similar x-coords to the containers
                overlap_x1.append(x1[i:i+slice_len])
                overlap_x2.append(x2[i:i+slice_len])

                # Converting arrays to ordered sets to remove duplicates from overlap
                # Since they are x-coords, they are monotonic increasing, order is preserved
                overlap_x1 = OrderedSet(overlap_x1)
                overlap_x2 = OrderedSet(overlap_x2)





                share|improve this answer









                $endgroup$















                  0












                  0








                  0





                  $begingroup$

                  Well, you need to first define what your threshold for 'similar' is, and also what length of similarity is meaningful to you.



                  One way of achieving this is by taking a 'slice' of the first set of coordinates, and comparing them against each slice of the same size in the second set. If all values are within a certain threshold distance, bingo.



                  You can then repeat this with the next slice of coordinates from set #1.



                  e.g. here is an O(n2) implementation:



                  slice_len = 10
                  thresh = 2
                  overlap_x1 = []
                  overlap_x2 = []

                  for i in range(len(x1)-slice_len):
                  for j in range(len(x2)-slice_len):
                  # checking the y coords are all at most 'threshold' far away
                  if max(abs(y1[i:i+slice_len]-y2[j:j+slice_len])) < thresh:
                  # Adding the similar x-coords to the containers
                  overlap_x1.append(x1[i:i+slice_len])
                  overlap_x2.append(x2[i:i+slice_len])

                  # Converting arrays to ordered sets to remove duplicates from overlap
                  # Since they are x-coords, they are monotonic increasing, order is preserved
                  overlap_x1 = OrderedSet(overlap_x1)
                  overlap_x2 = OrderedSet(overlap_x2)





                  share|improve this answer









                  $endgroup$



                  Well, you need to first define what your threshold for 'similar' is, and also what length of similarity is meaningful to you.



                  One way of achieving this is by taking a 'slice' of the first set of coordinates, and comparing them against each slice of the same size in the second set. If all values are within a certain threshold distance, bingo.



                  You can then repeat this with the next slice of coordinates from set #1.



                  e.g. here is an O(n2) implementation:



                  slice_len = 10
                  thresh = 2
                  overlap_x1 = []
                  overlap_x2 = []

                  for i in range(len(x1)-slice_len):
                  for j in range(len(x2)-slice_len):
                  # checking the y coords are all at most 'threshold' far away
                  if max(abs(y1[i:i+slice_len]-y2[j:j+slice_len])) < thresh:
                  # Adding the similar x-coords to the containers
                  overlap_x1.append(x1[i:i+slice_len])
                  overlap_x2.append(x2[i:i+slice_len])

                  # Converting arrays to ordered sets to remove duplicates from overlap
                  # Since they are x-coords, they are monotonic increasing, order is preserved
                  overlap_x1 = OrderedSet(overlap_x1)
                  overlap_x2 = OrderedSet(overlap_x2)






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Feb 24 at 13:59









                  ukemiukemi

                  1489




                  1489





















                      0












                      $begingroup$

                      This can be solved in simply O(1) complexity using Deep learning technique called oneshot learning. If you are to find the exact match, we are going to set the cosine similarity to 1 and convolve the kernel over the second image and calculate the difference with the first image to find the difference. Read further about one_shot learning here.






                      share|improve this answer











                      $endgroup$

















                        0












                        $begingroup$

                        This can be solved in simply O(1) complexity using Deep learning technique called oneshot learning. If you are to find the exact match, we are going to set the cosine similarity to 1 and convolve the kernel over the second image and calculate the difference with the first image to find the difference. Read further about one_shot learning here.






                        share|improve this answer











                        $endgroup$















                          0












                          0








                          0





                          $begingroup$

                          This can be solved in simply O(1) complexity using Deep learning technique called oneshot learning. If you are to find the exact match, we are going to set the cosine similarity to 1 and convolve the kernel over the second image and calculate the difference with the first image to find the difference. Read further about one_shot learning here.






                          share|improve this answer











                          $endgroup$



                          This can be solved in simply O(1) complexity using Deep learning technique called oneshot learning. If you are to find the exact match, we are going to set the cosine similarity to 1 and convolve the kernel over the second image and calculate the difference with the first image to find the difference. Read further about one_shot learning here.







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Mar 27 at 13:15

























                          answered Mar 27 at 11:41









                          thanatozthanatoz

                          534319




                          534319



























                              draft saved

                              draft discarded
















































                              Thanks for contributing an answer to Data Science Stack Exchange!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid


                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.

                              Use MathJax to format equations. MathJax reference.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f46128%2fhow-can-i-find-similarities-in-two-graphs%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown