regression-linear / README.md
Varma2905's picture
Upload folder using huggingface_hub
f41fa00 verified
|
Raw History Blame Contribute Delete
3.16 kB
# Simple Linear Regression
**This model is designed for generic regression datasets and is not restricted to the Tetuan City Power Consumption dataset.** It is a reusable regression workflow: retrain it on your own tabular data by calling `train_and_predict(data=your_df, target_column="your_target")` from `regression_model.py`.
**Model type:** tabular_regression
**Task:** regression
**Framework:** scikit-learn
## Supported input
- Any tabular (CSV-loadable) dataset with a numeric target column.
- Numeric and categorical feature columns are auto-detected; categorical columns are one-hot encoded (`handle_unknown="ignore"`, so unseen categories at inference time don't crash).
- Datetime-like columns are auto-detected and converted into hour/day-of-week/month/year features.
## Target column requirement
- Must be numeric. Pass it explicitly: `train_and_predict(data=df, target_column="...")`.
## Files in this repository
- `regression_model.py` -- the reusable implementation (`GenericRegressionModel`, `train_and_predict`). Import this and call it on your own data.
- `model.joblib` -- a demo artifact fit on the Tetuan City power consumption dataset (development/testing only). Its learned coefficients are specific to THAT dataset's feature space and will not work on a dataset with different columns -- retrain via `regression_model.py` for your own data instead.
- `metrics.json` / `metadata.json` -- evaluation results from the development-dataset run and the synthetic generic-dataset validation.
## Training configuration (development-dataset run)
- Train size: 41932
- Test size: 10484
- Hyperparameters: `{"copy_X": true, "fit_intercept": true, "n_jobs": null, "positive": false}`
## Evaluation metrics (development dataset)
| Metric | Value |
|---|---|
| MAE | 3416.8772 |
| MSE | 19319221.1505 |
| RMSE | 4395.3636 |
| MedianAbsoluteError | 2689.5062 |
| MaxError | 18730.4598 |
| R2 | 0.5569 |
| ExplainedVariance | 0.5570 |
| MAPE | 20.7361 |
| MSLE | 0.0605 |
| RMSLE | 0.2459 |
| AdjustedR2 | 0.5569 |
| PearsonCorrelation | 0.7463 |
| SpearmanCorrelation | 0.7468 |
## Generic dataset validation
Passed: True. Verified with a synthetic `sklearn.datasets.make_regression` dataset (different columns, feature count, and distribution) -- not uploaded here, but proving `train_and_predict()` is not hard-coded to any one dataset.
## Limitations
- `model.joblib` is a demo fit on one specific dataset's feature space -- it will raise a clear error if given data with different feature columns. Use `regression_model.py` to retrain on your own data instead.
- Classical statistical inference is only computed where OLS assumptions apply -- see `metadata.json` -> `statistical_summary`.
## Usage example
```python
import pandas as pd
from regression_model import train_and_predict
df = pd.read_csv('your_dataset.csv')
result = train_and_predict(data=df, target_column='your_target_column')
model = result['model']
print(result['predictions'][:5])
# Predict on brand-new rows with the same feature columns:
new_predictions = model.predict(new_df)
```