| library_name: scikit-learn | |
| tags: | |
| - sklearn | |
| - iris | |
| # Iris Flower Classification | |
| Model: Logistic Regression w Pipeline (StandardScaler + LogisticRegression). | |
| ## Input | |
| Table with columns: | |
| - sepal length (cm) | |
| - sepal width (cm) | |
| - petal length (cm) | |
| - petal width (cm) | |
| ## Output | |
| - predict: class (0/1/2) | |
| - predict_proba: class probabilities | |
| ## Przykład użycia | |
| ```python | |
| import joblib | |
| import pandas as pd | |
| from huggingface_hub import hf_hub_download | |
| import numpy as np | |
| repo_id = "studentscolab/iris" | |
| model_path = hf_hub_download(repo_id=repo_id, filename="model.joblib") | |
| model = joblib.load(model_path) | |
| x = pd.DataFrame([{ | |
| "sepal length (cm)": 5.1, | |
| "sepal width (cm)": 3.5, | |
| "petal length (cm)": 1.4, | |
| "petal width (cm)": 0.2, | |
| }]) | |
| np.set_printoptions(precision=10, suppress=True) | |
| pred = model.predict(x)[0] | |
| proba = model.predict_proba(x)[0] | |
| print("classes:", model.classes_) | |
| print("pred:", pred) | |
| print("proba:", proba) | |
| ``` |