{"id":570,"date":"2026-07-23T00:00:00","date_gmt":"2026-07-22T23:00:00","guid":{"rendered":"https:\/\/kosokoking.com\/?p=570"},"modified":"2026-07-18T14:38:37","modified_gmt":"2026-07-18T13:38:37","slug":"executing-a-label-flipping-attack-on-a-classifier","status":"publish","type":"post","link":"https:\/\/kosokoking.com\/index.php\/security\/executing-a-label-flipping-attack-on-a-classifier\/","title":{"rendered":"Executing a label flipping attack on a classifier"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">This article walks through executing a label flipping attack against the logistic regression classifier trained on the synthetic sentiment analysis dataset established in the previous article. It covers training the baseline model on clean data, implementing the attack function, evaluating its effects at poisoning rates from 10% to 50%, and analysing how the decision boundary shifts even when overall accuracy remains unchanged.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Training the baseline model<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before poisoning anything, we need a clean performance baseline. Logistic regression is a binary classifier that learns a weight vector&nbsp;<code>w<\/code>&nbsp;and bias&nbsp;<code>b<\/code>, then passes the linear combination&nbsp;<code>z = w^T x + b<\/code>&nbsp;through a sigmoid function to produce a probability between 0 and 1. The decision boundary sits where that probability equals 0.5, which is the line defined by&nbsp;<code>w^T x + b = 0<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>baseline_model = LogisticRegression(random_state=SEED)\nbaseline_model.fit(X_train, y_train)\n\ny_pred_baseline = baseline_model.predict(X_test)\nbaseline_accuracy = accuracy_score(y_test, y_pred_baseline)\nprint(f\"Baseline Model Accuracy: {baseline_accuracy:.4f}\")\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The baseline achieves 99.33% accuracy on the test set. This is the performance ceiling against which we measure every poisoned model.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To visualise how the model separates the two classes, we plot the decision boundary across the feature space. The function below generates a mesh grid, predicts the class at every point, and overlays the training data on top.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def plot_decision_boundary(model, X, y, title=\"Decision Boundary\"):\n    h = 0.02\n    x_min, x_max = X&#91;:, 0].min() - 1, X&#91;:, 0].max() + 1\n    y_min, y_max = X&#91;:, 1].min() - 1, X&#91;:, 1].max() + 1\n    xx, yy = np.meshgrid(np.arange(x_min, x_max, h), np.arange(y_min, y_max, h))\n\n    Z = model.predict(np.c_&#91;xx.ravel(), yy.ravel()])\n    Z = Z.reshape(xx.shape)\n\n    plt.figure(figsize=(12, 6))\n    plt.contourf(\n        xx, yy, Z, cmap=plt.cm.colors.ListedColormap(&#91;azure, nugget_yellow]), alpha=0.3\n    )\n    scatter = plt.scatter(\n        X&#91;:, 0], X&#91;:, 1], c=y,\n        cmap=plt.cm.colors.ListedColormap(&#91;azure, nugget_yellow]),\n        edgecolors=node_black, s=50, alpha=0.8,\n    )\n    plt.title(title, fontsize=16, color=htb_green)\n    plt.xlabel(\"Feature 1\", fontsize=12)\n    plt.ylabel(\"Feature 2\", fontsize=12)\n    handles = &#91;\n        plt.Line2D(&#91;0], &#91;0], marker=\"o\", color=\"w\", label=\"Negative Sentiment (Class 0)\",\n                   markersize=10, markerfacecolor=azure),\n        plt.Line2D(&#91;0], &#91;0], marker=\"o\", color=\"w\", label=\"Positive Sentiment (Class 1)\",\n                   markersize=10, markerfacecolor=nugget_yellow),\n    ]\n    plt.legend(handles=handles, title=\"Classes\")\n    plt.grid(True, color=hacker_grey, linestyle=\"--\", linewidth=0.5, alpha=0.3)\n    plt.xlim(xx.min(), xx.max())\n    plt.ylim(yy.min(), yy.max())\n    plt.show()\n\nplot_decision_boundary(\n    baseline_model, X_train, y_train,\n    title=f\"Baseline Model Decision Boundary\\nAccuracy: {baseline_accuracy:.4f}\",\n)\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The baseline boundary sits neatly between the two clusters. With well-separated synthetic data like this, logistic regression has no trouble drawing a clean line.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why flipped labels corrupt the loss function<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">During training, logistic regression minimises binary cross-entropy (log-loss) across the training set. Each sample contributes a term to the total loss based on how well the model&#8217;s predicted probability matches that sample&#8217;s label.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When a sample truly belongs to Class 0 and is correctly labelled, the model learns to predict a low probability for Class 1. The loss contribution from that sample is small because the prediction aligns with the label. If an attacker flips that sample&#8217;s label to Class 1, the model now faces a conflict. The features still point toward Class 0, but the label says Class 1. The loss contribution from that single sample becomes large because the model&#8217;s natural prediction (low probability for Class 1) directly contradicts the corrupted label.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This large error signal forces the optimiser to adjust the weight vector and bias to accommodate the poisoned sample. Multiply this across enough flipped samples and the learned decision boundary shifts away from its optimal position. The model is trying to satisfy two contradictory demands simultaneously, fitting the correctly labelled data and fitting the poisoned data, and the result is a compromised boundary that satisfies neither perfectly.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Implementing the label flipping attack<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The&nbsp;<code>flip_labels<\/code>&nbsp;function takes the original training labels and a poisoning percentage, randomly selects that fraction of samples, and inverts their labels. For binary labels,&nbsp;<code>1 - label<\/code>&nbsp;handles the inversion.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def flip_labels(y, poison_percentage):\n    if not 0 &lt;= poison_percentage &lt;= 1:\n        raise ValueError(\"poison_percentage must be between 0 and 1.\")\n\n    n_samples = len(y)\n    n_to_flip = int(n_samples * poison_percentage)\n\n    if n_to_flip == 0:\n        print(\"Warning: Poison percentage is 0 or too low to flip any labels.\")\n        return y.copy(), np.array(&#91;], dtype=int)\n\n    rng_instance = np.random.default_rng(SEED)\n    flipped_indices = rng_instance.choice(n_samples, size=n_to_flip, replace=False)\n\n    y_poisoned = y.copy()\n    original_labels_at_flipped = y_poisoned&#91;flipped_indices]\n    y_poisoned&#91;flipped_indices] = np.where(original_labels_at_flipped == 0, 1, 0)\n\n    print(f\"Flipping {n_to_flip} labels ({poison_percentage * 100:.1f}%).\")\n    return y_poisoned, flipped_indices\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The function works on a copy of the label array so the original&nbsp;<code>y_train<\/code>&nbsp;stays intact for comparison. It returns both the poisoned labels and the indices of the flipped samples, which is useful for visualisation later. The random number generator is seeded for reproducibility, meaning the same indices get selected on every run.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We also need a visualisation function to highlight which samples had their labels flipped. The&nbsp;<code>plot_poisoned_data<\/code>&nbsp;function plots all training points, colouring them by their new (possibly corrupted) label, and marks the flipped samples with a red-bordered X marker so they stand out from the untouched data.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def plot_poisoned_data(X, y_original, y_poisoned, flipped_indices,\n                       title=\"Poisoned Data Visualization\", target_class_info=None):\n    plt.figure(figsize=(12, 7))\n    mask_not_flipped = np.ones(len(y_poisoned), dtype=bool)\n    mask_not_flipped&#91;flipped_indices] = False\n\n    plt.scatter(X&#91;mask_not_flipped, 0], X&#91;mask_not_flipped, 1],\n                c=y_poisoned&#91;mask_not_flipped],\n                cmap=plt.cm.colors.ListedColormap(&#91;azure, nugget_yellow]),\n                edgecolors=node_black, s=50, alpha=0.6, label=\"Unchanged Label\")\n\n    flipped_legend_label = (f\"Flipped (Orig Class {target_class_info})\"\n                           if target_class_info is not None else \"Flipped Label\")\n\n    if len(flipped_indices) &gt; 0:\n        plt.scatter(X&#91;flipped_indices, 0], X&#91;flipped_indices, 1],\n                    c=y_poisoned&#91;flipped_indices],\n                    cmap=plt.cm.colors.ListedColormap(&#91;azure, nugget_yellow]),\n                    edgecolors=malware_red, linewidths=1.5, marker=\"X\",\n                    s=100, alpha=0.9, label=flipped_legend_label)\n\n    plt.title(title, fontsize=16, color=htb_green)\n    plt.xlabel(\"Feature 1\", fontsize=12)\n    plt.ylabel(\"Feature 2\", fontsize=12)\n    handles = &#91;\n        plt.Line2D(&#91;0], &#91;0], marker=\"o\", color=\"w\", label=\"Class 0 Point (Azure)\",\n                   markersize=10, markerfacecolor=azure, linestyle=\"None\"),\n        plt.Line2D(&#91;0], &#91;0], marker=\"o\", color=\"w\", label=\"Class 1 Point (Yellow)\",\n                   markersize=10, markerfacecolor=nugget_yellow, linestyle=\"None\"),\n        plt.Line2D(&#91;0], &#91;0], marker=\"X\", color=\"w\", label=flipped_legend_label,\n                   markersize=12, markeredgecolor=malware_red,\n                   markerfacecolor=hacker_grey, linestyle=\"None\"),\n    ]\n    plt.legend(handles=handles, title=\"Data Points\")\n    plt.grid(True, color=hacker_grey, linestyle=\"--\", linewidth=0.5, alpha=0.3)\n    plt.show()\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Evaluating the label flipping attack<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">With the attack function in place, we can poison the training labels at increasing rates and measure the effect on the model trained on that corrupted data. The evaluation loop flips labels at 10%, 20%, 30%, 40%, and 50%, trains a fresh logistic regression model at each rate, and evaluates accuracy on the clean test set.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>results = {\n    \"percentage\": &#91;], \"accuracy\": &#91;], \"model\": &#91;],\n    \"y_train_poisoned\": &#91;], \"flipped_indices\": &#91;],\n}\ndecision_boundaries_data = &#91;]\n\n# Store baseline\nresults&#91;\"percentage\"].append(0.0)\nresults&#91;\"accuracy\"].append(baseline_accuracy)\nresults&#91;\"model\"].append(baseline_model)\nresults&#91;\"y_train_poisoned\"].append(y_train.copy())\nresults&#91;\"flipped_indices\"].append(np.array(&#91;], dtype=int))\n\n# Pre-compute meshgrid for boundary plots\nh = 0.02\nx_min, x_max = X_train&#91;:, 0].min() - 1, X_train&#91;:, 0].max() + 1\ny_min, y_max = X_train&#91;:, 1].min() - 1, X_train&#91;:, 1].max() + 1\nxx, yy = np.meshgrid(np.arange(x_min, x_max, h), np.arange(y_min, y_max, h))\nmesh_points = np.c_&#91;xx.ravel(), yy.ravel()]\n\npoison_percentages = &#91;0.10, 0.20, 0.30, 0.40, 0.50]\n\nfor pp in poison_percentages:\n    print(f\"\\n--- Training with {pp * 100:.0f}% Poisoned Data ---\")\n    y_train_poisoned, flipped_idx = flip_labels(y_train, pp)\n\n    poisoned_model = LogisticRegression(random_state=SEED)\n    poisoned_model.fit(X_train, y_train_poisoned)\n\n    y_pred_poisoned = poisoned_model.predict(X_test)\n    accuracy = accuracy_score(y_test, y_pred_poisoned)\n    print(f\"Accuracy on clean test set: {accuracy:.4f}\")\n\n    results&#91;\"percentage\"].append(pp)\n    results&#91;\"accuracy\"].append(accuracy)\n    results&#91;\"model\"].append(poisoned_model)\n    results&#91;\"y_train_poisoned\"].append(y_train_poisoned)\n    results&#91;\"flipped_indices\"].append(flipped_idx)\n\n    plot_poisoned_data(X_train, y_train, y_train_poisoned, flipped_idx,\n                       title=f\"Training Data with {pp * 100:.0f}% Flipped Labels\")\n    plot_decision_boundary(poisoned_model, X_train, y_train_poisoned,\n                          title=f\"Decision Boundary ({pp * 100:.0f}% Poisoned)\\nAccuracy: {accuracy:.4f}\")\n\n    Z = poisoned_model.predict(mesh_points).reshape(xx.shape)\n    decision_boundaries_data.append({\"percentage\": pp, \"Z\": Z})\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Each iteration generates two plots, one showing which samples were flipped and one showing the resulting decision boundary. The accuracy scores and boundary predictions are stored for the aggregate analysis below.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Plotting accuracy against poisoning percentage reveals the degradation curve.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>plt.figure(figsize=(8, 5))\nplot_data_sorted = sorted(zip(results&#91;\"percentage\"], results&#91;\"accuracy\"]))\nplot_percentages = &#91;p * 100 for p, a in plot_data_sorted]\nplot_accuracies = &#91;a for p, a in plot_data_sorted]\n\nplt.plot(plot_percentages, plot_accuracies, marker=\"o\", linestyle=\"-\",\n         color=htb_green, markersize=8)\nplt.title(\"Model Accuracy vs. Label Flipping Percentage\", fontsize=16, color=htb_green)\nplt.xlabel(\"Percentage of Training Labels Flipped (%)\", fontsize=12)\nplt.ylabel(\"Accuracy on Clean Test Set\", fontsize=12)\nplt.xticks(plot_percentages)\nplt.ylim(0, 1.05)\nplt.grid(True, color=hacker_grey, linestyle=\"--\", linewidth=0.5, alpha=0.3)\nplt.show()\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">With this synthetic dataset, accuracy holds at 99.33% all the way through 40% poisoning and only collapses at 50%. This is a consequence of the data being so well-separated. The two clusters sit far enough apart that even with a substantial number of labels flipped, the model still finds a boundary that correctly classifies the test set. In a real-world dataset where classes overlap or the feature space is noisier, the accuracy degradation would begin much earlier.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The boundary shift under the surface<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The accuracy curve tells a misleading story if read in isolation. While the test accuracy stays flat, the decision boundary is moving at every poisoning rate. Overlaying all boundaries on a single plot makes this visible.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>plt.figure(figsize=(12, 8))\nplt.scatter(X_train&#91;:, 0], X_train&#91;:, 1], c=y_train,\n            cmap=plt.cm.colors.ListedColormap(&#91;azure, nugget_yellow]),\n            edgecolors=node_black, s=50, alpha=0.5, label=\"Clean Data Points\")\n\ncontour_colors = {0.0: htb_green, 0.10: aquamarine, 0.20: nugget_yellow,\n                  0.30: vivid_purple, 0.40: azure, 0.50: malware_red}\ncontour_linestyles = {0.0: \"solid\", 0.10: \"dashed\", 0.20: \"dashed\",\n                      0.30: \"dashed\", 0.40: \"dashed\", 0.50: \"dashed\"}\n\n# Baseline boundary\nZ_baseline = baseline_model.predict(mesh_points).reshape(xx.shape)\nplt.contour(xx, yy, Z_baseline, levels=&#91;0.5], colors=&#91;contour_colors&#91;0.0]],\n            linestyles=&#91;contour_linestyles&#91;0.0]], linewidths=&#91;2.5])\n\n# Poisoned boundaries\ndecision_boundaries_data.sort(key=lambda item: item&#91;\"percentage\"])\nplotted_percentages = &#91;0.0]\nfor data in decision_boundaries_data:\n    pp = data&#91;\"percentage\"]\n    plt.contour(xx, yy, data&#91;\"Z\"], levels=&#91;0.5], colors=&#91;contour_colors&#91;pp]],\n                linestyles=&#91;contour_linestyles&#91;pp]], linewidths=&#91;2.5])\n    plotted_percentages.append(pp)\n\nplt.title(\"Shift in Decision Boundary with Increasing Label Flipping\",\n          fontsize=16, color=htb_green)\nplt.xlabel(\"Feature 1\", fontsize=12)\nplt.ylabel(\"Feature 2\", fontsize=12)\n\nlegend_handles = &#91;plt.Line2D(&#91;0], &#91;0], color=contour_colors&#91;pp], lw=2.5,\n                             linestyle=contour_linestyles&#91;pp],\n                             label=f\"Boundary ({pp * 100:.0f}% Poisoned)\")\n                  for pp in sorted(plotted_percentages)]\ndata_handles = &#91;\n    plt.Line2D(&#91;0], &#91;0], marker=\"o\", color=\"w\", label=\"Class 0\", markersize=10,\n               markerfacecolor=azure, linestyle=\"None\"),\n    plt.Line2D(&#91;0], &#91;0], marker=\"o\", color=\"w\", label=\"Class 1\", markersize=10,\n               markerfacecolor=nugget_yellow, linestyle=\"None\"),\n]\nplt.legend(handles=legend_handles + data_handles, title=\"Boundaries &amp; Data\")\nplt.grid(True, color=hacker_grey, linestyle=\"--\", linewidth=0.5, alpha=0.3)\nplt.xlim(xx.min(), xx.max())\nplt.ylim(yy.min(), yy.max())\nplt.show()\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The overlay shows each boundary progressively rotating away from the baseline position as the model accommodates more poisoned samples. At 50%, the boundary has shifted far enough to start misclassifying test samples from the minority region. On noisier, real-world data where the classes already overlap, this kind of boundary migration would cause accuracy loss at much lower poisoning rates, potentially as low as 5-10% depending on the dataset.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This is the practical takeaway from random label flipping. Accuracy is a trailing indicator. The model&#8217;s internal representation is already degraded before the accuracy metric reflects it, and a defender who monitors only accuracy may not notice the drift until the boundary has moved far enough to produce visible misclassifications.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The next article covers the targeted variant of this attack, where labels are flipped only within a specific class to cause predictable misclassifications rather than general degradation.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Step-by-step label flipping attack walkthrough on a logistic regression classifier, evaluating accuracy degradation and decision boundary shift at 10% to 50%.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[640,630,635,642,868,644,662,726,738,869],"class_list":["post-570","post","type-post","status-publish","format-standard","hentry","category-security","tag-adversarial-ai","tag-ai-red-teaming","tag-data-poisoning","tag-decision-boundary","tag-label-flipping","tag-logistic-regression","tag-machine-learning-security","tag-python","tag-scikit-learn","tag-training-data-attacks"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 4.9.10 - aioseo.com -->\n\t<meta name=\"description\" content=\"Step-by-step label flipping attack walkthrough on a logistic regression classifier, evaluating accuracy degradation and decision boundary shift at 10% to 50%.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"KosokoKing\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/kosokoking.com\/index.php\/security\/executing-a-label-flipping-attack-on-a-classifier\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 4.9.10\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Kosokoking - 31337\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Executing a label flipping attack on a classifier - Kosokoking\" \/>\n\t\t<meta property=\"og:description\" content=\"Step-by-step label flipping attack walkthrough on a logistic regression classifier, evaluating accuracy degradation and decision boundary shift at 10% to 50%.\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/kosokoking.com\/index.php\/security\/executing-a-label-flipping-attack-on-a-classifier\/\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/kosokoking.com\/wp-content\/uploads\/2020\/08\/edited-personal-picture-scaled.jpg\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/kosokoking.com\/wp-content\/uploads\/2020\/08\/edited-personal-picture-scaled.jpg\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2026-07-22T23:00:00+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2026-07-18T13:38:37+00:00\" \/>\n\t\t<meta property=\"article:publisher\" content=\"https:\/\/facebook.com\/adeife\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:site\" content=\"@kosokoking\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Executing a label flipping attack on a classifier - Kosokoking\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Step-by-step label flipping attack walkthrough on a logistic regression classifier, evaluating accuracy degradation and decision boundary shift at 10% to 50%.\" \/>\n\t\t<meta name=\"twitter:creator\" content=\"@kosokoking\" \/>\n\t\t<meta name=\"twitter:image\" content=\"https:\/\/kosokoking.com\/wp-content\/uploads\/2020\/08\/edited-personal-picture-scaled.jpg\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"BlogPosting\",\"@id\":\"https:\\\/\\\/kosokoking.com\\\/index.php\\\/security\\\/executing-a-label-flipping-attack-on-a-classifier\\\/#blogposting\",\"name\":\"Executing a label flipping attack on a classifier - Kosokoking\",\"headline\":\"Executing a label flipping attack on a classifier\",\"author\":{\"@id\":\"https:\\\/\\\/kosokoking.com\\\/index.php\\\/author\\\/adeifekosokokinggmail-com\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/kosokoking.com\\\/#person\"},\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/kosokoking.com\\\/index.php\\\/security\\\/executing-a-label-flipping-attack-on-a-classifier\\\/#articleImage\",\"url\":\"https:\\\/\\\/kosokoking.com\\\/wp-content\\\/litespeed\\\/avatar\\\/7352636f37cc2ce2fad7b856df236dff.jpg?ver=1784707567\",\"width\":96,\"height\":96,\"caption\":\"KosokoKing\"},\"datePublished\":\"2026-07-23T00:00:00+01:00\",\"dateModified\":\"2026-07-18T14:38:37+01:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/kosokoking.com\\\/index.php\\\/security\\\/executing-a-label-flipping-attack-on-a-classifier\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/kosokoking.com\\\/index.php\\\/security\\\/executing-a-label-flipping-attack-on-a-classifier\\\/#webpage\"},\"articleSection\":\"Info. Sec., Adversarial AI, AI Red Teaming, Data Poisoning, Decision Boundary, Label Flipping, Logistic Regression, Machine Learning Security, Python, Scikit-learn, Training Data Attacks\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/kosokoking.com\\\/index.php\\\/security\\\/executing-a-label-flipping-attack-on-a-classifier\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/kosokoking.com#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/kosokoking.com\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/kosokoking.com\\\/index.php\\\/category\\\/security\\\/#listItem\",\"name\":\"Info. Sec.\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/kosokoking.com\\\/index.php\\\/category\\\/security\\\/#listItem\",\"position\":2,\"name\":\"Info. Sec.\",\"item\":\"https:\\\/\\\/kosokoking.com\\\/index.php\\\/category\\\/security\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/kosokoking.com\\\/index.php\\\/security\\\/executing-a-label-flipping-attack-on-a-classifier\\\/#listItem\",\"name\":\"Executing a label flipping attack on a classifier\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/kosokoking.com#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/kosokoking.com\\\/index.php\\\/security\\\/executing-a-label-flipping-attack-on-a-classifier\\\/#listItem\",\"position\":3,\"name\":\"Executing a label flipping attack on a classifier\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/kosokoking.com\\\/index.php\\\/category\\\/security\\\/#listItem\",\"name\":\"Info. Sec.\"}}]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/kosokoking.com\\\/#person\",\"name\":\"KosokoKing\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/kosokoking.com\\\/index.php\\\/security\\\/executing-a-label-flipping-attack-on-a-classifier\\\/#personImage\",\"url\":\"https:\\\/\\\/kosokoking.com\\\/wp-content\\\/litespeed\\\/avatar\\\/7352636f37cc2ce2fad7b856df236dff.jpg?ver=1784707567\",\"width\":96,\"height\":96,\"caption\":\"KosokoKing\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/kosokoking.com\\\/index.php\\\/author\\\/adeifekosokokinggmail-com\\\/#author\",\"url\":\"https:\\\/\\\/kosokoking.com\\\/index.php\\\/author\\\/adeifekosokokinggmail-com\\\/\",\"name\":\"KosokoKing\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/kosokoking.com\\\/index.php\\\/security\\\/executing-a-label-flipping-attack-on-a-classifier\\\/#authorImage\",\"url\":\"https:\\\/\\\/kosokoking.com\\\/wp-content\\\/litespeed\\\/avatar\\\/7352636f37cc2ce2fad7b856df236dff.jpg?ver=1784707567\",\"width\":96,\"height\":96,\"caption\":\"KosokoKing\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/kosokoking.com\\\/index.php\\\/security\\\/executing-a-label-flipping-attack-on-a-classifier\\\/#webpage\",\"url\":\"https:\\\/\\\/kosokoking.com\\\/index.php\\\/security\\\/executing-a-label-flipping-attack-on-a-classifier\\\/\",\"name\":\"Executing a label flipping attack on a classifier - Kosokoking\",\"description\":\"Step-by-step label flipping attack walkthrough on a logistic regression classifier, evaluating accuracy degradation and decision boundary shift at 10% to 50%.\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/kosokoking.com\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/kosokoking.com\\\/index.php\\\/security\\\/executing-a-label-flipping-attack-on-a-classifier\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/kosokoking.com\\\/index.php\\\/author\\\/adeifekosokokinggmail-com\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/kosokoking.com\\\/index.php\\\/author\\\/adeifekosokokinggmail-com\\\/#author\"},\"datePublished\":\"2026-07-23T00:00:00+01:00\",\"dateModified\":\"2026-07-18T14:38:37+01:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/kosokoking.com\\\/#website\",\"url\":\"https:\\\/\\\/kosokoking.com\\\/\",\"name\":\"Kosokoking\",\"description\":\"31337\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/kosokoking.com\\\/#person\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Executing a label flipping attack on a classifier - Kosokoking","description":"Step-by-step label flipping attack walkthrough on a logistic regression classifier, evaluating accuracy degradation and decision boundary shift at 10% to 50%.","canonical_url":"https:\/\/kosokoking.com\/index.php\/security\/executing-a-label-flipping-attack-on-a-classifier\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"BlogPosting","@id":"https:\/\/kosokoking.com\/index.php\/security\/executing-a-label-flipping-attack-on-a-classifier\/#blogposting","name":"Executing a label flipping attack on a classifier - Kosokoking","headline":"Executing a label flipping attack on a classifier","author":{"@id":"https:\/\/kosokoking.com\/index.php\/author\/adeifekosokokinggmail-com\/#author"},"publisher":{"@id":"https:\/\/kosokoking.com\/#person"},"image":{"@type":"ImageObject","@id":"https:\/\/kosokoking.com\/index.php\/security\/executing-a-label-flipping-attack-on-a-classifier\/#articleImage","url":"https:\/\/kosokoking.com\/wp-content\/litespeed\/avatar\/7352636f37cc2ce2fad7b856df236dff.jpg?ver=1784707567","width":96,"height":96,"caption":"KosokoKing"},"datePublished":"2026-07-23T00:00:00+01:00","dateModified":"2026-07-18T14:38:37+01:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/kosokoking.com\/index.php\/security\/executing-a-label-flipping-attack-on-a-classifier\/#webpage"},"isPartOf":{"@id":"https:\/\/kosokoking.com\/index.php\/security\/executing-a-label-flipping-attack-on-a-classifier\/#webpage"},"articleSection":"Info. Sec., Adversarial AI, AI Red Teaming, Data Poisoning, Decision Boundary, Label Flipping, Logistic Regression, Machine Learning Security, Python, Scikit-learn, Training Data Attacks"},{"@type":"BreadcrumbList","@id":"https:\/\/kosokoking.com\/index.php\/security\/executing-a-label-flipping-attack-on-a-classifier\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/kosokoking.com#listItem","position":1,"name":"Home","item":"https:\/\/kosokoking.com","nextItem":{"@type":"ListItem","@id":"https:\/\/kosokoking.com\/index.php\/category\/security\/#listItem","name":"Info. Sec."}},{"@type":"ListItem","@id":"https:\/\/kosokoking.com\/index.php\/category\/security\/#listItem","position":2,"name":"Info. Sec.","item":"https:\/\/kosokoking.com\/index.php\/category\/security\/","nextItem":{"@type":"ListItem","@id":"https:\/\/kosokoking.com\/index.php\/security\/executing-a-label-flipping-attack-on-a-classifier\/#listItem","name":"Executing a label flipping attack on a classifier"},"previousItem":{"@type":"ListItem","@id":"https:\/\/kosokoking.com#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/kosokoking.com\/index.php\/security\/executing-a-label-flipping-attack-on-a-classifier\/#listItem","position":3,"name":"Executing a label flipping attack on a classifier","previousItem":{"@type":"ListItem","@id":"https:\/\/kosokoking.com\/index.php\/category\/security\/#listItem","name":"Info. Sec."}}]},{"@type":"Person","@id":"https:\/\/kosokoking.com\/#person","name":"KosokoKing","image":{"@type":"ImageObject","@id":"https:\/\/kosokoking.com\/index.php\/security\/executing-a-label-flipping-attack-on-a-classifier\/#personImage","url":"https:\/\/kosokoking.com\/wp-content\/litespeed\/avatar\/7352636f37cc2ce2fad7b856df236dff.jpg?ver=1784707567","width":96,"height":96,"caption":"KosokoKing"}},{"@type":"Person","@id":"https:\/\/kosokoking.com\/index.php\/author\/adeifekosokokinggmail-com\/#author","url":"https:\/\/kosokoking.com\/index.php\/author\/adeifekosokokinggmail-com\/","name":"KosokoKing","image":{"@type":"ImageObject","@id":"https:\/\/kosokoking.com\/index.php\/security\/executing-a-label-flipping-attack-on-a-classifier\/#authorImage","url":"https:\/\/kosokoking.com\/wp-content\/litespeed\/avatar\/7352636f37cc2ce2fad7b856df236dff.jpg?ver=1784707567","width":96,"height":96,"caption":"KosokoKing"}},{"@type":"WebPage","@id":"https:\/\/kosokoking.com\/index.php\/security\/executing-a-label-flipping-attack-on-a-classifier\/#webpage","url":"https:\/\/kosokoking.com\/index.php\/security\/executing-a-label-flipping-attack-on-a-classifier\/","name":"Executing a label flipping attack on a classifier - Kosokoking","description":"Step-by-step label flipping attack walkthrough on a logistic regression classifier, evaluating accuracy degradation and decision boundary shift at 10% to 50%.","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/kosokoking.com\/#website"},"breadcrumb":{"@id":"https:\/\/kosokoking.com\/index.php\/security\/executing-a-label-flipping-attack-on-a-classifier\/#breadcrumblist"},"author":{"@id":"https:\/\/kosokoking.com\/index.php\/author\/adeifekosokokinggmail-com\/#author"},"creator":{"@id":"https:\/\/kosokoking.com\/index.php\/author\/adeifekosokokinggmail-com\/#author"},"datePublished":"2026-07-23T00:00:00+01:00","dateModified":"2026-07-18T14:38:37+01:00"},{"@type":"WebSite","@id":"https:\/\/kosokoking.com\/#website","url":"https:\/\/kosokoking.com\/","name":"Kosokoking","description":"31337","inLanguage":"en-US","publisher":{"@id":"https:\/\/kosokoking.com\/#person"}}]},"og:locale":"en_US","og:site_name":"Kosokoking - 31337","og:type":"article","og:title":"Executing a label flipping attack on a classifier - Kosokoking","og:description":"Step-by-step label flipping attack walkthrough on a logistic regression classifier, evaluating accuracy degradation and decision boundary shift at 10% to 50%.","og:url":"https:\/\/kosokoking.com\/index.php\/security\/executing-a-label-flipping-attack-on-a-classifier\/","og:image":"https:\/\/kosokoking.com\/wp-content\/uploads\/2020\/08\/edited-personal-picture-scaled.jpg","og:image:secure_url":"https:\/\/kosokoking.com\/wp-content\/uploads\/2020\/08\/edited-personal-picture-scaled.jpg","article:published_time":"2026-07-22T23:00:00+00:00","article:modified_time":"2026-07-18T13:38:37+00:00","article:publisher":"https:\/\/facebook.com\/adeife","twitter:card":"summary","twitter:site":"@kosokoking","twitter:title":"Executing a label flipping attack on a classifier - Kosokoking","twitter:description":"Step-by-step label flipping attack walkthrough on a logistic regression classifier, evaluating accuracy degradation and decision boundary shift at 10% to 50%.","twitter:creator":"@kosokoking","twitter:image":"https:\/\/kosokoking.com\/wp-content\/uploads\/2020\/08\/edited-personal-picture-scaled.jpg"},"aioseo_meta_data":{"post_id":"570","title":null,"description":null,"keywords":null,"keyphrases":{"focus":{"keyphrase":"flipping","score":85,"analysis":{"keyphraseInTitle":{"score":9,"maxScore":9,"error":0},"keyphraseInDescription":{"score":9,"maxScore":9,"error":0},"keyphraseLength":{"score":9,"maxScore":9,"error":0,"length":1},"keyphraseInURL":{"score":5,"maxScore":5,"error":0},"keyphraseInIntroduction":{"score":9,"maxScore":9,"error":0},"keyphraseInSubHeadings":{"score":9,"maxScore":9,"error":0},"keyphraseInImageAlt":[],"keywordDensity":{"score":0,"type":"low","maxScore":9,"error":1}}},"additional":[]},"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":"","og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"BlogPosting","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":"-1","robots_max_videopreview":"-1","robots_max_imagepreview":"large","priority":null,"frequency":"default","local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":{"faqs":[],"keyPoints":[],"schemas":[],"titles":[],"descriptions":[],"socialPosts":{"email":{"subject":"","preview":"","content":""},"linkedin":[],"twitter":[],"facebook":[],"instagram":[]}},"created":"2026-07-18 13:38:38","updated":"2026-07-22 23:18:20","seo_analyzer_scan_date":null},"_links":{"self":[{"href":"https:\/\/kosokoking.com\/index.php\/wp-json\/wp\/v2\/posts\/570","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kosokoking.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kosokoking.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kosokoking.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kosokoking.com\/index.php\/wp-json\/wp\/v2\/comments?post=570"}],"version-history":[{"count":1,"href":"https:\/\/kosokoking.com\/index.php\/wp-json\/wp\/v2\/posts\/570\/revisions"}],"predecessor-version":[{"id":571,"href":"https:\/\/kosokoking.com\/index.php\/wp-json\/wp\/v2\/posts\/570\/revisions\/571"}],"wp:attachment":[{"href":"https:\/\/kosokoking.com\/index.php\/wp-json\/wp\/v2\/media?parent=570"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kosokoking.com\/index.php\/wp-json\/wp\/v2\/categories?post=570"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kosokoking.com\/index.php\/wp-json\/wp\/v2\/tags?post=570"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}