> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wandb.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Class: Evaluation<R, E, M>

> TypeScript SDK reference

[weave](../) / Evaluation

Sets up an evaluation which includes a set of scorers and a dataset.

Calling evaluation.evaluate(model) will pass in rows form a dataset into a model matching
the names of the columns of the dataset to the argument names in model.predict.

Then it will call all of the scorers and save the results in weave.

`Example`

```ts theme={null}
// Collect your examples into a dataset
const dataset = new weave.Dataset({
  id: 'my-dataset',
  rows: [
    { question: 'What is the capital of France?', expected: 'Paris' },
    { question: 'Who wrote "To Kill a Mockingbird"?', expected: 'Harper Lee' },
    { question: 'What is the square root of 64?', expected: '8' },
  ],
});

// Define any custom scoring function
const scoringFunction = weave.op(function isEqual({ modelOutput, datasetRow }) {
  return modelOutput == datasetRow.expected;
});

// Define the function to evaluate
const model = weave.op(async function alwaysParisModel({ question }) {
  return 'Paris';
});

// Start evaluating
const evaluation = new weave.Evaluation({
  id: 'my-evaluation',
  dataset: dataset,
  scorers: [scoringFunction],
});

const results = await evaluation.evaluate({ model });
```

## Type parameters

| Name | Type                 |
| :--- | :------------------- |
| `R`  | extends `DatasetRow` |
| `E`  | extends `DatasetRow` |
| `M`  | `M`                  |

## Hierarchy

* [`WeaveObject`](./weaveobject)

  ↳ `Evaluation`

## Table of contents

### Constructors

* [constructor](./evaluation#constructor)

### Properties

* [\_\_savedRef](./evaluation#__savedref)

### Accessors

* [description](./evaluation#description)
* [name](./evaluation#name)

### Methods

* [evaluate](./evaluation#evaluate)
* [predictAndScore](./evaluation#predictandscore)
* [saveAttrs](./evaluation#saveattrs)

## Constructors

### constructor

• **new Evaluation**\<`R`, `E`, `M`>(`parameters`): [`Evaluation`](./evaluation)\<`R`, `E`, `M`>

#### Type parameters

| Name | Type                 |
| :--- | :------------------- |
| `R`  | extends `DatasetRow` |
| `E`  | extends `DatasetRow` |
| `M`  | `M`                  |

#### Parameters

| Name         | Type                                   |
| :----------- | :------------------------------------- |
| `parameters` | `EvaluationParameters`\<`R`, `E`, `M`> |

#### Returns

[`Evaluation`](./evaluation)\<`R`, `E`, `M`>

#### Overrides

[WeaveObject](./weaveobject).[constructor](./weaveobject#constructor)

#### Defined in

[evaluation.ts:148](https://github.com/wandb/weave/blob/62f1e46098095776ee29b730ad10b3b3d1a68307/sdks/node/src/evaluation.ts#L148)

## Properties

### \_\_savedRef

• `Optional` **\_\_savedRef**: [`ObjectRef`](./objectref) | `Promise`\<[`ObjectRef`](./objectref)>

#### Inherited from

[WeaveObject](./weaveobject).[\_\_savedRef](./weaveobject#__savedref)

#### Defined in

[weaveObject.ts:73](https://github.com/wandb/weave/blob/62f1e46098095776ee29b730ad10b3b3d1a68307/sdks/node/src/weaveObject.ts#L73)

## Accessors

### description

• `get` **description**(): `undefined` | `string`

#### Returns

`undefined` | `string`

#### Inherited from

WeaveObject.description

#### Defined in

[weaveObject.ts:100](https://github.com/wandb/weave/blob/62f1e46098095776ee29b730ad10b3b3d1a68307/sdks/node/src/weaveObject.ts#L100)

***

### name

• `get` **name**(): `string`

#### Returns

`string`

#### Inherited from

WeaveObject.name

#### Defined in

[weaveObject.ts:96](https://github.com/wandb/weave/blob/62f1e46098095776ee29b730ad10b3b3d1a68307/sdks/node/src/weaveObject.ts#L96)

## Methods

### evaluate

▸ **evaluate**(`«destructured»`): `Promise`\<`Record`\<`string`, `any`>>

#### Parameters

| Name                | Type                                                                         | Default value |
| :------------------ | :--------------------------------------------------------------------------- | :------------ |
| `«destructured»`    | `Object`                                                                     | `undefined`   |
| › `maxConcurrency?` | `number`                                                                     | `5`           |
| › `model`           | `WeaveCallable`\<(...`args`: \[\{ `datasetRow`: `R`  }]) => `Promise`\<`M`>> | `undefined`   |
| › `nTrials?`        | `number`                                                                     | `1`           |

#### Returns

`Promise`\<`Record`\<`string`, `any`>>

#### Defined in

[evaluation.ts:163](https://github.com/wandb/weave/blob/62f1e46098095776ee29b730ad10b3b3d1a68307/sdks/node/src/evaluation.ts#L163)

***

### predictAndScore

▸ **predictAndScore**(`«destructured»`): `Promise`\<\{ `model_latency`: `number` = modelLatency; `model_output`: `any` = modelOutput; `model_success`: `boolean` = !modelError; `scores`: \{ `[key: string]`: `any`;  }  }>

#### Parameters

| Name               | Type                                                                         |
| :----------------- | :--------------------------------------------------------------------------- |
| `«destructured»`   | `Object`                                                                     |
| › `columnMapping?` | `ColumnMapping`\<`R`, `E`>                                                   |
| › `example`        | `R`                                                                          |
| › `model`          | `WeaveCallable`\<(...`args`: \[\{ `datasetRow`: `E`  }]) => `Promise`\<`M`>> |

#### Returns

`Promise`\<\{ `model_latency`: `number` = modelLatency; `model_output`: `any` = modelOutput; `model_success`: `boolean` = !modelError; `scores`: \{ `[key: string]`: `any`;  }  }>

#### Defined in

[evaluation.ts:231](https://github.com/wandb/weave/blob/62f1e46098095776ee29b730ad10b3b3d1a68307/sdks/node/src/evaluation.ts#L231)

***

### saveAttrs

▸ **saveAttrs**(): `Object`

#### Returns

`Object`

#### Inherited from

[WeaveObject](./weaveobject).[saveAttrs](./weaveobject#saveattrs)

#### Defined in

[weaveObject.ts:77](https://github.com/wandb/weave/blob/62f1e46098095776ee29b730ad10b3b3d1a68307/sdks/node/src/weaveObject.ts#L77)
