def _generate_label_matrix(self):
        """Generate an [n,m] label matrix with entries in {0,...,k}"""
        self.L = np.zeros((self.n, self.m))
        self.Y = np.zeros(self.n, dtype=np.int64)
        for i in range(self.n):
            y = choice(self.k, p=self.p) + 1  # Note that y \in {1,...,k}
            self.Y[i] = y
            for j in range(self.m):
                p_j = self.parent.get(j, 0)
                prob_y = self.P_conditional(j, y, p_j, self.L[i, p_j], y)
                prob_0 = self.P_conditional(j, 0, p_j, self.L[i, p_j], y)
                p = np.ones(self.k + 1) * (1 - prob_y - prob_0) / (self.k - 1)
                p[0] = prob_0
                p[y] = prob_y
                self.L[i, j] = choice(self.k + 1, p=p)
def _generate_label_matrix ( self ) : self . L = np . zeros ( ( self . n , self . m ) ) self . Y = np . zeros ( self . n , dtype = np . int64 ) for i in range ( self . n ) : y = choice ( self . k , p = self . p ) + 1 self . Y [ i ] = y for j in range ( self . m ) : p_j = self . parent . get ( j , 0 ) prob_y = self . P_conditional ( j , y , p_j , self . L [ i , p_j ] , y ) prob_0 = self . P_conditional ( j , 0 , p_j , self . L [ i , p_j ] , y ) p = np . ones ( self . k + 1 ) * ( 1 - prob_y - prob_0 ) / ( self . k - 1 ) p [ 0 ] = prob_0 p [ y ] = prob_y self . L [ i , j ] = choice ( self . k + 1 , p = p )
Generate an [n,m] label matrix with entries in {0,...,k}