# scikit-learn

> Use ChakraTab as a scikit-learn estimator in pipelines, grid searches and cross-validation.

ChakraTab is also a scikit-learn estimator, so existing scikit-learn code works with it unchanged. Install the extra first:

```sh
pip install "yhatlabs[sklearn]"
```

This scores ChakraTab with 3-fold cross-validation on the breast cancer dataset:

```python
from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import cross_val_score
from yhatlabs.integrations import ChakraTabClassifier

X, y = load_breast_cancer(return_X_y=True, as_frame=True)

scores = cross_val_score(ChakraTabClassifier(ttl_hours=1), X, y, cv=3)
print("accuracy per fold:", scores.round(3), "mean:", round(scores.mean(), 3))
```

Output:

```
accuracy per fold: [0.974 0.984 0.974] mean: 0.977
```

- `ChakraTabClassifier` and `ChakraTabRegressor` are in `yhatlabs.integrations`.
- `fit(X, y)` fits once on our side; `predict` and `predict_proba` send only the rows to score.
- `ChakraTabRegressor().predict_quantiles(X, (0.05, 0.5, 0.95))` returns intervals indexed like `X`.
- `.importance(X_holdout, y_holdout)` returns column importance.
- Arguments: `model`, `preset`, `eval_metric`, `time_limit`, `seed`, `ttl_hours`, `api_key`, `base_url`.
- They work in `Pipeline`, `GridSearchCV` and `cross_val_score`, clone cleanly, and pickle with their fit.

Each fold or grid point is its own fit: a 3-fold cross-validation uses three fits from your quota.
