diff --git a/03_classification.ipynb b/03_classification.ipynb index 05050fa..b9f3650 100644 --- a/03_classification.ipynb +++ b/03_classification.ipynb @@ -346,13 +346,6 @@ "execution_count": 23, "metadata": {}, "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": 24, - "metadata": {}, - "outputs": [], "source": [ "y_train_perfect_predictions = y_train_5 # pretend we reached perfection\n", "confusion_matrix(y_train_5, y_train_perfect_predictions)" @@ -360,7 +353,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 24, "metadata": {}, "outputs": [], "source": [ @@ -371,7 +364,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 25, "metadata": {}, "outputs": [], "source": [ @@ -380,7 +373,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 26, "metadata": {}, "outputs": [], "source": [ @@ -389,7 +382,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 27, "metadata": {}, "outputs": [], "source": [ @@ -398,7 +391,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 28, "metadata": {}, "outputs": [], "source": [ @@ -409,7 +402,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 29, "metadata": {}, "outputs": [], "source": [ @@ -418,7 +411,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 30, "metadata": {}, "outputs": [], "source": [ @@ -428,7 +421,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 31, "metadata": {}, "outputs": [], "source": [ @@ -438,7 +431,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 32, "metadata": {}, "outputs": [], "source": [ @@ -447,7 +440,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 33, "metadata": {}, "outputs": [], "source": [ @@ -458,7 +451,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 34, "metadata": {}, "outputs": [], "source": [ @@ -468,7 +461,7 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 35, "metadata": {}, "outputs": [], "source": [ @@ -479,7 +472,7 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 36, "metadata": {}, "outputs": [], "source": [ @@ -504,7 +497,7 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": 37, "metadata": {}, "outputs": [], "source": [ @@ -513,7 +506,7 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 38, "metadata": {}, "outputs": [], "source": [ @@ -533,31 +526,13 @@ "plt.show()" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "threshold_90_precision = thresholds[np.argmax(precisions >= 0.90)] # == 7813" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "threshold_90_precision" - ] - }, { "cell_type": "code", "execution_count": 39, "metadata": {}, "outputs": [], "source": [ - "y_train_pred_90 = (y_scores >= threshold_90_precision)" + "threshold_90_precision = thresholds[np.argmax(precisions >= 0.90)]" ] }, { @@ -566,7 +541,7 @@ "metadata": {}, "outputs": [], "source": [ - "precision_score(y_train_5, y_train_pred_90)" + "threshold_90_precision" ] }, { @@ -574,6 +549,24 @@ "execution_count": 41, "metadata": {}, "outputs": [], + "source": [ + "y_train_pred_90 = (y_scores >= threshold_90_precision)" + ] + }, + { + "cell_type": "code", + "execution_count": 42, + "metadata": {}, + "outputs": [], + "source": [ + "precision_score(y_train_5, y_train_pred_90)" + ] + }, + { + "cell_type": "code", + "execution_count": 43, + "metadata": {}, + "outputs": [], "source": [ "recall_score(y_train_5, y_train_pred_90)" ] @@ -587,7 +580,7 @@ }, { "cell_type": "code", - "execution_count": 43, + "execution_count": 44, "metadata": {}, "outputs": [], "source": [