CHAPTER 9
Anti-Ethical Practice: Obfuscation and Black Box Design
Overview
The anti-ethical developer, often driven by an understandable desire to protect proprietary algorithms or to hide discriminatory practices, will engage in obfuscation—the intentional act of making the model's operation opaque and difficult to audit.
This violates the core principle of transparency and exposes the organization to significant ethical and legal liabilities.
Obfuscation tactics
Unnecessarily complex models: Choosing a deep, complex neural network when a simpler, more interpretable model (like a linear regression or decision tree) would suffice. The complexity is used as a shield against scrutiny.
Proprietary feature hashing: Using nonreversible feature transformations or proprietary feature names that make it impossible for an external auditor or end-user to understand the input variables.
Explanation suppression: Deploying the model without any XAI framework, or providing only vague, non-actionable explanations (such as "The model determined your profile was a poor fit.").
Poor documentation: Failing to create or maintain model cards and data sheets, thereby erasing the audit trail and preventing future developers from understanding the model's ethical limitations.
Building an unnecessarily opaque model
This anti-ethical example demonstrates how a developer can intentionally choose a complex model and suppress the necessary information for interpretation, effectively creating a "black box" that is difficult to audit.
Code Listing 9-a: Opaque model example (opaque-model.py)
import pandas as pd from sklearn.model_selection import train_test_split from sklearn.neural_network import MLPClassifier # Multi-Layer Perceptron # (Opaque) – a.k.a. neural network classifier. from sklearn.preprocessing import StandardScaler import numpy as np # --- Intentional Obfuscation --- # 1. Create a simple dataset where a linear model would work perfectly. data = { 'Feature_1': np.random.rand(100) * 10, 'Feature_2': np.random.rand(100) * 10, 'Target': ((np.random.rand(100) * 10 + np.random.rand(100) * 10) > 10).astype(int) } df = pd.DataFrame(data) X = df[['Feature_1', 'Feature_2']] y = df['Target'] X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) # 2. Anti-Ethical Step: Choose an unnecessarily complex model (MLP). # A simple logistic regression would be fully transparent and sufficient. # The MLP is chosen for its opacity. scaler = StandardScaler() X_train_scaled = scaler.fit_transform(X_train) X_test_scaled = scaler.transform(X_test) model_opaque = MLPClassifier( hidden_layer_sizes=(50, 50, 50), # Deep, complex structure max_iter=500, random_state=42 ) model_opaque.fit(X_train_scaled, y_train) # 3. Anti-Ethical Step: Suppress explanation. # The developer deploys the model with only the prediction function. def opaque_predict(input_data): """ A function that returns only the prediction, with no explanation or confidence score. """ # The prediction is made on the scaled data, which is not # exposed to the user. input_scaled = scaler.transform(input_data) prediction = model_opaque.predict(input_scaled)[0] return {"prediction": int(prediction)} # Example usage sample_input = X_test.iloc[[0]] result = opaque_predict(sample_input) print("--- Anti-Ethical Outcome Analysis ---") print(f"Prediction Result: {result}") # Anti-Ethical Comment: print("\n[ANTI-ETHICAL RESULT]: The model is a complex, multi-layer perceptron (MLP) " "that is difficult to interpret, even though the underlying problem is simple. " "The deployment function 'opaque_predict' intentionally returns only the final " "prediction, suppressing confidence scores, feature contributions, or any " "other form of explanation. This makes auditing the model's logic for bias " "or error virtually impossible for an external party.") |
This code illustrates an anti-ethical practice of intentional obfuscation in ML. It first creates a simple, linearly separable dataset for which a transparent model (such as logistic regression) would be sufficient and easy to explain. Instead, the developer deliberately chooses a complex, opaque neural network (a multilayer perceptron, or MLP) with multiple hidden layers, making the model hard to interpret despite the problem's simplicity.
In simple terms, an MLP is a type of artificial neural network made up of:
· An input layer: Receives the feature values.
· One or more hidden layers: Perform nonlinear transformations.
· An output layer: Produces the final prediction.
The data is scaled and used to train the MLP, further increasing opacity. In deployment, the opaque_predict function returns only the final prediction, hiding the preprocessing steps, confidence scores, and any explanation of how the decision was made.
The result is a system that produces outputs that look correct, but are neither auditable nor explainable, preventing users or regulators from understanding, challenging, or detecting bias or errors—highlighting a clear example of unethical model design and deployment.
Now, let’s run the code with the command py opaque-model.py from the terminal in VS Code.
Code Listing 9-b: Opaque model example execution
C:\PERSONAL-DATA\Projects\Books\Ethical AI Code\venv\Lib\site-packages\sklearn\neural_network\_multilayer_perceptron.py:785: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (500) reached and the optimization hasn't converged yet. warnings.warn( --- Anti-Ethical Outcome Analysis --- Prediction Result: {'prediction': 1} [ANTI-ETHICAL RESULT]: The model is a complex, multi-layer perceptron (MLP) that is difficult to interpret, even though the underlying problem is simple. The deployment function 'opaque_predict' intentionally returns only the final prediction, suppressing confidence scores, feature contributions, or any other form of explanation. This makes auditing the model's logic for bias or error virtually impossible for an external party. |
This execution highlights both a technical warning and an ethical failure by design.
First, the ConvergenceWarning indicates that the neural network training process did not fully converge within the allowed 500 iterations. This means the optimizer stopped before finding a stable minimum of the loss function, so that the learned model parameters may be suboptimal or unstable. While the model still produces predictions, reliability is uncertain—especially problematic when no diagnostics or confidence information are exposed.
Next, the script prints the prediction result: {'prediction': 1}. This is the only output returned by the deployed opaque_predict function. No probability, confidence score, or reasoning accompanies the decision.
The final message explains the anti-ethical implications of this setup. A highly complex and opaque MLP is used even though the task is simple, and the deployment interface deliberately hides all explanatory signals.
Recap
Combined with the convergence warning, this means:
· The model may not even be well-trained.
· Users have no way to detect instability, bias, or errors.
· Auditors and stakeholders cannot meaningfully challenge or understand the decision.
Overall, the execution demonstrates how technical opacity plus suppressed transparency can create a system that appears functional but is untrustworthy and unsuitable—which is precisely why this pattern is considered an anti-ethical AI practice.
- 1800+ high-performance UI components.
- Includes popular controls such as Grid, Chart, Scheduler, and more.
- 24x5 unlimited support by developers.