The main objective of this project is to predict whether a tumor is benign or malignant using machine learning models and explain the model’s decisions using LIME (Local Interpretable Model-Agnostic Explanations). The dataset used in this project is the Breast Cancer Dataset available from Kaggle.
- Source: Kaggle
- Dataset URL: Breast Cancer Dataset
- The dataset contains features related to the physical characteristics of the tumor and the target variable is diagnosis, where:
- 1 represents Malignant
- 0 represents Benign
The dataset consists of 30 features, each representing a different attribute of the tumor, such as the radius, texture, perimeter, area, and smoothness. These features are used to predict whether a tumor is malignant or benign. In addition to building a predictive model, we employ LIME (Local Interpretable Model-agnostic Explanations) to explain individual predictions, enhancing the interpretability of the model.
- Set up the Kaggle API for dataset download using the following code:
- Loaded the dataset into a pandas dataframe and analyzed its structure.
- Checked for missing values, data types, and duplicated rows.
- Visualized the distribution of diagnosis values.
- Converted categorical values (
diagnosis) to numerical values, where 1 indicates Malignant and 0 indicates Benign. - Applied one-hot encoding for categorical columns.
- Split the data into training and testing sets using an 80-20 ratio.
- Implemented a Decision Tree Classifier for the initial classification task.
- Trained the model using the training set (
X_train,y_train) and evaluated its accuracy on the test set (X_test,y_test).
- Applied LIME to explain individual predictions of the decision tree model.
- Generated explanations for test instances, which highlight how each feature contributes to the prediction of whether a tumor is benign or malignant.
- Evaluated the model’s performance using accuracy, confusion matrix, and classification report metrics.
- Used LIME to interpret and explain the model’s predictions for individual cases.
- Decision Tree Classifier: A tree-based model used for classification of tumors based on their features.
- LIME (Local Interpretable Model-Agnostic Explanations): Used to explain predictions of the machine learning model by generating interpretable explanations for individual instances.
- Pandas: For data manipulation.
- Numpy: For numerical computations.
- Scikit-learn: For building and evaluating the machine learning model.
- LIME: For generating explanations for the machine learning model’s predictions.
- Matplotlib & Seaborn: For data visualization.
This project provides insights into:
- How to build a decision tree model to predict whether a tumor is benign or malignant.
- The application of LIME to explain individual predictions and understand the decision-making process of the model.
- Visualizing and interpreting the effect of different features on the predictions.