AI Feasibility Predictor Case Study

  Shuja ur Rahman     17 November 2024       Share

Developing an AI Integration Feasibility Analyzer: Detailed Guide to the Gradient Boosting Classifier Model

The adoption of Artificial Intelligence (AI) in businesses is growing rapidly. To aid decision-makers, I developed an AI Integration Feasibility Analyzer that predicts whether integrating AI will be beneficial for a business based on key parameters such as revenue, workforce skills, and operational efficiency. This model uses a Gradient Boosting Classifier to deliver accurate predictions.

In this article, I’ll detail the steps taken to develop, train, and evaluate the model, explain the algorithms and techniques used, and discuss the pros, cons, and future possibilities.


Image

1. Problem Statement

The objective was to predict whether integrating AI into a business will be beneficial or not based on various factors like:

  • Financial health (annual revenue, current tech investments).
  • Operational metrics (customer satisfaction, operational efficiency).
  • Workforce characteristics (skill level, workforce size).

A binary classification model was built to solve this problem, with labels:

  • 0: Not Beneficial
  • 1: Beneficial

Image

2. Dataset Overview

2.1 Data Source

The dataset used for this project was stored on Google Drive, containing structured business data with the following features:

  • Categorical Features:
    • business_type: Type of business (e.g., retail, tech, healthcare).
    • complexity_level: Operational complexity.
    • data_availability: Availability of historical data.
  • Numerical Features:
    • annual_revenue: Annual revenue of the business.
    • employee_count: Number of employees.
    • current_tech_investment: Current investment in technology.
    • customer_satisfaction: Average satisfaction score.
    • operational_efficiency: Efficiency score.
    • workforce_skill_level: Average skill level of employees.
    • ai_integration_cost: Estimated cost of AI integration.
    • potential_improvement: Projected improvement in operations post-AI integration.
  • Target Variable:
    • ai_beneficial: Binary variable indicating AI’s benefit.

Image

3. Steps for Model Development

3.1 Preprocessing the Data

Image

Handling Categorical Features

Categorical features were encoded using Label Encoding. Each category was transformed into numerical values to be understood by the Gradient Boosting Classifier.

from sklearn.preprocessing import LabelEncoder

label_encoders = {}
categorical_features = ['business_type', 'complexity_level', 'data_availability']

for column in categorical_features:
    le = LabelEncoder()
    df[column] = le.fit_transform(df[column])
    label_encoders[column] = le

Scaling Numerical Features

Numerical features were standardized using StandardScaler to ensure uniformity across different ranges of values.

from sklearn.preprocessing import StandardScaler

scaler = StandardScaler()
numeric_features = ['annual_revenue', 'employee_count', 'current_tech_investment',
                    'customer_satisfaction', 'operational_efficiency',
                    'workforce_skill_level', 'ai_integration_cost', 'potential_improvement']

df[numeric_features] = scaler.fit_transform(df[numeric_features])

3.2 Splitting Data

The dataset was split into training and testing sets (80%-20%) to evaluate the model’s performance on unseen data.

from sklearn.model_selection import train_test_split

X = df.drop('ai_beneficial', axis=1)
y = df['ai_beneficial']
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

4. Model Selection and Training

4.1 Why Gradient Boosting Classifier?

Gradient Boosting Classifier was chosen for its ability to:

  • Handle both numerical and categorical data.
  • Build strong predictive models by combining weak learners.
  • Reduce bias and variance effectively.

4.2 Training the Model

from sklearn.ensemble import GradientBoostingClassifier

model = GradientBoostingClassifier(random_state=42)
model.fit(X_train, y_train)

5. Model Evaluation

5.1 Classification Report

The classification report provided precision, recall, F1-score, and support for each class.

from sklearn.metrics import classification_report

y_pred = model.predict(X_test)
print(classification_report(y_test, y_pred))

Image

5.2 Confusion Matrix

The confusion matrix highlighted the number of correct and incorrect predictions.

from sklearn.metrics import confusion_matrix
import seaborn as sns
import matplotlib.pyplot as plt

conf_matrix = confusion_matrix(y_test, y_pred)
sns.heatmap(conf_matrix, annot=True, fmt="d", cmap="Blues",
            xticklabels=["Not Beneficial", "Beneficial"],
            yticklabels=["Not Beneficial", "Beneficial"])
plt.title("Confusion Matrix")
plt.xlabel("Predicted")
plt.ylabel("Actual")
plt.show()

Image

5.3 ROC Curve and AUC

The ROC Curve and AUC Score measured the model’s ability to distinguish between classes.

from sklearn.metrics import roc_auc_score, roc_curve

y_proba = model.predict_proba(X_test)[:, 1]
roc_auc = roc_auc_score(y_test, y_proba)
fpr, tpr, thresholds = roc_curve(y_test, y_proba)

plt.plot(fpr, tpr, label=f'ROC Curve (AUC = {roc_auc:.2f})')
plt.plot([0, 1], [0, 1], 'k--')
plt.xlabel('False Positive Rate')
plt.ylabel('True Positive Rate')
plt.title('ROC Curve')
plt.legend(loc="lower right")
plt.show()

Image Image

6. Feature Importance and Interpretability

6.1 Feature Importance Plot

Feature importance values indicated which features contributed most to the model’s predictions.

feature_importance = model.feature_importances_
importance_df = pd.DataFrame({'Feature': X.columns, 'Importance': feature_importance}).sort_values(by='Importance', ascending=False)

sns.barplot(x='Importance', y='Feature', data=importance_df)
plt.title("Feature Importance")
plt.show()

6.2 SHAP Values

SHAP values were used to explain individual predictions and visualize feature contributions.

import shap

explainer = shap.TreeExplainer(model)
shap_values = explainer.shap_values(X_test)

shap.summary_plot(shap_values, X_test, plot_type="bar", feature_names=X.columns)
for feature in importance_df['Feature'][:5]:
    shap.dependence_plot(feature, shap_values, X_test, feature_names=X.columns)

7. Saving and Exporting the Model

The trained model, scaler, and encoders were saved for deployment.

import joblib

joblib.dump(model, '/content/drive/My Drive/ML_Models/weights/model.joblib')
joblib.dump(scaler, '/content/drive/My Drive/ML_Models/weights/scaler.joblib')
joblib.dump(label_encoders, '/content/drive/My Drive/ML_Models/weights/label_encoders.joblib')

Image

8. Pros and Cons

Pros

  • Accuracy: High precision and recall.
  • Interpretability: SHAP values enabled insights into feature contributions.
  • Robustness: Gradient Boosting handles noisy data and outliers effectively.

Cons

  • Training Time: Gradient Boosting can be slower compared to simpler models.
  • Complexity: Requires careful hyperparameter tuning for optimal performance.

Image

9. Conclusion

The AI Integration Feasibility Analyzer provides a reliable prediction system for businesses exploring AI adoption. The model’s accuracy, interpretability, and feature importance insights make it an invaluable decision-making tool. Future work could involve integrating deep learning for complex feature interactions and deploying the model as a web-based API for real-time predictions.

Fork the repo on Github


                                       

Table of Contents