29 lines
938 B
JavaScript
29 lines
938 B
JavaScript
/**
|
|
* Calculate the distances by using the numbers, strings and dates.
|
|
* @param {node} source
|
|
* @param {node} target
|
|
* @param {array} properties - the properties of the nodes.
|
|
* @return {number} the distance between source and target nodes.
|
|
*/
|
|
function calculateJaccardDissimilarity (source, target, properties, normArgs) {
|
|
var notShared = 0.0;
|
|
|
|
// console.log(properties);
|
|
// Iterate through every column of data
|
|
for (var i = 0; i < properties.length; i++) {
|
|
property = properties[i];
|
|
if (property.toLowerCase() !== 'class' && property.toLowerCase() !== 'app' && property.toLowerCase() !== 'user' && property.toLowerCase() !== 'weekday') {
|
|
var s = source[property],
|
|
t = target[property];
|
|
|
|
if (s !== t) {
|
|
notShared++;
|
|
}
|
|
}
|
|
}
|
|
|
|
// console.log(Math.sqrt(sumDiff)/cols);
|
|
// console.log(cols);
|
|
return notShared / properties.length;
|
|
}
|