def display_interactive_cm()

in notebook/utils/trust.py [0:0]


    def display_interactive_cm(self, start=0.5, min=0.0, max=1.0, step=0.05) :

        y = self._y()
        yh = self._yh()
        
        def cm_heatmap_fn(Threshold) :

            cm = confusion_matrix(y, yh >= Threshold).astype(int)

            names = ['True Neg','False Pos','False Neg','True Pos']
            counts = ["{0:0.0f}".format(value)
                            for value in cm.flatten()]

            pcts = ["{0:.2%}".format(value)
                                 for value in cm.flatten()/np.sum(cm)]

            labels = [f"{v1}\n{v2}\n{v3}"
                      for v1, v2, v3 in zip(names,counts,pcts)]

            labels = np.asarray(labels).reshape(2,2)
            sns.heatmap(cm, annot=labels, fmt='', cmap='Blues')

        thresh_slider = widgets.FloatSlider(value=start,
                                            min=min,
                                            max=max,
                                            step=step)

        interact(cm_heatmap_fn, Threshold=thresh_slider)