# eval\_linear

## Function: eval\_linear

```python
def eval_linear(pipe_data, models, device='cuda', split=None, test=None):
```

### Description

`eval_linear` is a function that evaluates the accuracy of models using a linear classifier. It takes as input data and models, converts the data into embeddings using the models, then trains a linear classifier on the embeddings and evaluates its accuracy. The function supports the evaluation of multiple models and returns their accuracies.

### Parameters

* `pipe_data` (PipeDataset): The data to be used as a PipeDataset object.
* `models` (dict/torch.nn.Module): The models to create embeddings. This could be a single PyTorch model or a dictionary of models as returned by `pipe_collate`.
* `device` (str, optional): The device to perform computations on. Defaults to 'cuda' if available.
* `split` (float, optional): The ratio of samples to include in the training split if `test` data is not provided.
* `test` (PipeDataset, optional): The test data as a PipeDataset object.

### Returns

This function returns a list of tuples where each tuple consists of the model's name and the accuracy score of the linear classifier trained on the embeddings produced by the model.

* `results` (list of tuples): A list of (model name, accuracy) tuples.

### Example

Here's an example of how to use the `eval_linear` function:

```python
pipe_data = PipeDataset(...)
models = pipe_collate("/path/to/model/directory", "batch_*")
results = eval_linear(pipe_data, models, device='cuda', split=0.8)
```

In this example, the `eval_linear` function trains a linear classifier on the embeddings produced by the models found in the directory "/path/to/model/directory". It splits the `pipe_data` into a train-test split with 80% of the data in the training set. The results are stored in `results` as a list of tuples where each tuple consists of a model's name and the corresponding accuracy of the linear classifier trained on the model's embeddings.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://autossl.gitbook.io/autossl/api/evaluate/eval_linear.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
