Hi,

The generation of the 'random' confusion matrix constrained by
rows and columns can be done in different ways so first of all
you have the define the assumptions of the underlying probabilistic
model of what exactly means "at random" in your case. Once
you have that model you just sample from it.

A reasonable solution in many contexts is to define as "random" the
confusion matrices for which the predicted class labels are statistically
independent from the true class label. Under this assumption you can
find some useful directions from here:
   http://www.tandfonline.com/doi/abs/10.1198/jasa.2009.tm08106
(Section 2, sampling models and inference, your case is P3)
The paper is not about confusion matrices but the more general
contingency tables. About confusion matrices:
   http://dx.doi.org/10.1109/prni.2012.14
(disclaimer: it is one of my papers)
but in that article I am not using your strict constraints. I am in the
process of writing one longer article for the case of one total fixed (usually
called "one margin fixed) [*].

Having both margin fixed is an unlikely situation, especially for
confusion matrices. Your case looks like the one margin fixed. Could
you elaborate more on the final goal of your attempt?

Best,

Emanuele

[*] for the one-margin fixed case I've some Python code here:
https://github.com/emanuele/inference_with_classifiers


On 03/15/2013 02:05 PM, [email protected] wrote:
> Dear ScikitLearners,
>
> I hope that I'm not too much off topic...
>
> Given a confusion matrix (trained in scikit-learn):
> [[186 187]
>   [119 997]]
>
> I calculate these variables:
> exp_class0 = conf_matrix[0].sum()
> exp_class1 = conf_matrix[1].sum()
> pred_class0 = conf_matrix[:,0].sum()
> pred_class1 = conf_matrix[:,1].sum()
>
>
> Based on these parameters/constraints, I would like to generate a
> "kind-of-random" confusion matrix showing the same sum of rows and colums
> as the trained confusion matrix, e.g.
> [[184 189]
>   [121 995]]
> which is rather close to my original confusion matrix, but for this
> sampling I didn't need good coding skills. :)
>
> How can such a sampling be done in Python/Numpy?
> I have spent some time on stackoverflow.com et al., but I didn't find a
> proper solution..
>
> Cheers & Thanks,
> Paul
>
>
> This message and any attachment are confidential and may be privileged or 
> otherwise protected from disclosure. If you are not the intended recipient, 
> you must not copy this message or attachment or disclose the contents to any 
> other person. If you have received this transmission in error, please notify 
> the sender immediately and delete the message and any attachment from your 
> system. Merck KGaA, Darmstadt, Germany and any of its subsidiaries do not 
> accept liability for any omissions or errors in this message which may arise 
> as a result of E-Mail-transmission or for damages resulting from any 
> unauthorized changes of the content of this message and any attachment 
> thereto. Merck KGaA, Darmstadt, Germany and any of its subsidiaries do not 
> guarantee that this message is free of viruses and does not accept liability 
> for any damages caused by any virus transmitted therewith.
>
> Click http://www.merckgroup.com/disclaimer to access the German, French, 
> Spanish and Portuguese versions of this disclaimer.
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_mar
> _______________________________________________
> Scikit-learn-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
>
>


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Scikit-learn-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general

Reply via email to