The objective of this task is to implement and understand Linear Regression using Scikit-learn. The model is trained to predict passenger fare based on selected features from the Titanic dataset.
- Python
- Pandas
- NumPy
- Matplotlib
- Scikit-learn
- KaggleHub
Titanic Dataset
- Downloaded and loaded the Titanic dataset.
- Imported the dataset into a Pandas DataFrame.
- Checked for missing values.
- Replaced missing values in the Age column using the median.
- Selected relevant features for regression.
Input Features:
- Age
- Pclass
Target Variable:
- Fare
- Split the dataset into training and testing sets using an 80:20 ratio.
- Created a Linear Regression model using Scikit-learn.
- Trained the model on the training dataset.
- Generated fare predictions on the test dataset.
Evaluated model performance using:
- Mean Absolute Error (MAE)
- Mean Squared Error (MSE)
- R² Score
Created the following plots:
- Actual vs Predicted Fare
- Residual Plot
- Examined model intercept and feature coefficients.
- Analyzed the impact of Age and Passenger Class on Fare prediction.
The Linear Regression model was successfully trained and evaluated. The evaluation metrics provided insight into prediction accuracy, while the visualizations helped assess model performance and residual distribution.
- Linear Regression
- Feature Selection
- Train-Test Splitting
- Model Training
- Prediction
- MAE, MSE, and R² Metrics
- Model Interpretation
- Residual Analysis
Successfully implemented a Linear Regression model and evaluated its performance using standard regression metrics and visualizations.
Submitted as part of the AI & ML Internship Program.