我应该如何处理音乐键(比例)作为KNN算法中的功能
我正在进行数据科学项目,我想知道如何将音乐键(比例)作为KNN算法中的功能处理。 我知道KNN是基于距离的,因此给出每个钥匙一个像1-24这样的数字没有太大的意义(因为密钥编号24接近1接近7接近8的1)。 我考虑过为“大专业/次要”制作一列,而另一列本身则是 但是我仍然面临着同样的问题,我需要用一个数字指定注释,但是由于注释是循环的,所以我不能以线性为1-12。
对于那些不知道音乐钥匙如何工作的人,我的问题等同于在KNN中的处理状态,您不能仅以线性1-50来编号。
I'm doing a data science project, and I was wondering how to handle a music key (scale) as a feature in the KNN algorithm.
I know KNN is based on distances, therefore giving each key a number like 1-24 doesn't make that much sense (because key number 24 is close to 1 as much as 7 close to 8).
I have thought about making a column for "Major/Minor" and another for the note itself,
but I'm still facing the same problem, I need to specify the note with a number, but because notes are cyclic I cannot number them linearly 1-12.
For the people that have no idea how music keys work my question is equivalent to handling states in KNN, you can't just number them linearly 1-50.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以考虑量表之间的距离的一种方法是将每个量表视为一个12元素的二进制向量,其中有1个音符在刻度中的位置,否则为零。
然后,您可以计算秤之间的锤距。例如,大规模及其相对次要尺度之间的锤子距离应为零,因为它们都包含相同的音符。
这是您可以在Python中进行设置的方法
One way you could think about the distance between scales is to think of each scale as a 12-element binary vector where there's a 1 wherever a note is in the scale and a zero otherwise.
Then you can compute the Hamming distance between scales. The Hamming distance, for example, between a major scale and its relative minor scale should be zero because they both contain the same notes.
Here's a way you could set this up in Python
iiuc,您可以将功能转换为
sin
,如下所示。听说我有10个值1-10,我正在改变它们以保持它们的循环关系。输出:
通过此功能工程,您可以看到功能的圆形性已编码。 0等于10。
IIUC, you can convert your features to something like
sin
as follows. Hear I have 10 values 1-10 and I am transforming them to keep their circular relation.Output:
Through this feature engineering you can see that the circularity of your feature is encoded. The value of 0 is equal to 10.