Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 31 additions & 43 deletions PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,90 +8,78 @@ Closes #

## Task Summary

Provide a brief overview of your implementation.

- What did you implement?
- What approach did you follow?
- **What did you implement?** Implemented an unsupervised anomaly detection system using the Isolation Forest algorithm to flag anomalous shuttle flights.
- **What approach did you follow?** Followed an experimental approach: established a baseline with default parameters, analyzed the see-saw trade-off between Precision and Recall by adjusting strictness parameters, tested feature scaling, and ultimately executed an automated Grid Search to locate the optimal safety configuration.

---

## Dataset

- [ ] Mammography
- [ ] Shuttle
- [x] Shuttle

Dataset Source:

---

## Preprocessing

Describe any preprocessing performed.

Examples:
- Missing value handling
- Feature scaling
- Encoding
- Feature selection
- There were no missing values in the dataset.
- **Feature Scaling Evaluation:** We integrated data standardization using `StandardScaler` to evaluate the model's sensitivity to feature magnitudes. The experiments successfully validated that the Isolation Forest algorithm is inherently scale-invariant. Because the model relies on recursive, axis-aligned isolation trees rather than geometric distance metrics, scaling preserves the exact relative separation paths of the anomalies. This is an exceptional characteristic for our pipeline, as it proves the model achieves peak predictive performance with reduced preprocessing overhead.

---

## Model Configuration

List the important hyperparameters used.
*(For best "Safety-First" model)*

| Hyperparameter | Value |
|---------------|-------|
| n_estimators | |
| contamination | |
| max_samples | |
| max_features | |
| random_state | |
| n_estimators | 100 |
| contamination | 0.50 |
| max_samples | 256 |
| max_features | 1.0 |
| random_state | 42 |

---

## Evaluation Results

| Metric | Value |
|--------|-------|
| Precision | |
| Recall | |
| F1-score | |
| ROC-AUC (Optional) | |
| Precision | 0.40 |
| Recall | 0.94 |
| F1-score | 0.56 |


---

## Visualizations

Attach **at least 2 plots** from your analysis.
**Confusion Matrix — Best Safety Model**

Examples:
- PCA visualization
- Anomaly score distribution
- Confusion Matrix
- Correlation heatmap
- Feature distributions
- Hyperparameter comparison
- Precision/Recall/F1 comparison
![Confusion Matrix](./confusion_matrix.png)

**Impact of Contamination Threshold on Anomaly Recall**

![Hyperparameter Impact](./hyperparameter_impact.png)

---

## Key Observations

Briefly summarize:

- What worked well?
- Which hyperparameter had the biggest impact?
- Any interesting findings?
- Challenges faced (if any)
- **What worked well?** Increasing the `contamination` parameter significantly expanded the classification envelope, maximizing our Recall to 0.94 (catching 94% of shuttle system anomalies).
- **Which hyperparameter had the biggest impact?** `contamination` had the absolute biggest impact on shifting the see-saw balance between precision and recall.
- **Any interesting findings?** Increasing `n_estimators` beyond 200–300 resulted in diminishing returns and minor score degradation due to algorithmic plateauing. Furthermore, setting `contamination` too high combined with tiny sample sizes caused "swamping," where normal data points overwhelmed the trees' ability to isolate actual anomalies.
- **Challenges faced:** Overcoming short-term memory clears when switching kernel environments in VS Code, requiring structured notebook tracking.

---

## Checklist

- [ ] Code runs successfully
- [ ] Notebook (`.ipynb`) included
- [ ] Code is well-commented
- [ ] README/documentation updated
- [ ] At least **2 plots** included
- [ ] PR is linked to the corresponding issue
- [x] Code runs successfully
- [x] Notebook (`.ipynb`) included
- [x] Code is well-commented
- [x] README/documentation updated
- [x] At least **2 plots** included
- [x] PR is linked to the corresponding issue
123 changes: 113 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,118 @@
# CogniOS – Tasks
DIFFERENT CASES USED
1-
iso_forest = IsolationForest(
contamination =0.4,
max_samples = 256,
random_state=42,
max_features = 1.0 ,
n_estimators = 120)

This branch contains tasks designed to help contributors learn the concepts and technologies used in CogniOS before contributing to the main project.
Classification Report:
precision recall f1-score support

## Workflow
-1 0.45 0.84 0.59 12414
1 0.94 0.72 0.82 45586

1. Check your assigned GitHub issue.
2. Create a new branch from `Tasks`.
3. Complete the assigned task.
4. Open a Pull Request **to the `Tasks` branch**.
5. Mention `Closes #<issue_number>` in your PR description.
2-
iso_forest = IsolationForest(
contamination =0.4,
max_samples = 400,
random_state=42,
max_features = 1.0 ,
n_estimators = 200)

Please follow the repository's Pull Request template while submitting your solution.
Classification Report:
precision recall f1-score support

Happy learning!
-1 0.43 0.81 0.56 12414
1 0.93 0.71 0.81 45586


3-(using standard values)
iso_forest = IsolationForest(
contamination =0.4,
max_samples = 256,
random_state=42,
max_features = 1.0 ,
n_estimators = 100)

Classification Report:
precision recall f1-score support

-1 0.46 0.86 0.60 12414
1 0.95 0.73 0.82 45586


4-(assuming most amount of contamination)
(most recall obtained)
iso_forest = IsolationForest(
contamination =0.5,
max_samples = 256,
random_state=42,
max_features = 1.0 ,
n_estimators = 100)

Classification Report:
precision recall f1-score support

-1 0.40 0.94 0.56 12414
1 0.97 0.62 0.76 45586

5 - (actual amount of contamination)
iso_forest = IsolationForest(
contamination =0.21,
max_samples = 256,
random_state=42,
max_features = 1.0 ,
n_estimators = 100)

Classification Report:
precision recall f1-score support

-1 0.54 0.53 0.54 12414
1 0.87 0.88 0.88 45586


6 - (inc no of trres anfd reducing samples )

iso_forest = IsolationForest(
contamination =0.5,
max_samples = 100,
random_state=42,
max_features = 1.0 ,
n_estimators = 400)

Classification Report:
precision recall f1-score support

-1 0.37 0.86 0.52 12414
1 0.94 0.60 0.73 45586

7-

iso_forest = IsolationForest(
contamination =0.5,
max_samples = 50,
random_state=42,
max_features = 1.0 ,
n_estimators = 290)

precision recall f1-score support

-1 0.38 0.89 0.53 12414
1 0.95 0.61 0.74 45586


8 --
contamination =0.5,
max_samples = 50,
random_state=42,
max_features = 1.0 ,
n_estimators = 400)

Classification Report:
precision recall f1-score support

-1 0.38 0.88 0.53 12414
1 0.95 0.60 0.74 45586

Binary file added images/confusion_matrix.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/hyperparameter_impact.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading