diff --git a/README.md b/README.md index 55cdeb1..887d22f 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/examples/classification_example.py b/examples/classification_example.py new file mode 100644 index 0000000..1687f2d --- /dev/null +++ b/examples/classification_example.py @@ -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()