assignments/assignment1/metrics.py
def multiclass_accuracy(prediction, ground_truth):
    '''
    Computes metrics for multiclass classification

    Arguments:
    prediction, np array of int (num_samples) - model predictions
    ground_truth, np array of int (num_samples) - true labels

    Returns:
    accuracy - ratio of accurate predictions to total samples
    '''

    accuracy = 0


    nTruePositives = 0
    nFalsePositives = 0


    for i in range(len(prediction)):

        if prediction[i] == ground_truth[i]:
            nTruePositives = nTruePositives + 1
        else:
            nFalsePositives = nFalsePositives + 1



    accuracy = nTruePositives  / (nTruePositives  +nFalsePositives)
    return  accuracy

    Computes metrics for multiclass classification

    Arguments:
    prediction, np array of int (num_samples) - model predictions
    ground_truth, np array of int (num_samples) - true labels

    Returns:
    accuracy - ratio of accurate predictions to total samples
    
Computes metrics for multiclass classification
Arguments:
prediction, np array of int (num_samples) - model predictions
ground_truth, np array of int (num_samples) - true labels

ratio of accurate predictions to total samples
Computes metrics for multiclass classification Arguments : prediction np array of int ( num_samples ) - model predictions ground_truth np array of int ( num_samples ) - true labels ratio of accurate predictions to total samples
def multiclass_accuracy(prediction, ground_truth):
    accuracy = 0
    nTruePositives = 0
    nFalsePositives = 0
    for i in range(len(prediction)):
        if prediction[i] == ground_truth[i]:
            nTruePositives = nTruePositives + 1
        else:
            nFalsePositives = nFalsePositives + 1
    accuracy = nTruePositives  / (nTruePositives  +nFalsePositives)
    return  accuracy
def multiclass_accuracy ( prediction , ground_truth ) : accuracy = 0 nTruePositives = 0 nFalsePositives = 0 for i in range ( len ( prediction ) ) : if prediction [ i ] == ground_truth [ i ] : nTruePositives = nTruePositives + 1 else : nFalsePositives = nFalsePositives + 1 accuracy = nTruePositives / ( nTruePositives + nFalsePositives ) return accuracy
Computes metrics for multiclass classification
Arguments:
prediction, np array of int (num_samples) - model predictions
ground_truth, np array of int (num_samples) - true labels
Computes metrics for multiclass classification Arguments : prediction np array of int ( num_samples ) - model predictions ground_truth np array of int ( num_samples ) - true labels
'''
    Computes metrics for multiclass classification

    Arguments:
    prediction, np array of int (num_samples) - model predictions
    ground_truth, np array of int (num_samples) - true labels

    Returns:
    accuracy - ratio of accurate predictions to total samples
    '''
prediction
ground_truth