Metadata-Version: 2.4
Name: behappy
Version: 0.1.1
Summary: Print the code of 8 classic ML and statistics experiments with a single call: from BeHappy import code; code()
Author: BeHappy Authors
License-Expression: MIT
Keywords: machine-learning,statistics,scikit-learn,statsmodels,education,jupyter,colab
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Framework :: Jupyter
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.23
Requires-Dist: pandas>=1.5
Requires-Dist: scipy>=1.9
Requires-Dist: scikit-learn>=1.2
Requires-Dist: statsmodels>=0.14
Requires-Dist: matplotlib>=3.5
Requires-Dist: requests>=2.25
Provides-Extra: dev
Requires-Dist: pytest>=7; extra == "dev"
Requires-Dist: build>=1.0; extra == "dev"
Requires-Dist: twine>=5.0; extra == "dev"
Dynamic: license-file

# BeHappy

**BeHappy** is a small Python package that prints the source code of eight
classic machine learning and statistics experiments with a single function call:

```python
from BeHappy import code

code()
```

Calling `code()` prints the code of these eight experiments, in order, under
the headings `Exp 1:` to `Exp 8:`:

| Exp | What it covers |
|-----|----------------|
| 1 | NumPy arrays, linear algebra, `clip` / `select` / `where`, SciPy statistics and optimisation, statsmodels OLS, K-Means clustering |
| 2 | Simple linear regression on Boston Housing (`RM` → price) with scikit-learn and statsmodels |
| 3 | Multiple linear regression on Boston Housing (OpenML) with scikit-learn and statsmodels |
| 4 | Polynomial regression (degrees 1-3) on `LSTAT`, with a plot |
| 5 | Binary and multinomial logistic regression on Iris (scikit-learn and statsmodels) |
| 6 | Dow Jones Index: predicting next week's close price with linear regression, with a plot |
| 7 | One-vs-rest classification with linear regression on Iris |
| 8 | One-vs-rest classification with linear regression on KDD Cup 99 (10% sample) |

`code()` only prints the code. It does not run the experiments, download
anything or create any files. Nothing is printed when you import the package.

You can copy any printed experiment into a notebook cell or a `.py` file and
run it. The libraries it needs (numpy, pandas, scipy, scikit-learn,
statsmodels, matplotlib and requests) are installed together with BeHappy.
Experiments 2, 3, 4, 6 and 8 download public datasets when you run them, so
they need an internet connection.

## Installation

```bash
pip install behappy
```

The project is called `behappy` on PyPI, and you import it as `BeHappy`.
pip treats the name case-insensitively, so `pip install BeHappy` works too.

To install from a local copy of the source:

```bash
pip install .
```

## Usage

### Python (script or terminal)

```python
from BeHappy import code

code()
```

Save that as `run.py` and run `python run.py`. The code is printed in the terminal.
To save it to a file instead, run `python run.py > experiments.txt`.

### Jupyter Notebook

In a cell:

```python
%pip install behappy
```

Then, in a new cell:

```python
from BeHappy import code

code()
```

The code is printed below the cell. If VS Code shows "Output is truncated", click
"View as a scrollable element" (or "open in a text editor") to see all of it.

### Google Colab

```python
!pip install behappy
```

```python
from BeHappy import code

code()
```

Colab may ask you to restart the runtime after installing (for example if
numpy was upgraded). If it does, restart and run the second cell again.

## Requirements

Python 3.9 or newer. These dependencies are installed automatically:
numpy, pandas, scipy, scikit-learn, statsmodels, matplotlib and requests.

## Development

```bash
pip install -e ".[dev]"
pytest
```

## License

MIT. See [LICENSE](LICENSE).
