I’m really excited to write today’s article. Last week, I found a way to use data science, network science to build a tool so that I could more easily learn to play scales as a guitarist. This week, I’ve taken that idea much further, and it is opening up new pathways and opportunities.
My Musical Learning and Struggles
A little bit about me: I have been playing guitar since I was fifteen years old. My family is musical, so I have always been around it, but at age fifteen, I saw a group of high school students playing Creep by Radiohead, and I was immediately enthralled. That means that I have now been playing guitar for 31 years.
Over all of those years, some things were easy for me, and other things seemed out of reach. Chords and rhythm guitar was always easy for me, but I could not memorize scales, so I really struggled to learn lead guitar. Or, I should say, I struggled to hold interest in learning lead guitar. The way that my mind works, if I can’t do something, I lose interest.
But with learning lead guitar, I KNEW that it was not out of reach, because with brute force, I’ve always been able to roughly learn my favorite solos. I knew I could get there with scales, but everything I used to help me learn them would overwhelm me.
Last week, I found something that actually was helpful, and since then, it’s as if it unlocked a new capability in my brain. Literally, what I am about to show you has unlocked new things for me.
And I know why. I cannot memorize names very well. That has always been true. But, if my mind makes a relationship between a name and something I’m familiar with, my mind struggles less. I think my mind is doing that with scales, now that graph and NLP have allowed me to build relationships with concepts I couldn’t before.
So, I am very excited to write this, because:
This is something that is actually helping me. It is making a difference in my life.
I told you that Network Science and Natural Language Processing are useful for learning about things that exist in our lives
This really shows the versatility of both network science and natural language processing. I am using both on scales, which can be used in both text as well as graph format.
Enough. Let’s go!
Creating the Graph
In last week’s article, I used graph to show ONE scale. This week, I have built a graph of scales from a book I am learning from.
You can get today’s code here!
I used a Python dictionary for this:
scales = {}
# all C scales
scales['Ionian'] = 'C D E F G A B C'
scales['Dorian'] = 'C D Eb F G A Bb C'
scales['Phrygian'] = 'C Db Eb F G Ab Bb C'
scales['Lydian'] = 'C D E F# G A B C'
scales['Mixolydian'] = 'C D E F G A Bb C'
scales['Aeolian'] = 'C D Eb F G Ab Bb C'
scales['Locrian'] = 'C Db Eb F Gb Ab Bb C'
scales['Jazz Minor'] = 'C D Eb F G A B C'
scales['Jazz Minor Mode 3'] = 'C D E F# G# A B C'
scales['Jazz Minor Mode 4'] = 'C D E F# G A Bb C'
scales['Jazz Minor Mode 7'] = 'C Db Eb E Gb Ab Bb C'
scales['Harmonic Minor'] = 'C D Eb F G Ab B C'
scales['Harmonic Minor Mode 3'] = 'C D E F G# A B C'
scales['Harmonic Minor Mode 5'] = 'C Db E F G Ab Bb C'
scales['Harmonic Minor Mode 6'] = 'C D# E F# G A B C'
scales['Harmonic Major'] = 'C D E F G Ab B C'
scales['Harmonic Major Mode 4'] = 'C D Eb F# G A B C'
scales['Harmonic Major Mode 5'] = 'C Db E F G A Bb C'
scales['Harmonic Major Mode 6'] = 'C D# E F# G# A B C'
scales['Major Pentatonic'] = 'C D E G A C'
scales['Minor Pentatonic'] = 'C Eb F G Bb C'
scales['Major Blues'] = 'C D Eb E G A C'
scales['Minor Blues'] = 'C Eb F Gb G Bb C'
scales['Blues Scale'] = 'C Eb E F Gb G Bb C'
This dictionary is the foundation for the rest of the analysis.
Scale Similarity (NLP)
Before I even wrote last week’s article, my mind was already pestering me, wanting to know which scales were most similar to which other scales.
It is one thing to memorize everything in a list, top to bottom. My mind does not work like that. Like I said, if I can notice a relationship between something I want to understand and something else I know or want to understand, then things start to make sense to me. I think it’s my mind building out some systems thinking.
So, even originally, I wanted “scale similarity”. I even knew how to do this, as I do a lot with Natural Language Processing. In the scale dictionary, a scale is a Python string. Similarity is not out of reach. I knew I could use NLP for this.
So, I used the scales to create TFIDF vectors, and I used those vectors to capture and visualize scale similarity.
The similarity matrix is easy to understand after you’ve seen one once. I used cosine similarity for this, which returns a matrix of similarities. Look for Phrygian and you will see it TWICE. At the very bottom right, it has a value of 1. This indicates that the Phrygian scale has exact similarity with itself, because of course it does. Values that are close to one show high similarity. Low values are the opposite.
But, this is messy and hard to use for learning. So, I took the most similar scales for each scale and visualized it this way instead, and it can be done for each scale:
That’s very cool. It is obvious which scales are most similar to Aeolian. But guess what. While writing the code, I already forgot which notes are in these scales. So, let’s see.
I used this code (ugly, don’t care):
scales['Aeolian'], scales['Harmonic Minor'], scales['Dorian'], scales['Phrygian']
Which gave me the ability to easily see and compare.
('C D Eb F G Ab Bb C',
'C D Eb F G Ab B C',
'C D Eb F G A Bb C',
'C Db Eb F G Ab Bb C')
Most importantly, this is the point where I picked up my guitar, tried each of the four, and started to actually understand their similarity, how they relate. This understanding is a deeper knowledge than simple memorization. This understanding will make me a better musician.
It’s really fun to explore the similarities and use them for learning.
Scale Graph
I then used the scales dictionary to create a Scale Graph, mapping out how each scale used each note.
Check it out! There is some shape to this! Graph visualizations are always immediately illuminating to me. Things just jump right out:
Fewer scales are using Gb, Db, Ab, G#, F#, and D#. They jump off the side of the visualization, because they have fewer connections.
The C note has highest page rank (highest importance) across all notes, which makes perfect sense as I used C scales. Every scale used the note C.
You can kind of see which scales have similarity even by graph positioning.
Don’t just listen to me. What stands out to you. Look closer. Develop your systems thinking abilities, and build confidence analyzing graphs visually.
But, I know that this can be visualized in a way that only shows the scales, or only shows the notes. I can use Bipartite Projection for this. You only need to do things a little bit differently to use Bipartite Projection, and it can make a world of difference and unlock new perspectives.
B = nx.from_pandas_edgelist(edgelist_df, source='scale', target='note') # new approach
G = bipartite.projected_graph(B, edgelist_df['note'])
I’ll walk you through this:
The edgelist is a bipartite edgelist, containing of scales and the notes belonging to them. The edgelist contains two types of things, scales and notes. It makes sense to create a bipartite graph for this.
If I don’t do the second step, B looks like the graph above. Scroll up. The graph has a mix of scales and notes.
The second line takes this bipartite graph (B) and projects it into a new graph that only shows notes.
This is what G now looks like:
Look at that. All notes, no scales. Clean.
This is enough to have fun with. It doesn’t matter if you are a guitarist, bassist, pianist, whatever. You can experiment with different progressions by going from one note to any other note that it is connected to. If you are a guitarist, practice power chords, and then try out minor chords. Experiment. That’s the point.
The Page Rank of notes is also very interesting.
You can see which notes are most “central” in the note graph. C and E have a lot of importance across ALL scales, in the key of C.
Note Ego Graphs
The note ego graphs are also interesting to explore. For instance, here is the ego graph for note E:
Here are it’s top ten notes by Page Rank:
And for direct comparison, here is the ego graph for Eb:
And it’s high Page Rank notes:
Oh my goodness, what have I done?
Oh my goodness, what have I done? I have taken a topic that has always been out of reach for me and made it accessible and fun. Because I was stuck for so long, my mind, without my permission, decided that scales are BORING. Now, scales are interesting to me. I can learn more about them in a way that works for me.
I showed this to a friend of mine last week and she kept saying, “I wish I had something like this when I was learning to play Piano as a kid.” I can relate. So many topics are taught via brute force and memorization, and they become so frustrating for those of us who struggle with memorization. We learn how we learn.
And this is actually helping me, as well. Playing guitar is a real world thing that I do. I have used a combination of Natural Language Processing and Network Science to learn more about the world around me.
That’s why I wrote my book. My book is a combination of Natural Language Processing and Network Science. I describe how that is a powerful combination because:
NLP gives you the what. What is being said. What is the sentiment. What note is being played. What scales are similar, textually.
Graphs give you the relationships and their importance. NLP does not give you this. Network Science gives you this.
Other Cool Excitement
I want to give a call-out to a few LinkedIn connections.
If you want to learn about ontology and ontology networks, you need to follow Jérémy Ravenel on LinkedIn. He posts some of the most interesting stuff that I see in my feed, day after day. He is very active and his posts are very interesting.
Yuki Kakegawa recently wrote a book called Polars Cookbook, that really explains the Polars library very well. I am beginning to read it, and finding it very useful. You can read my first impression, here. You can get his book here.
I am experimenting with converting some of my Pandas code to Polars, to see what parts of graph analysis I can speed up. I’ll occasionally use Polars with #100daysofnetworks. It’s a good chance for me to learn Polars, by simply translating a working notebook into another working notebook that uses Polars instead of Pandas. This will help me see what works well, and what doesn’t.
Also, wow, there’s been a lot of excitement on LinkedIn about my use of graphs to explore music. I have to say, I am really enjoying this, and it’s nice to be playing with a kind of graph (notes, scales) that I have never used before. It’s fun to try new things. This just shows the versatility of Network Science, Natural Language Processing, and Data Science in general.
Finally, obligatory AI art.
Gotta have that scowl! The audience is cracking me up, too. Nice.
What’s Next
I’m going to continue with this kind of music + graph stuff for a while. I would really like to come up with something useful for learning scales. This blog isn’t just for teaching, it is for experimentation and learning.
That’s All for Today
Thanks for reading. I’m glad I was able to find something that would be fun to develop and write about. I’m excited to explore graphs musically. This is a cool topic.
Thanks to everyone who has been following along with this series. Happy learning! If you would like to learn more about networks and network analysis, please buy a copy of my book!
I enjoyed the read. I actually understood what you were talking about.
Thank you
Over the past three years I have bought the book and given it to a dozen people.