import streamlit as st import pandas as pd st.set_page_config(page_title="Ensemble Learning Techniques") st.title("🧠 Ensemble Machine Learning Techniques") # Topic selector view = st.radio("🔍 Select Ensemble Technique", [ "🌳 Random Forest (Classification)", "🌳 Random Forest (Regression)", "🌲 Gradient Boosting (Classification)", "🌲 Gradient Boosting (Regression)", "🔥 AdaBoost (Classification)", "🔥 AdaBoost (Regression)" ], horizontal=True) if view == "🌳 Random Forest (Classification)": st.header("🌳 Random Forest Classifier") st.markdown(""" Random Forest is an ensemble method that builds multiple **decision trees** and combines their results to improve accuracy and reduce overfitting. ### 🔍 How it Works: - Trains multiple decision trees on bootstrapped samples. - Each tree votes; majority class wins. ### ✅ Use Cases: - Spam detection - Medical diagnosis ### 🔧 Key Parameters: - `n_estimators`: Number of trees in the forest. - `max_depth`: Maximum depth of each tree. - `min_samples_split`: Minimum samples to split a node. - `min_samples_leaf`: Minimum samples in a leaf node. - `max_features`: Number of features to consider when looking for best split. - `bootstrap`: Whether bootstrap samples are used. ### Pros: - Handles high-dimensional data well - Reduces variance (robust to overfitting) ### Cons: - Slower for real-time predictions - Can be less interpretable """) elif view == "🌳 Random Forest (Regression)": st.header("🌳 Random Forest Regressor") st.markdown(""" Random Forest for regression aggregates the output of multiple regression trees by **averaging their outputs**. ### 🔍 How it Works: - Each tree predicts a value. - Final output = average of all tree outputs. ### ✅ Use Cases: - Price prediction - Forecasting trends ### 🔧 Key Parameters: - Same as classifier (`n_estimators`, `max_depth`, etc.) ### Pros: - Captures complex relationships - Handles non-linearity well ### Cons: - Slower than simpler models - Overfitting if not tuned properly """) elif view == "🌲 Gradient Boosting (Classification)": st.header("🌲 Gradient Boosting Classifier") st.markdown(""" Gradient Boosting is a sequential ensemble technique that builds trees one after another, **each trying to correct the error** of the previous one. ### 🔍 How it Works: - Uses gradient descent to minimize the loss. - Trees are shallow (weak learners). ### ✅ Use Cases: - Customer churn prediction - Credit scoring ### 🔧 Key Parameters: - `n_estimators`: Number of boosting stages. - `learning_rate`: Shrinks the contribution of each tree. - `max_depth`: Depth of each individual tree. - `subsample`: Fraction of samples used for fitting. ### Pros: - High accuracy - Handles mixed data well ### Cons: - Sensitive to hyperparameters - Can overfit on noisy data """) elif view == "🌲 Gradient Boosting (Regression)": st.header("🌲 Gradient Boosting Regressor") st.markdown(""" Similar to classification but optimized for **continuous values** using gradient descent on regression loss functions. ### ✅ Use Cases: - Demand forecasting - House price prediction ### 🔧 Parameters: - Same as classification (`n_estimators`, `learning_rate`, etc.) ### Pros: - Excellent performance on tabular data ### Cons: - Training is slower """) elif view == "🔥 AdaBoost (Classification)": st.header("🔥 AdaBoost Classifier") st.markdown(""" AdaBoost stands for **Adaptive Boosting**. It combines weak learners sequentially, **giving more weight to misclassified instances**. ### 🔍 How it Works: - Learns sequentially. - Harder instances are focused in later learners. ### ✅ Use Cases: - Fraud detection - Face detection ### 🔧 Key Parameters: - `n_estimators`: Number of weak learners. - `learning_rate`: Weight given to each learner. - `base_estimator`: Default is decision stump. ### Pros: - Simple and effective - Works well with fewer features ### Cons: - Sensitive to noise - Poor with complex data unless base estimator is strong """) elif view == "🔥 AdaBoost (Regression)": st.header("🔥 AdaBoost Regressor") st.markdown(""" Boosts weak regressors sequentially, correcting residual errors of previous models. ### ✅ Use Cases: - Stock price prediction - Insurance risk modeling ### 🔧 Parameters: - Same as classifier (`n_estimators`, `learning_rate`, `loss`, etc.) ### Pros: - Robust to overfitting if tuned ### Cons: - Sensitive to outliers """) st.markdown(""" --- 📌 **Note**: Ensemble methods perform better with **hyperparameter tuning**. Use tools like `Optuna`, `GridSearchCV`, or `RandomizedSearchCV` to find the best model parameters. 📌 **Pro Tip**: Feature importance scores from tree-based models help in **feature selection** and **interpretability**. """)