Create compatibility feature
This commit is contained in:
parent
850274efdf
commit
1402d60100
@ -193,6 +193,9 @@ function computeRecordGeo(records, context) {
|
||||
}
|
||||
|
||||
function computeRecordPopularity(records, context, callback) {
|
||||
var scoreMin = 0;
|
||||
var scoreMax = 0;
|
||||
|
||||
async.each(
|
||||
records,
|
||||
function(record, callback) {
|
||||
@ -213,12 +216,18 @@ function computeRecordPopularity(records, context, callback) {
|
||||
});
|
||||
|
||||
var groupScore = innerProduct(context.profile, reviewFeatures);
|
||||
scoreMin = Math.min(scoreMin, groupScore);
|
||||
scoreMax = Math.max(scoreMax, groupScore);
|
||||
|
||||
callback(err, groupScore);
|
||||
}
|
||||
);
|
||||
},
|
||||
function(err, groupScores) {
|
||||
record.groupScores = groupScores;
|
||||
var scoreSum = _.reduce(groupScores, function(a, b) { return a + b; });
|
||||
var scoreAvg = scoreSum / groupScores.length;
|
||||
|
||||
record.features.compatibility = (scoreAvg - scoreMin) / (scoreMax - scoreMin);
|
||||
callback(err);
|
||||
}
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user