-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
default score function treats objects as ordered #108
Comments
This is something that bit me as well. The way I got around this is to use the One thing that we could do is look at the type, as well as the size where necessary, of the support elements to decide if paying that computation cost will be worth it. Clearly there are cases where this is unavoidable; the only issue is minimizing the impact where it isn't necessary. Actually, the |
Here's a workaround that can be used in some cases until we have a more general solution: var toPairs = function(obj){
return _.sortBy(_.pairs(obj));
}
var toObject = function(pairs){
return _.object(pairs);
}
var makeObjectScorer = function(erp) {
var newERP = Enumerate(function(){
return toPairs(erp.sample());
});
return function(value) {
return newERP.score([], toPairs(value));
}
}
// Example:
var myERP = Enumerate(function(){
return uniformDraw(
[{'a' : 1, 'b' : 2},
{'b' : 2, 'a' : 1}]
);
});
var myScoreObject = makeObjectScorer(myERP);
print(Math.exp(myERP.score([], {'a' : 1, 'b' : 2}))); // .5 - wrong
print(Math.exp(myScoreObject({'a' : 1, 'b' : 2}))); // 1 - right |
Just wanted to bump this as an issue. Here is my minimal example:
|
Suppose you use Enumerate to create an erp with objects in its support:
When you try to look up the score of
{'b' : 1, 'a' : 2}
, which is equivalent to{'a' : 2, 'b' : 1}
, the score function treats the object as ordered. Thus, the following returns null when it should return -0.69This happens because we use
json.stringify()
to look up the value inmakeMarginalERP()
instead of something that will properly match objects.The text was updated successfully, but these errors were encountered: