Hi Sheila,
I think if you use an odd-number of neighbors you can break your ties.
Without a weight function, the probability should be comprised of votes
from the k-nearest neighbors. So, the tie at 0.5 means two neighbors are
class 2 and two are class 3 for the first two samples and a tie would be
broken by including a fifth neighbor (the default).
On Mon, Sep 8, 2014 at 4:06 AM, Sheila the angel <[email protected]>
wrote:
> Any suggestion about KNeighborsClassifier().predict_proba ?
>
>
> On 3 September 2014 14:57, Sheila the angel <[email protected]>
> wrote:
>
>> I am using KNeighborsClassifier and trying to obtain probabilistic output.
>> But for many of the test sets I am getting equal probability for all
>> class.
>>
>> >>>X_train, X_test, y_train, y_test =
>> cross_validation.train_test_split(iris.data, iris.target, test_size=0.4,
>> random_state=0)
>>
>> >>>clf = KNeighborsClassifier(n_neighbors=4).fit(X_train, y_train)
>>
>> >>>clf.predict_proba(X_test)
>>
>> #An example output
>>
>> [ 0. 0.5 0.5 ]
>>
>> [ 0. 0.5 0.5 ]
>>
>> [ 0. 1. 0. ]
>>
>> Do the prediction of class label via function .predict in
>> KNeighborsClassifier use .predict_proba ?
>>
>>
>> In my another data-set the probability values for two particular classes
>> are most of the time equal (as shown in the example).
>>
>> How do I break the tie in such cases?
>>
>> Thanks
>> --
>> Sheila
>>
>
>
>
> ------------------------------------------------------------------------------
> Want excitement?
> Manually upgrade your production database.
> When you want reliability, choose Perforce
> Perforce version control. Predictably reliable.
>
> http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
> _______________________________________________
> Scikit-learn-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
>
>
--
Patrick Short
------------------------------
University of North Carolina at Chapel Hill, 2014
Applied Mathematics and Quantitative Biology
[email protected] | 919-455-7045 C
------------------------------------------------------------------------------
Want excitement?
Manually upgrade your production database.
When you want reliability, choose Perforce
Perforce version control. Predictably reliable.
http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
_______________________________________________
Scikit-learn-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general