Skip to content

Commit e05a157

Browse files
AlexIoannidesalexioannides
and
alexioannides
authored
Add example notebook (#3)
Co-authored-by: alexioannides <[email protected]>
1 parent 37ca575 commit e05a157

File tree

3 files changed

+408
-34
lines changed

3 files changed

+408
-34
lines changed

README.md

+45-34
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,44 @@
1-
# llm_regression
1+
# Regression using LLMs
22

3-
This is the repository for the llm_regression Python package.
3+
The llm_regression package demonstrates how LLMs can be used to solve classical regression problems, and exposes these capabilities for you to experiment with. Example:
4+
5+
```python
6+
from llm_regression import OpenAiRegressor
7+
8+
llm_regressor = OpenAiRegressor(model="gpt-3.5-turbo")
9+
llm_regressor.fit(X_train, y_train)
10+
y_pred = llm_regressor.predict(X_test)
11+
```
12+
13+
This work was motivated by the paper,
14+
15+
["_From Words to Numbers: You LLM is Secretly a Capable Regressor_", by Vacareanu et al. (2024)](https://arxiv.org/abs/2404.07544).
16+
17+
Which is well worth a read!
18+
19+
## Installing
20+
21+
You can install the llm_regression package, together with the dependencies required to run the example notebooks, directly from this repo,
22+
23+
```text
24+
pip install -U pip
25+
pip install "llm_regression[examples] @ git+https://github.com/AlexIoannides/llm-regression.git"
26+
```
27+
28+
## Examples
29+
30+
Checkout the [basic_demo notebook](https://github.com/AlexIoannides/llm-regression/tree/main/examples/basic_demo.ipynb).
431

532
## Developer Setup
633

34+
If you want to modify or extend the work in this repo, then the information in this section is for you.
35+
36+
### Install Developer Tools
37+
738
Install the package as an [editable dependency](https://setuptools.pypa.io/en/latest/userguide/development_mode.html), together with all the developer tools required to format code, check types and run tests:
839

940
```text
10-
$ pip install -e ".[dev]"
41+
pip install -e ".[dev]"
1142
```
1243

1344
### Developer Task Execution with Nox
@@ -19,11 +50,11 @@ $ nox --list
1950
2051
Sessions defined in /Users/.../noxfile.py:
2152
22-
* run_tests-3.10 -> Run unit tests.
23-
- format_code-3.10 -> Lint code and re-format where necessary.
24-
* check_code_formatting-3.10 -> Check code for formatting errors.
25-
* check_types-3.10 -> Run static type checking.
26-
- build_and_deploy-3.10 -> Build wheel and deploy to PyPI.
53+
* run_tests-3.12 -> Run unit tests.
54+
- format_code-3.12 -> Lint code and re-format where necessary.
55+
* check_code_formatting-3.12 -> Check code for formatting errors.
56+
* check_types-3.12 -> Run static type checking.
57+
- build_and_deploy-3.12 -> Build wheel and deploy to PyPI.
2758
2859
sessions marked with * are selected, sessions marked with - are skipped.
2960
```
@@ -33,48 +64,28 @@ Single tasks can be executed easily - e.g.,
3364
```text
3465
$ nox -s run_tests
3566
36-
nox > Running session run_tests-3.10
37-
nox > Creating virtual environment (virtualenv) using python3.10 in .nox/run_tests-3-10
67+
nox > Running session run_tests-3.12
68+
nox > Creating virtual environment (virtualenv) using python3.12 in .nox/run_tests-3-10
3869
nox > python -m pip install '.[dev]'
3970
nox > pytest
4071
======================================== test session starts ========================================
41-
platform darwin -- Python 3.10.2, pytest-7.4.2, pluggy-1.3.0
72+
platform darwin -- Python 3.12.2, pytest-7.4.2, pluggy-1.3.0
4273
rootdir: /Users/.../llm_regression
4374
configfile: pyproject.toml
4475
testpaths: tests
4576
collected 1 item
4677
47-
tests/test_hello_world.py . [100%]
78+
tests/test_hello_world.py [100%]
4879
4980
========================================== 1 passed in 0.00s =========================================
50-
nox > Session run_tests-3.10 was successful.
51-
```
52-
53-
### Building Packages and Deploying to PyPI
54-
55-
This is automated via the `nox -s build_and_deploy` command. In order to use this, the following environment variables will need to be made available to Python:
56-
57-
```text
58-
PYPI_USR # PyPI username
59-
PYPI_PWD # PyPI password
81+
nox > Session run_tests-3.12 was successful.
6082
```
6183

62-
These may be specified in a `.env` file from which they will be loaded automatically - e.g.,
63-
64-
```text
65-
PYPI_USR=XXXX
66-
PYPI_PWD=XXXX
67-
```
68-
69-
Note: `.gitignore` will ensure that `.env`is not tracked by Git.
70-
71-
## CI/CD
84+
### CI/CD
7285

7386
This repo comes configured to run two [GitHub Actions](https://docs.github.com/en/actions) workflows:
7487

7588
- **Test Python Package (CI)**, defined in `.github/workflows/python-package-ci.yml`
7689
- **Deploy Python Package (CD)**, defined in `.github/workflows/python-package-cd.yml`
7790

7891
The CI workflow has been configured to run whenever a pull request to the `main` branch is created. The CD workflow has been configured to run whenever a [release](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository) is created on GitHub.
79-
80-
Note, the CD workflow will require `PYPI_USR` and `PYPI_PWD` to be added as [repository secrets](https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions).

examples/basic_demo.ipynb

+358
Large diffs are not rendered by default.

pyproject.toml

+5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ dependencies = [
1616
]
1717

1818
[project.optional-dependencies]
19+
examples = [
20+
"pandas==2.2.2",
21+
"scikit-learn==1.4.2",
22+
"seaborn==0.13.2",
23+
]
1924
dev = [
2025
"black==23.9.1",
2126
"python-dotenv>=1.0.0",

0 commit comments

Comments
 (0)