Understanding Confusion Matrix and Data Types
Confusion Matrix
A confusion matrix is an N x N matrix used for evaluating the performance of a classification model, where N is the total number of target classes. The matrix compares the actual target values with those predicted by the machine learning model. The target variable has two values: Positive or Negative.
The columns represent the actual values of the target variable. The rows represent the predicted values of the target variable.
Confusion Matrix Elements
- True Positive (TP): The predicted value matches the actual value. The actual value was positive, and the model predicted a positive value.
- True Negative (TN): The actual value was negative, and the model predicted a negative value.
- False Positive (FP) – Type I Error: The predicted value was falsely predicted. The actual value was negative, but the model predicted a positive value. Also known as the type I error.
- False Negative (FN) – Type II Error: The predicted value was falsely predicted. The actual value was positive, but the model predicted a negative value. Also known as the type II error.
Machine Learning Activities
- Input Data: The dataset used for training the model, which includes features (inputs) and sometimes labels (outputs). It can come in different formats like images, text, or numerical data, and is the foundation for machine learning.
- Preparing to Model: Pre-processing data to make it ready for modeling. This includes cleaning (removing noise or errors), scaling (normalizing data), splitting into training and testing sets.
- Learning: The stage where the machine learning algorithm processes the training data to learn patterns. The model adjusts its parameters (e.g., weights in neural networks) to minimize error and improve predictions based on optimization techniques.
- Performance Evaluation: After training, the model’s performance is assessed on unseen test data.
- Performance Improvement: Refining the model to boost performance. This can include tuning hyperparameters, trying different algorithms, adding more data, or using techniques like cross-validation to reduce overfitting.
Data Types
Qualitative Data
Qualitative data refers to descriptive information that explains characteristics or qualities and cannot be measured numerically. It is often used to categorize or label things. For example, data like colors (red, blue), or types of food (pizza, pasta) are qualitative.
- Nominal Data: Categories without a specific order (e.g., colors, gender).
- Ordinal Data: Categories with a meaningful order (e.g., satisfaction levels: poor, fair, good).
Quantitative Data
Quantitative data is numerical and measures quantities. It answers questions like “How much?” or “How many?” and is useful for calculations. Examples include height (5 feet), or age (25 years).
- Interval Data: Numerical data with a meaningful order and equal intervals between values, but no true zero. For example, temperature in Celsius or IQ scores. Zero doesn’t mean “none.”
- Ratio Data: Similar to interval data but with a true zero point, meaning zero represents “none.” For example, height, weight, or time, where zero means the absence of the measurement.
Performance Metrics
- Accuracy: (TP + TN) / (TP + TN + FP + FN)
- Error Rate: (FP + FN) / (TP + TN + FP + FN)
- Error Rate: 1 – Model Accuracy
- Sensitivity: TP / (TP + FN)
- Specificity: TN / (TN + FP)
- Precision: TP / (TP + FP)
- Recall: TP / (TP + FN)
- F1 Score: 2 * (precision * recall) / (precision + recall)