Skip to content

Assignment 2 - #2

Open
alf-99 wants to merge 2 commits into
mainfrom
assignment-2
Open

Assignment 2#2
alf-99 wants to merge 2 commits into
mainfrom
assignment-2

Conversation

@alf-99

@alf-99 alf-99 commented Jan 26, 2026

Copy link
Copy Markdown
Owner

What changes are you trying to make? (e.g. Adding or removing code, refactoring existing code, adding reports)

I completed Assignment 2 on forest fire prediction. The main changes were:
-Loading and preprocessing the forest fire dataset (13 features, 517 samples).
-Creating two different preprocessing pipelines (simple scaling vs scaling + log transform).
-Building four model combinations: LinearRegression + kNN + RandomForest with both preprocessors.
-Tuning hyperparameters using GridSearchCV with 5-fold cross-validation.
-Evaluating models using negative mean squared error.
-Analyzing feature importance using LinearRegression coefficients.
-Saving the best-performing model (though pickle file not included per submission rules).

What did you learn from the changes you have made?

-How to construct multiple pipeline combinations for systematic comparison.
-That simple LinearRegression can outperform more complex models like RandomForest on some datasets.
-The importance of handling unknown categories in OneHotEncoder during cross-validation (used handle_unknown='ignore').
-How to extract and interpret feature importance from linear models.
-That month features (September, October) were most predictive of forest fire area, suggesting strong seasonal patterns.

Was there another approach you were thinking about making? If so, what approach(es) were you thinking of?

I considered using more advanced models like GradientBoosting or SVR, but kept RandomForest as the "advanced" model as required.
For feature importance, I wanted to use SHAP but installation failed, so I used LinearRegression coefficients instead.

Were there any challenges? If so, what issue(s) did you face? How did you overcome it?

-OneHotEncoder issue: Cross-validation folds had missing month categories (e.g., 'dec', 'nov' in some folds but not others). This caused "unknown categories" errors.
Solution: Added handle_unknown='ignore' to OneHotEncoder, which encodes unknown categories as zeros.

-SHAP installation: Couldn't install SHAP due to environment issues. Also it took long time to grasp the necessary info.
Solution: Used LinearRegression coefficients for feature importance analysis instead.

-Model performance interpretation: Negative MSE scores were confusing at first.
Solution: Realized higher (less negative) scores indicate better performance.

How were these changes tested?

-Used 5-fold cross-validation for all model evaluations.
-Compared four different pipeline configurations systematically.
-Verified all code runs from top to bottom without errors.

A reference to a related issue in your repository (if applicable)

N/A - This is Assignment 2 submission.

Checklist

  • [x ] I can confirm that my changes are working as intended

alf-99 added 2 commits January 19, 2026 01:18
- Load price data from parquet files
- Create lag features, returns, and price ranges
- Convert to pandas and calculate moving averages
- Answer written analysis questions
- Built four model pipelines with different preprocessors and regressors
- LinearRegression with simple preprocessing performed best (MSE: -4351.6)
- Fixed OneHotEncoder issue with handle_unknown='ignore'
- Analyzed feature importance using LinearRegression coefficients
- Exported best model as pickle file

@fyellow fyellow left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work overall! SHAP was not actually used you relied on linear model coefficients. Please redo and submit

@alf-99

alf-99 commented Jan 31, 2026

Copy link
Copy Markdown
Owner Author

Hi, I have tried installing SHAP in many ways. Including the steps outlined in slack thread by Jesus. And several other configurations. It just not working on the environment. Please kindly provide a fix from the environment file if possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants