(self)
IV = ∑(py_i - pn_i ) * WOE
        where py_i is event_rate, pn_i is non_event_rate
        WOE = log(non_event_rate / event_rate)
IV = ∑(py_i - pn_i ) * WOE
        where py_i is event_rate, pn_i is non_event_rate
        WOE = log(non_event_rate / event_rate)
IV = ∑ ( py_i - pn_i ) * WOE where py_i is event_rate pn_i is non_event_rate WOE = log ( non_event_rate / event_rate )
def cal_score(self):
        """
        IV = ∑(py_i - pn_i ) * WOE
        where py_i is event_rate, pn_i is non_event_rate
        WOE = log(non_event_rate / event_rate)
        """

        self.event_count = self.left_bucket.event_count + self.right_bucket.event_count
        self.non_event_count = self.left_bucket.non_event_count + self.right_bucket.non_event_count
        if self.total_count == 0:
            self.score = -math.inf
            return

        # if self.left_bucket.left_bound != math.inf and self.right_bucket.right_bound != -math.inf:
        #     if (self.left_bucket.left_bound <= self.right_bucket.right_bound):
        #         self.score = -math.inf
        #         return

        self.event_total = self.left_bucket.event_total
        self.non_event_total = self.left_bucket.non_event_total

        if self.event_count == 0 or self.non_event_count == 0:
            event_rate = 1.0 * (self.event_count + self.adjustment_factor) / max(self.event_total, 1)
            non_event_rate = 1.0 * (self.non_event_count + self.adjustment_factor) / max(self.non_event_total, 1)
        else:
            event_rate = 1.0 * self.event_count / max(self.event_total, 1)
            non_event_rate = 1.0 * self.non_event_count / max(self.non_event_total, 1)
        merge_woe = math.log(event_rate / non_event_rate)

        merge_iv = (event_rate - non_event_rate) * merge_woe
        self.score = self.left_bucket.iv + self.right_bucket.iv - merge_iv
def cal_score ( self ) : self . event_count = self . left_bucket . event_count + self . right_bucket . event_count self . non_event_count = self . left_bucket . non_event_count + self . right_bucket . non_event_count if self . total_count == 0 : self . score = - math . inf return # if self.left_bucket.left_bound != math.inf and self.right_bucket.right_bound != -math.inf: #     if (self.left_bucket.left_bound <= self.right_bucket.right_bound): #         self.score = -math.inf #         return self . event_total = self . left_bucket . event_total self . non_event_total = self . left_bucket . non_event_total if self . event_count == 0 or self . non_event_count == 0 : event_rate = 1.0 * ( self . event_count + self . adjustment_factor ) / max ( self . event_total , 1 ) non_event_rate = 1.0 * ( self . non_event_count + self . adjustment_factor ) / max ( self . non_event_total , 1 ) else : event_rate = 1.0 * self . event_count / max ( self . event_total , 1 ) non_event_rate = 1.0 * self . non_event_count / max ( self . non_event_total , 1 ) merge_woe = math . log ( event_rate / non_event_rate ) merge_iv = ( event_rate - non_event_rate ) * merge_woe self . score = self . left_bucket . iv + self . right_bucket . iv - merge_iv