hw3/hw3_submission.py
def predict(self, x):
        """
        Use the acquired mean and std for each class to predict class for input x.
        Inputs:

        Returns:
        - prediction: Predicted labels for the data in x. prediction is (N, C) dimensional array, for N samples and C classes.
        """

        n = len(x)
        num_class = len(np.unique(self.y))
        prediction = np.zeros((n, num_class))

        ############################################################
        ############################################################
        # BEGIN_YOUR_CODE
        # calculate naive bayes probability of each class of input x
        for arr in range(n):
            for c in range(num_class):
                prediction[arr][c] = self.y_prior[c] + np.sum(np.log(self.calc_gaussian_dist(x[arr], self.mean_by_class[c], self.std_by_class[c])))
        pass
        # END_YOUR_CODE
        ############################################################
        ############################################################

        return prediction

        Use the acquired mean and std for each class to predict class for input x.
        Inputs:

        Returns:
        - prediction: Predicted labels for the data in x. prediction is (N, C) dimensional array, for N samples and C classes.
        
Use the acquired mean and std for each class to predict class for input x.
Inputs.
Use the acquired mean and std for each class to predict class for input x . Inputs .
def predict(self, x):
        n = len(x)
        num_class = len(np.unique(self.y))
        prediction = np.zeros((n, num_class))
        for arr in range(n):
            for c in range(num_class):
                prediction[arr][c] = self.y_prior[c] + np.sum(np.log(self.calc_gaussian_dist(x[arr], self.mean_by_class[c], self.std_by_class[c])))
        pass
        return prediction
def predict ( self , x ) : n = len ( x ) num_class = len ( np . unique ( self . y ) ) prediction = np . zeros ( ( n , num_class ) ) for arr in range ( n ) : for c in range ( num_class ) : prediction [ arr ] [ c ] = self . y_prior [ c ] + np . sum ( np . log ( self . calc_gaussian_dist ( x [ arr ] , self . mean_by_class [ c ] , self . std_by_class [ c ] ) ) ) pass return prediction
Use the acquired mean and std for each class to predict class for input x.
Inputs:
Use the acquired mean and std for each class to predict class for input x . Inputs :
"""
        Use the acquired mean and std for each class to predict class for input x.
        Inputs:

        Returns:
        - prediction: Predicted labels for the data in x. prediction is (N, C) dimensional array, for N samples and C classes.
        """ ############################################################ ############################################################ # BEGIN_YOUR_CODE # calculate naive bayes probability of each class of input x # END_YOUR_CODE ############################################################ ############################################################
None
self
x