Metadata-Version: 2.4
Name: mlr_cpp
Version: 1.1.0
Summary: A high-performance Multiple Linear Regression model implemented in C++ with a clean Python API via Pybind11 bindings
Author: Sidhant Raj Khati
Author-email: Sidhant Raj Khati <sidhant.raj.khati@gmail.com>
License-Expression: MIT
Project-URL: Repository, https://github.com/Sidhant-1299/mlr_cpp.git
Keywords: Machine Learning,Linear Regression,Multiple Linear Regression,C++,Python,Python3
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: C++
Classifier: Operating System :: OS Independent
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Intended Audience :: Science/Research
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: pandas>=2.2.3
Requires-Dist: pybind11>=2.13.6
Provides-Extra: examples
Requires-Dist: matplotlib; extra == "examples"
Requires-Dist: jupyter; extra == "examples"
Requires-Dist: scikit-learn; extra == "examples"
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"
Dynamic: author

# mlr_cpp – Fast C++ Multiple Linear Regression with Python API

`mlr_cpp` is a high-performance Multiple Linear Regression library implemented in C++ and exposed to Python using `pybind11`. It is designed for speed, delivering results over **10x faster** than `scikit-learn`, while providing a user-friendly `pandas`-compatible API.

---

## Key Features

- **Blazing fast** C++ core, with Pybind11 for seamless Python integration  
- Supports full model diagnostics: R², Adjusted R², MAE, MSE, F-test, T-statistics, P-values  
- Automatically checks for multicollinearity and sufficient data  
- Equation generation with smart rounding and absolute tolerance  
- Compatible with `pandas` DataFrames  

---

## Benchmarks with sklearn

#### coefficients
```
mlr_cpp: [3.98827526e+00 3.98919944e+00 8.77169801e+00 3.74320006e+00
          3.38302087e-04 1.10138110e-02]
sklearn: [3.98919944e+00 8.77169801e+00 3.74320006e+00 3.38302087e-04
          1.10138110e-02]
```

#### Runtimes

```
mlr_cpp: 0.000344s
sklearn: 0.004404s
```

#### $R^2$ Scores

```
mlr_cpp: 0.987661
sklearn: 0.987661
```

`mlr_cpp` provides identical accuracy while being ~10x faster than `scikit-learn`


##  Installation

```bash
pip install mlr_cpp
```

#### Optional Extras
```bash
pip install mlr_cpp[examples]  # for examples, plotting
pip install mlr_cpp[dev]       # for development tools
```


## Example Usage

```python
import pandas as pd
from mlr_wrapper import MLRWrapper

df = pd.read_csv("your_data.csv")
model = MLRWrapper(df, target_col="mpg")

model.fit()
eqn, predictors, tests = model.get_model_summary(tstats=True)

print(eqn)
print(predictors)
print(tests)
```

### Prediction
```python
model.predict(new_df)
```

### Model Summary

You can retrieve a complete summary of the model including the regression equation, coefficients, p-values, and test metrics:

```python
eqn, predictor_summary, model_tests = model.get_model_summary(tstats=True)

print(eqn)                  # Prints the regression equation
print(predictor_summary)    # DataFrame with coefficients, p-values, and t-statistics
print(model_tests)          # DataFrame with metrics like R², MAE, MSE, etc.
```

### Evaluation Metrics

After fitting the model, `mlr_cpp` provides access to standard evaluation metrics for performance diagnostics:

```python
model.get_R2()           # Coefficient of Determination (R²)
model.get_AdjustedR2()   # Adjusted R²
model.get_MAE()          # Mean Absolute Error
model.get_MSE()          # Mean Squared Error
model.get_ftest()        # F-statistic of the regression model
model.get_TStatistics()  # T-statistics for each predictor
model.get_PValues()      # P-values corresponding to each predictor
model.get_model_tests()  # Summary DataFrame containing major evaluation metrics
```

## 👨‍💻 Author

### Sidhant Raj Khati

🌐︎ Website: [sidhantkhati.com](https://sidhantkhati.com)\
💼 LinkedIn: [LinkedIn](https://www.linkedin.com/in/sidhant-raj-khati-728086245/)\
🔗 GitHub: [Sidhant-1299/mlr_cpp](https://github.com/Sidhant-1299/mlr_cpp)


## 📄 License

This project is licensed under the **MIT License**

