You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@mahout.apache.org by Matt Mitchell <go...@gmail.com> on 2012/07/07 00:28:34 UTC
error when evaluating recommender w/boolean prefs
Hi,
I have a recommender, with a boolean prefs model. I am following the
instructions in the MIA book, but only get this exception:
Illegal precision: NaN
[Thrown class java.lang.IllegalArgumentException]
Restarts:
0: [QUIT] Quit to the SLIME top level
Backtrace:
0: com.google.common.base.Preconditions.checkArgument(Preconditions.java:88)
1: org.apache.mahout.cf.taste.impl.eval.IRStatisticsImpl.<init>(IRStatisticsImpl.java:35)
2: org.apache.mahout.cf.taste.impl.eval.GenericRecommenderIRStatsEvaluator.evaluate(GenericRecommenderIRStatsEvaluator.java:212)
The code is written in Clojure, I hope that's OK:
(let [model (GenericBooleanPrefDataModel.
(GenericBooleanPrefDataModel/toDataMap
(FileDataModel. (File. "resources/test.data"))))
evaluator (GenericRecommenderIRStatsEvaluator.)
rbuilder (reify RecommenderBuilder
(buildRecommender [this model]
(let [sim (LogLikelihoodSimilarity. model)
nhood (NearestNUserNeighborhood. 10 sim model)]
(GenericBooleanPrefUserBasedRecommender. model
nhood sim))))
mbuilder (reify DataModelBuilder
(buildDataModel [this training-data]
(GenericBooleanPrefDataModel.
(GenericBooleanPrefDataModel/toDataMap training-data))))]
(.evaluate evaluator rbuilder mbuilder model nil 10
GenericRecommenderIRStatsEvaluator/CHOOSE_THRESHOLD
1.0))
My test data file is very simple (for now):
1,1
1,2
1,3
2,1
2,10
2,100
2,20
3,9
3,10
3,20
3,1
4,10
4,15
4,1
Any idea what I might be doing wrong?
Thanks in advance,
- Matt
Re: error when evaluating recommender w/boolean prefs
Posted by Matt Mitchell <go...@gmail.com>.
I got it! The problem was my clojure code. I was not using the model
argument passed into in my builder method, instead I was referencing a
local, model var outside the method -- state problem. All working
great now. Very interesting results too... sure to keep me busy for a
while!
On Sun, Jul 15, 2012 at 11:52 AM, Sean Owen <sr...@gmail.com> wrote:
> Duplicates are handled by over-writing. There's not a way to represent
> two states of a user-item association simultaneously.
> It could be an issue only if you made your own data splitter that
> didn't properly put stuff in one bucket or the other, but I don't know
> that this is the issue here.
>
> You might just run through the debugger and see just why it's 0. Is it
> really predicting with perfect accuracy every time? how many times?
> what data points... may give a clue quickly about the issue.
>
> On Sun, Jul 15, 2012 at 4:23 PM, Matt Mitchell <go...@gmail.com> wrote:
>> OK hmm, is it possible this could happen from duplicate
>> user/pref/score values in my data? How does Mahout handle duplicate
>> entries in data, whether in a load-once file or coming from a refresh?
>>
>> On Sun, Jul 15, 2012 at 4:01 AM, Sean Owen <sr...@gmail.com> wrote:
>>> This sounds like a target leak, like your test data is actually
>>> getting copied into the training data.
>>>
>>> On Sun, Jul 15, 2012 at 1:08 AM, Matt Mitchell <go...@gmail.com> wrote:
>>>> One strange thing, and I'm going to dig through the MIA book tonight,
>>>> is that my user based recommendation evaluator returns 0.0 no matter
>>>> what I do. It's setup using PearsonCorrelationSimilarity,
>>>> NearestNUserNeighborhood(2), GenericUserBasedRecommender and the
>>>> AverageAbsoluteDifferenceRecommenderEvaluator. Also, my prefs do have
>>>> values, a range from 1 to 3.
Re: error when evaluating recommender w/boolean prefs
Posted by Sean Owen <sr...@gmail.com>.
Duplicates are handled by over-writing. There's not a way to represent
two states of a user-item association simultaneously.
It could be an issue only if you made your own data splitter that
didn't properly put stuff in one bucket or the other, but I don't know
that this is the issue here.
You might just run through the debugger and see just why it's 0. Is it
really predicting with perfect accuracy every time? how many times?
what data points... may give a clue quickly about the issue.
On Sun, Jul 15, 2012 at 4:23 PM, Matt Mitchell <go...@gmail.com> wrote:
> OK hmm, is it possible this could happen from duplicate
> user/pref/score values in my data? How does Mahout handle duplicate
> entries in data, whether in a load-once file or coming from a refresh?
>
> On Sun, Jul 15, 2012 at 4:01 AM, Sean Owen <sr...@gmail.com> wrote:
>> This sounds like a target leak, like your test data is actually
>> getting copied into the training data.
>>
>> On Sun, Jul 15, 2012 at 1:08 AM, Matt Mitchell <go...@gmail.com> wrote:
>>> One strange thing, and I'm going to dig through the MIA book tonight,
>>> is that my user based recommendation evaluator returns 0.0 no matter
>>> what I do. It's setup using PearsonCorrelationSimilarity,
>>> NearestNUserNeighborhood(2), GenericUserBasedRecommender and the
>>> AverageAbsoluteDifferenceRecommenderEvaluator. Also, my prefs do have
>>> values, a range from 1 to 3.
Re: error when evaluating recommender w/boolean prefs
Posted by Matt Mitchell <go...@gmail.com>.
OK hmm, is it possible this could happen from duplicate
user/pref/score values in my data? How does Mahout handle duplicate
entries in data, whether in a load-once file or coming from a refresh?
On Sun, Jul 15, 2012 at 4:01 AM, Sean Owen <sr...@gmail.com> wrote:
> This sounds like a target leak, like your test data is actually
> getting copied into the training data.
>
> On Sun, Jul 15, 2012 at 1:08 AM, Matt Mitchell <go...@gmail.com> wrote:
>> One strange thing, and I'm going to dig through the MIA book tonight,
>> is that my user based recommendation evaluator returns 0.0 no matter
>> what I do. It's setup using PearsonCorrelationSimilarity,
>> NearestNUserNeighborhood(2), GenericUserBasedRecommender and the
>> AverageAbsoluteDifferenceRecommenderEvaluator. Also, my prefs do have
>> values, a range from 1 to 3.
Re: error when evaluating recommender w/boolean prefs
Posted by Sean Owen <sr...@gmail.com>.
This sounds like a target leak, like your test data is actually
getting copied into the training data.
On Sun, Jul 15, 2012 at 1:08 AM, Matt Mitchell <go...@gmail.com> wrote:
> One strange thing, and I'm going to dig through the MIA book tonight,
> is that my user based recommendation evaluator returns 0.0 no matter
> what I do. It's setup using PearsonCorrelationSimilarity,
> NearestNUserNeighborhood(2), GenericUserBasedRecommender and the
> AverageAbsoluteDifferenceRecommenderEvaluator. Also, my prefs do have
> values, a range from 1 to 3.
Re: error when evaluating recommender w/boolean prefs
Posted by Matt Mitchell <go...@gmail.com>.
Thanks Sean, your suggestions worked! I'm now getting results back
from the evaluator. I also tweaked the JVM settings and things are
running quicker.
One strange thing, and I'm going to dig through the MIA book tonight,
is that my user based recommendation evaluator returns 0.0 no matter
what I do. It's setup using PearsonCorrelationSimilarity,
NearestNUserNeighborhood(2), GenericUserBasedRecommender and the
AverageAbsoluteDifferenceRecommenderEvaluator. Also, my prefs do have
values, a range from 1 to 3.
- Matt
On Sat, Jul 14, 2012 at 11:21 AM, Sean Owen <sr...@gmail.com> wrote:
> Ah yes I see that now.
>
> Try increasing evaluation percentage to 1.0. At the moment you're only
> using 10% of the data. That's a quick way to make a bigger test!
>
> Also, what happens if you set the threshold to 0.5?
>
> On Sat, Jul 14, 2012 at 4:56 PM, Matt Mitchell <go...@gmail.com> wrote:
>> Hey Sean, are you talking about using
>> GenericRecommenderIRStatsEvaluator/CHOOSE_THRESHOLD? I am already
>> using that. I have however bumped up the training size, maybe this
>> will help.
>>
Re: error when evaluating recommender w/boolean prefs
Posted by Sean Owen <sr...@gmail.com>.
Ah yes I see that now.
Try increasing evaluation percentage to 1.0. At the moment you're only
using 10% of the data. That's a quick way to make a bigger test!
Also, what happens if you set the threshold to 0.5?
On Sat, Jul 14, 2012 at 4:56 PM, Matt Mitchell <go...@gmail.com> wrote:
> Hey Sean, are you talking about using
> GenericRecommenderIRStatsEvaluator/CHOOSE_THRESHOLD? I am already
> using that. I have however bumped up the training size, maybe this
> will help.
>
Re: error when evaluating recommender w/boolean prefs
Posted by Matt Mitchell <go...@gmail.com>.
Hey Sean, are you talking about using
GenericRecommenderIRStatsEvaluator/CHOOSE_THRESHOLD? I am already
using that. I have however bumped up the training size, maybe this
will help.
- Matt
On Sat, Jul 14, 2012 at 3:13 AM, Sean Owen <sr...@gmail.com> wrote:
> It still means the same thing. 220K lines may still be too sparse to
> get results. Also try removing your threshold and let it pick.
>
> On Sat, Jul 14, 2012 at 3:24 AM, Matt Mitchell <go...@gmail.com> wrote:
>> Hmm, still happening. I have a 220k line file with user, item and pref
>> value. I am still getting the NaN error when evaluating. I'm not sure
>> what to do. It also takes a long time for this error to popup, around
>> 1 hour. I hate to throw code out like this, but maybe it'll be help
>> someone... help me. Is it related to the evaluator settings?
>>
>> - Matt
>>
>> (def prefs-file "data.txt")
>> (org.apache.mahout.common.RandomUtils/useTestSeed)
>> (let [model (FileDataModel. (File. prefs-file))
>> evaluator (GenericRecommenderIRStatsEvaluator.)
>> rbuilder (reify RecommenderBuilder
>> (buildRecommender [this model]
>> (let [sim (LogLikelihoodSimilarity. model)]
>> (GenericBooleanPrefItemBasedRecommender. model sim))))
>> mbuilder (reify DataModelBuilder
>> (buildDataModel [this training-data]
>> (GenericBooleanPrefDataModel.
>> (GenericBooleanPrefDataModel/toDataMap training-data))))]
>> (prn (.evaluate evaluator rbuilder mbuilder model nil 10
>> GenericRecommenderIRStatsEvaluator/CHOOSE_THRESHOLD
>> 0.01)))
>>
>>
>> On Sat, Jul 7, 2012 at 11:20 AM, Matt Mitchell <go...@gmail.com> wrote:
>>> Thanks Sean, you're absolutely right. Things are working nicely now.
>>>
>>> - Matt
>>>
>>> On Sat, Jul 7, 2012 at 3:48 AM, Sean Owen <sr...@gmail.com> wrote:
>>>> What it really means is that there is not enough data to make a
>>>> meaningful test here.
>>>>
>>>> On Sat, Jul 7, 2012 at 1:28 AM, Matt Mitchell <go...@gmail.com> wrote:
>>>>> Hi,
>>>>>
>>>>> I have a recommender, with a boolean prefs model. I am following the
>>>>> instructions in the MIA book, but only get this exception:
>>>>>
>>>>> Illegal precision: NaN
>>>>> [Thrown class java.lang.IllegalArgumentException]
>>>>>
>>>>> Restarts:
>>>>> 0: [QUIT] Quit to the SLIME top level
>>>>>
>>>>> Backtrace:
>>>>> 0: com.google.common.base.Preconditions.checkArgument(Preconditions.java:88)
>>>>> 1: org.apache.mahout.cf.taste.impl.eval.IRStatisticsImpl.<init>(IRStatisticsImpl.java:35)
>>>>> 2: org.apache.mahout.cf.taste.impl.eval.GenericRecommenderIRStatsEvaluator.evaluate(GenericRecommenderIRStatsEvaluator.java:212)
>>>>>
>>>>> The code is written in Clojure, I hope that's OK:
>>>>>
>>>>> (let [model (GenericBooleanPrefDataModel.
>>>>> (GenericBooleanPrefDataModel/toDataMap
>>>>> (FileDataModel. (File. "resources/test.data"))))
>>>>> evaluator (GenericRecommenderIRStatsEvaluator.)
>>>>> rbuilder (reify RecommenderBuilder
>>>>> (buildRecommender [this model]
>>>>> (let [sim (LogLikelihoodSimilarity. model)
>>>>> nhood (NearestNUserNeighborhood. 10 sim model)]
>>>>> (GenericBooleanPrefUserBasedRecommender. model
>>>>> nhood sim))))
>>>>> mbuilder (reify DataModelBuilder
>>>>> (buildDataModel [this training-data]
>>>>> (GenericBooleanPrefDataModel.
>>>>> (GenericBooleanPrefDataModel/toDataMap training-data))))]
>>>>> (.evaluate evaluator rbuilder mbuilder model nil 10
>>>>> GenericRecommenderIRStatsEvaluator/CHOOSE_THRESHOLD
>>>>> 1.0))
>>>>>
>>>>> My test data file is very simple (for now):
>>>>>
>>>>> 1,1
>>>>> 1,2
>>>>> 1,3
>>>>>
>>>>> 2,1
>>>>> 2,10
>>>>> 2,100
>>>>> 2,20
>>>>>
>>>>> 3,9
>>>>> 3,10
>>>>> 3,20
>>>>> 3,1
>>>>>
>>>>> 4,10
>>>>> 4,15
>>>>> 4,1
>>>>>
>>>>> Any idea what I might be doing wrong?
>>>>>
>>>>> Thanks in advance,
>>>>>
>>>>> - Matt
Re: error when evaluating recommender w/boolean prefs
Posted by Sean Owen <sr...@gmail.com>.
It still means the same thing. 220K lines may still be too sparse to
get results. Also try removing your threshold and let it pick.
On Sat, Jul 14, 2012 at 3:24 AM, Matt Mitchell <go...@gmail.com> wrote:
> Hmm, still happening. I have a 220k line file with user, item and pref
> value. I am still getting the NaN error when evaluating. I'm not sure
> what to do. It also takes a long time for this error to popup, around
> 1 hour. I hate to throw code out like this, but maybe it'll be help
> someone... help me. Is it related to the evaluator settings?
>
> - Matt
>
> (def prefs-file "data.txt")
> (org.apache.mahout.common.RandomUtils/useTestSeed)
> (let [model (FileDataModel. (File. prefs-file))
> evaluator (GenericRecommenderIRStatsEvaluator.)
> rbuilder (reify RecommenderBuilder
> (buildRecommender [this model]
> (let [sim (LogLikelihoodSimilarity. model)]
> (GenericBooleanPrefItemBasedRecommender. model sim))))
> mbuilder (reify DataModelBuilder
> (buildDataModel [this training-data]
> (GenericBooleanPrefDataModel.
> (GenericBooleanPrefDataModel/toDataMap training-data))))]
> (prn (.evaluate evaluator rbuilder mbuilder model nil 10
> GenericRecommenderIRStatsEvaluator/CHOOSE_THRESHOLD
> 0.01)))
>
>
> On Sat, Jul 7, 2012 at 11:20 AM, Matt Mitchell <go...@gmail.com> wrote:
>> Thanks Sean, you're absolutely right. Things are working nicely now.
>>
>> - Matt
>>
>> On Sat, Jul 7, 2012 at 3:48 AM, Sean Owen <sr...@gmail.com> wrote:
>>> What it really means is that there is not enough data to make a
>>> meaningful test here.
>>>
>>> On Sat, Jul 7, 2012 at 1:28 AM, Matt Mitchell <go...@gmail.com> wrote:
>>>> Hi,
>>>>
>>>> I have a recommender, with a boolean prefs model. I am following the
>>>> instructions in the MIA book, but only get this exception:
>>>>
>>>> Illegal precision: NaN
>>>> [Thrown class java.lang.IllegalArgumentException]
>>>>
>>>> Restarts:
>>>> 0: [QUIT] Quit to the SLIME top level
>>>>
>>>> Backtrace:
>>>> 0: com.google.common.base.Preconditions.checkArgument(Preconditions.java:88)
>>>> 1: org.apache.mahout.cf.taste.impl.eval.IRStatisticsImpl.<init>(IRStatisticsImpl.java:35)
>>>> 2: org.apache.mahout.cf.taste.impl.eval.GenericRecommenderIRStatsEvaluator.evaluate(GenericRecommenderIRStatsEvaluator.java:212)
>>>>
>>>> The code is written in Clojure, I hope that's OK:
>>>>
>>>> (let [model (GenericBooleanPrefDataModel.
>>>> (GenericBooleanPrefDataModel/toDataMap
>>>> (FileDataModel. (File. "resources/test.data"))))
>>>> evaluator (GenericRecommenderIRStatsEvaluator.)
>>>> rbuilder (reify RecommenderBuilder
>>>> (buildRecommender [this model]
>>>> (let [sim (LogLikelihoodSimilarity. model)
>>>> nhood (NearestNUserNeighborhood. 10 sim model)]
>>>> (GenericBooleanPrefUserBasedRecommender. model
>>>> nhood sim))))
>>>> mbuilder (reify DataModelBuilder
>>>> (buildDataModel [this training-data]
>>>> (GenericBooleanPrefDataModel.
>>>> (GenericBooleanPrefDataModel/toDataMap training-data))))]
>>>> (.evaluate evaluator rbuilder mbuilder model nil 10
>>>> GenericRecommenderIRStatsEvaluator/CHOOSE_THRESHOLD
>>>> 1.0))
>>>>
>>>> My test data file is very simple (for now):
>>>>
>>>> 1,1
>>>> 1,2
>>>> 1,3
>>>>
>>>> 2,1
>>>> 2,10
>>>> 2,100
>>>> 2,20
>>>>
>>>> 3,9
>>>> 3,10
>>>> 3,20
>>>> 3,1
>>>>
>>>> 4,10
>>>> 4,15
>>>> 4,1
>>>>
>>>> Any idea what I might be doing wrong?
>>>>
>>>> Thanks in advance,
>>>>
>>>> - Matt
Re: error when evaluating recommender w/boolean prefs
Posted by Matt Mitchell <go...@gmail.com>.
Hmm, still happening. I have a 220k line file with user, item and pref
value. I am still getting the NaN error when evaluating. I'm not sure
what to do. It also takes a long time for this error to popup, around
1 hour. I hate to throw code out like this, but maybe it'll be help
someone... help me. Is it related to the evaluator settings?
- Matt
(def prefs-file "data.txt")
(org.apache.mahout.common.RandomUtils/useTestSeed)
(let [model (FileDataModel. (File. prefs-file))
evaluator (GenericRecommenderIRStatsEvaluator.)
rbuilder (reify RecommenderBuilder
(buildRecommender [this model]
(let [sim (LogLikelihoodSimilarity. model)]
(GenericBooleanPrefItemBasedRecommender. model sim))))
mbuilder (reify DataModelBuilder
(buildDataModel [this training-data]
(GenericBooleanPrefDataModel.
(GenericBooleanPrefDataModel/toDataMap training-data))))]
(prn (.evaluate evaluator rbuilder mbuilder model nil 10
GenericRecommenderIRStatsEvaluator/CHOOSE_THRESHOLD
0.01)))
On Sat, Jul 7, 2012 at 11:20 AM, Matt Mitchell <go...@gmail.com> wrote:
> Thanks Sean, you're absolutely right. Things are working nicely now.
>
> - Matt
>
> On Sat, Jul 7, 2012 at 3:48 AM, Sean Owen <sr...@gmail.com> wrote:
>> What it really means is that there is not enough data to make a
>> meaningful test here.
>>
>> On Sat, Jul 7, 2012 at 1:28 AM, Matt Mitchell <go...@gmail.com> wrote:
>>> Hi,
>>>
>>> I have a recommender, with a boolean prefs model. I am following the
>>> instructions in the MIA book, but only get this exception:
>>>
>>> Illegal precision: NaN
>>> [Thrown class java.lang.IllegalArgumentException]
>>>
>>> Restarts:
>>> 0: [QUIT] Quit to the SLIME top level
>>>
>>> Backtrace:
>>> 0: com.google.common.base.Preconditions.checkArgument(Preconditions.java:88)
>>> 1: org.apache.mahout.cf.taste.impl.eval.IRStatisticsImpl.<init>(IRStatisticsImpl.java:35)
>>> 2: org.apache.mahout.cf.taste.impl.eval.GenericRecommenderIRStatsEvaluator.evaluate(GenericRecommenderIRStatsEvaluator.java:212)
>>>
>>> The code is written in Clojure, I hope that's OK:
>>>
>>> (let [model (GenericBooleanPrefDataModel.
>>> (GenericBooleanPrefDataModel/toDataMap
>>> (FileDataModel. (File. "resources/test.data"))))
>>> evaluator (GenericRecommenderIRStatsEvaluator.)
>>> rbuilder (reify RecommenderBuilder
>>> (buildRecommender [this model]
>>> (let [sim (LogLikelihoodSimilarity. model)
>>> nhood (NearestNUserNeighborhood. 10 sim model)]
>>> (GenericBooleanPrefUserBasedRecommender. model
>>> nhood sim))))
>>> mbuilder (reify DataModelBuilder
>>> (buildDataModel [this training-data]
>>> (GenericBooleanPrefDataModel.
>>> (GenericBooleanPrefDataModel/toDataMap training-data))))]
>>> (.evaluate evaluator rbuilder mbuilder model nil 10
>>> GenericRecommenderIRStatsEvaluator/CHOOSE_THRESHOLD
>>> 1.0))
>>>
>>> My test data file is very simple (for now):
>>>
>>> 1,1
>>> 1,2
>>> 1,3
>>>
>>> 2,1
>>> 2,10
>>> 2,100
>>> 2,20
>>>
>>> 3,9
>>> 3,10
>>> 3,20
>>> 3,1
>>>
>>> 4,10
>>> 4,15
>>> 4,1
>>>
>>> Any idea what I might be doing wrong?
>>>
>>> Thanks in advance,
>>>
>>> - Matt
Re: error when evaluating recommender w/boolean prefs
Posted by Matt Mitchell <go...@gmail.com>.
Thanks Sean, you're absolutely right. Things are working nicely now.
- Matt
On Sat, Jul 7, 2012 at 3:48 AM, Sean Owen <sr...@gmail.com> wrote:
> What it really means is that there is not enough data to make a
> meaningful test here.
>
> On Sat, Jul 7, 2012 at 1:28 AM, Matt Mitchell <go...@gmail.com> wrote:
>> Hi,
>>
>> I have a recommender, with a boolean prefs model. I am following the
>> instructions in the MIA book, but only get this exception:
>>
>> Illegal precision: NaN
>> [Thrown class java.lang.IllegalArgumentException]
>>
>> Restarts:
>> 0: [QUIT] Quit to the SLIME top level
>>
>> Backtrace:
>> 0: com.google.common.base.Preconditions.checkArgument(Preconditions.java:88)
>> 1: org.apache.mahout.cf.taste.impl.eval.IRStatisticsImpl.<init>(IRStatisticsImpl.java:35)
>> 2: org.apache.mahout.cf.taste.impl.eval.GenericRecommenderIRStatsEvaluator.evaluate(GenericRecommenderIRStatsEvaluator.java:212)
>>
>> The code is written in Clojure, I hope that's OK:
>>
>> (let [model (GenericBooleanPrefDataModel.
>> (GenericBooleanPrefDataModel/toDataMap
>> (FileDataModel. (File. "resources/test.data"))))
>> evaluator (GenericRecommenderIRStatsEvaluator.)
>> rbuilder (reify RecommenderBuilder
>> (buildRecommender [this model]
>> (let [sim (LogLikelihoodSimilarity. model)
>> nhood (NearestNUserNeighborhood. 10 sim model)]
>> (GenericBooleanPrefUserBasedRecommender. model
>> nhood sim))))
>> mbuilder (reify DataModelBuilder
>> (buildDataModel [this training-data]
>> (GenericBooleanPrefDataModel.
>> (GenericBooleanPrefDataModel/toDataMap training-data))))]
>> (.evaluate evaluator rbuilder mbuilder model nil 10
>> GenericRecommenderIRStatsEvaluator/CHOOSE_THRESHOLD
>> 1.0))
>>
>> My test data file is very simple (for now):
>>
>> 1,1
>> 1,2
>> 1,3
>>
>> 2,1
>> 2,10
>> 2,100
>> 2,20
>>
>> 3,9
>> 3,10
>> 3,20
>> 3,1
>>
>> 4,10
>> 4,15
>> 4,1
>>
>> Any idea what I might be doing wrong?
>>
>> Thanks in advance,
>>
>> - Matt
Re: error when evaluating recommender w/boolean prefs
Posted by Sean Owen <sr...@gmail.com>.
What it really means is that there is not enough data to make a
meaningful test here.
On Sat, Jul 7, 2012 at 1:28 AM, Matt Mitchell <go...@gmail.com> wrote:
> Hi,
>
> I have a recommender, with a boolean prefs model. I am following the
> instructions in the MIA book, but only get this exception:
>
> Illegal precision: NaN
> [Thrown class java.lang.IllegalArgumentException]
>
> Restarts:
> 0: [QUIT] Quit to the SLIME top level
>
> Backtrace:
> 0: com.google.common.base.Preconditions.checkArgument(Preconditions.java:88)
> 1: org.apache.mahout.cf.taste.impl.eval.IRStatisticsImpl.<init>(IRStatisticsImpl.java:35)
> 2: org.apache.mahout.cf.taste.impl.eval.GenericRecommenderIRStatsEvaluator.evaluate(GenericRecommenderIRStatsEvaluator.java:212)
>
> The code is written in Clojure, I hope that's OK:
>
> (let [model (GenericBooleanPrefDataModel.
> (GenericBooleanPrefDataModel/toDataMap
> (FileDataModel. (File. "resources/test.data"))))
> evaluator (GenericRecommenderIRStatsEvaluator.)
> rbuilder (reify RecommenderBuilder
> (buildRecommender [this model]
> (let [sim (LogLikelihoodSimilarity. model)
> nhood (NearestNUserNeighborhood. 10 sim model)]
> (GenericBooleanPrefUserBasedRecommender. model
> nhood sim))))
> mbuilder (reify DataModelBuilder
> (buildDataModel [this training-data]
> (GenericBooleanPrefDataModel.
> (GenericBooleanPrefDataModel/toDataMap training-data))))]
> (.evaluate evaluator rbuilder mbuilder model nil 10
> GenericRecommenderIRStatsEvaluator/CHOOSE_THRESHOLD
> 1.0))
>
> My test data file is very simple (for now):
>
> 1,1
> 1,2
> 1,3
>
> 2,1
> 2,10
> 2,100
> 2,20
>
> 3,9
> 3,10
> 3,20
> 3,1
>
> 4,10
> 4,15
> 4,1
>
> Any idea what I might be doing wrong?
>
> Thanks in advance,
>
> - Matt