diff --git a/ProgrammingAssignment_2/model.ipynb b/ProgrammingAssignment_2/model.ipynb index 08813b20ca76a342c5470d99285f63e873a9c17e..413c74b98a01ce2e8c248a6ed50d7af9a660efd2 100644 --- a/ProgrammingAssignment_2/model.ipynb +++ b/ProgrammingAssignment_2/model.ipynb @@ -166,58 +166,6 @@ " raise NotImplementedError\n", " return value" ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## General supervised learning performance related functions " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Implement the \"conf_matrix\" function that takes as input an array of true labels (*true*) and an array of predicted labels (*pred*)." - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [], - "source": [ - "def conf_matrix(true, pred):\n", - " '''\n", - " Args: \n", - " true: ndarray\n", - " nx1 array of true labels for test set\n", - " pred: ndarray \n", - " nx1 array of predicted labels for test set\n", - " Returns:\n", - " ndarray\n", - " '''\n", - " \n", - " tp = tn = fp = fn = 0\n", - " # calculate true positives (tp), true negatives(tn)\n", - " # false positives (fp) and false negatives (fn)\n", - " \n", - " size = len(true)\n", - " for i in range(size):\n", - " if true[i]==1:\n", - " if pred[i] == 1: \n", - " tp += 1\n", - " else: \n", - " fn += 1\n", - " else:\n", - " if pred[i] == 0:\n", - " tn += 1 \n", - " else:\n", - " fp += 1 \n", - " \n", - " # returns the confusion matrix as numpy.ndarray\n", - " return np.array([tp,tn, fp, fn])" - ] } ], "metadata": {