# Data handling

> What happens to the data you send, and how long it is kept.

Your inputs are sent to the YHat Labs API over HTTPS to be processed.

- **We never use your data to train or improve our models.**
- **Calls** are kept with what they sent and got back, so you can open, download or delete them in the account app's Logs.
  Send `"store": false` in a call (or `?store=false`; `store=False` in Python, `--no-store` in the CLI) and the call isn't
  shown in your Logs. We also keep a copy of every call,
  whatever `store` says, to look into errors, and use it for nothing else.
- **Fits** keep your training table and the trained model while the fit lives: 30 days after its last use by default
  (`ttl_days`, 1 to 365), or until you delete it. Deleting removes them from your project.
- **Saved model files** (`model.save()` in Python) are written on your machine. They include a sample of up to 2,000
  training rows, for the out-of-range and novelty checks; `model.save(path, sample=False)` leaves the rows out.
- **Playground runs** are kept with their tables and results so you can open them again; deleting a run removes it from the
  app.
- **Uploaded tables** (large tables the Python library sends once, by reference) are kept so later calls can reuse them,
  and can be deleted with `DELETE /v1/uploads/{id}`.
- **Keys** are sent only in the `Authorization` header. The Python library never writes them to disk or to its logs.

## Masking column names

Column names often say more than the numbers: `patient_hiv_status`, `supplier_margin`. `mask_columns=True` sends every
column name as `c0`, `c1`, ... instead, and maps the replies back, so your code and results still use your own names:

```python
import pandas as pd
from sklearn.model_selection import train_test_split
from yhatlabs import Client

titanic = pd.read_csv("https://raw.githubusercontent.com/datasciencedojo/datasets/master/titanic.csv")
titanic = titanic.drop(columns=["PassengerId", "Name", "Ticket", "Cabin"])
train, test = train_test_split(titanic, random_state=0)

yh = Client(mask_columns=True)  # the API sees c0, c1, ... instead of Sex, Age, Fare, ...
model = yh.fit(train, target="Survived")
print(model.mask)
print(model.importance(test).head(3).round(3).to_string(index=False))  # your column names, not c0, c1, ...
model.delete()
```

Output:

```
{'Survived': 'c0', 'Pclass': 'c1', 'Sex': 'c2', 'Age': 'c3', 'SibSp': 'c4', 'Parch': 'c5', 'Fare': 'c6', 'Embarked': 'c7'}
feature  importance  stddev
Sex       0.283   0.003
 Pclass       0.129   0.027
   Fare       0.071   0.005
```

- Set it on the client (`Client(mask_columns=True)`), on a copy (`yh.with_options(mask_columns=True)`), or on one call
  (`forecast`, `predict`, `fit`, `evaluate_table`, ...). It is off by default.
- Everything comes back under your names: predictions, importance, effects, `out_of_range`, and the column names in error
  messages.
- A stored fit keeps the mapping on your side: `model.predict(...)` masks the same way, and `model.save()` writes the mapping
  into the saved record, so a fit loaded with `yhatlabs.load(...)` keeps it. Without that record (for example
  `yh.get_fit(id)`), a fit only knows the masked names.
- Predictions do not change: the models never read column names.
- Values, category labels and series ids are sent as they are. Masking hides what the columns are called, not what is in
  them.

Send only data you are allowed to share. For security reports, see the
[security policy](https://github.com/yhatlabs/yhatlabs-python/blob/main/SECURITY.md).
