Search code examples
data-miningordinals

compare ordinal type in data mining


I have several variables That type of them is ordinal type .

never < rarely < occasionally < often

I would calculate the amount of nearly two variables. Is it possible ؟

For Example 1 : v1 = often v2= often so v1 is completely near v2

For Example 2 : v1 = occasionally & v2 = often

For Example 3 : v1 = rarely & v2 = often

so V1 and v2 values in example 2 ​​are closer together than values in Example 3 .

How can I show degree close of them with a number?


Solution

  • Pseudocode:

    let never = 0, rarely = 1, occasionally = 2, often = 3
    result = absolute_value(v1 - v2)   //where result=0 is the closest and result=3 is the farthest