Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ Run the tests to verify everything is set up correctly:
pytest
```

## Examples

Take a look at the `examples/` directory for runnable snippets. The
`classification_example.py` script trains a small logistic regression
model on the included Iris dataset and prints evaluation metrics via the
`send_to_llm` helper:

```bash
python examples/classification_example.py
```

## Bug Reports & Feature Requests

Please open an issue on GitHub if you encounter a bug or have a feature request.
Expand Down
23 changes: 23 additions & 0 deletions examples/classification_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import pandas as pd
from sklearn.linear_model import LogisticRegression

from faster_llm.ML.classification import Model


def main() -> None:
"""Train a simple classifier and send metrics to the LLM."""
df = pd.read_csv("../sample_data/iris.csv")
X = df.drop(columns=["variety"])
y = (df["variety"] == "Virginica").astype(int)

model = Model(
LogisticRegression(max_iter=200),
X,
y,
send_to_llm_flag=True,
)
print(model._compute_metrics())


if __name__ == "__main__":
main()
Loading