> ## Documentation Index
> Fetch the complete documentation index at: https://wb-21fd5541-workspaces-notebooks.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 評価<R, E, M>

> TypeScript SDK リファレンス

export const GitHubLink = ({url, compact = false}) => <a href={url} target="_blank" rel="noopener noreferrer" className={compact ? "source-link" : "github-source-link"}>
    {compact ? "ソースを表示" : <>
    <svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
      <path d="M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z" />
    </svg>
    GitHub のソース
      </>}
  </a>;

<GitHubLink url="https://github.com/wandb/weave/blob/7c9efdc9fe05ffcaf2430dd652ef9bc5b3ffdfaa/sdks/node/src/evaluation.ts#L145" />

一連の scorer とデータセットを含む評価を設定します。

evaluation.evaluate(model) を呼び出すと、データセットの各行がモデルに渡されます。このとき、
データセットの列名が model.predict の引数名に対応付けられます。

その後、すべての scorer が呼び出され、結果が weave に保存されます。

<div id="example">
  ## 例
</div>

```ts twoslash theme={null}
// @noErrors
// examples をデータセットに収集する
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' },
  ],
});

// カスタムスコアリング関数を定義する
const scoringFunction = weave.op(function isEqual({ modelOutput, datasetRow }) {
  return modelOutput == datasetRow.expected;
});

// 評価する関数を定義する
const model = weave.op(async function alwaysParisModel({ question }) {
  return 'Paris';
});

// 評価を開始する
const evaluation = new weave.Evaluation({
  id: 'my-evaluation',
  dataset: dataset,
  scorers: [scoringFunction],
});

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

<div id="extends">
  ## 継承元
</div>

* [`WeaveObject`](./weaveobject)

<div id="type-parameters">
  ## タイプパラメーター
</div>

<ParamField path="R" type="extends DatasetRow" />

<ParamField path="E" type="extends DatasetRow" />

<ParamField path="M" />

<div id="constructor">
  ## コンストラクター
</div>

> **new Evaluation**\<`R`, `E`, `M`>(`parameters`): `Evaluation`\<`R`, `E`, `M`>

<div id="parameters">
  ### パラメーター
</div>

<ParamField path="parameters" type="object" required>
  <Expandable title="プロパティ" defaultOpen>
    <ParamField path="columnMapping" type="{[key: string]: keyof R; __savedRef?: keyof R; }">
      <Expandable title="プロパティ" defaultOpen>
        <ParamField path="__savedRef" type="keyof R" />
      </Expandable>
    </ParamField>

    <ParamField path="dataset" type="Dataset<R>" required>
      [`Dataset`](./dataset) を参照してください。
    </ParamField>

    <ParamField path="description" type="string" />

    <ParamField path="maxConcurrency" type="number" />

    <ParamField path="name" type="string" />

    <ParamField path="scorers" type="(Op<(...args) => any> | {…})[]" required>
      [`Op`](../type-aliases/op) を参照してください。

      完全なタイプ: `(Op<(...args) => any> | { id: string; invoke: (...args) => any; })[]`
    </ParamField>
  </Expandable>
</ParamField>

<div id="returns">
  ### 戻り値
</div>

`Evaluation`\<`R`, `E`, `M`>

<div id="overrides">
  ### オーバーライド
</div>

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

<div id="properties">
  ## プロパティ
</div>

<div id="__savedref">
  ### \_\_savedRef
</div>

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

<div id="inherited-from">
  #### 継承元
</div>

[`WeaveObject`](./weaveobject).[`__savedRef`](./weaveobject#__savedref)

<div id="accessors">
  ## アクセサ
</div>

<div id="description">
  ### description
</div>

<div id="get-signature">
  #### 取得シグネチャ
</div>

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

<div id="returns-2">
  ##### 戻り値
</div>

`string` | `undefined`

<div id="inherited-from-2">
  #### 継承元
</div>

[`WeaveObject`](./weaveobject).[`description`](./weaveobject#description)

***

<div id="name">
  ### 名
</div>

<div id="get-signature-2">
  #### 取得シグネチャ
</div>

> **get** **名**(): `string`

<div id="returns-3">
  ##### 戻り値
</div>

`string`

<div id="inherited-from-3">
  #### 継承元
</div>

[`WeaveObject`](./weaveobject).[`名`](./weaveobject#name)

<div id="methods">
  ## Methods
</div>

<div id="evaluate">
  ### evaluate()
</div>

> **evaluate**(`__namedParameters`): `Promise`\<`Record`\<`string`, `any`>>

<div id="parameters-2">
  #### パラメーター
</div>

<ParamField path="__namedParameters" type="object" required>
  <Expandable title="プロパティ" defaultOpen>
    <ParamField path="maxConcurrency" type="number = 5" />

    <ParamField path="model" type="Op<(...args) => Promise<M>> | {…}" required>
      [`Op`](../type-aliases/op) を参照してください。

      完全なタイプ: `Op<(...args) => Promise<M>> | { id: string; invoke: (...args) => Promise<M>; }`
    </ParamField>

    <ParamField path="nTrials" type="number = 1" />
  </Expandable>
</ParamField>

<div id="returns-4">
  #### 戻り値
</div>

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

***

<div id="predictandscore">
  ### predictAndScore()
</div>

> **predictAndScore**(`__namedParameters`): `Promise`\<\{ `model_latency`: `number`; `model_output`: `any`; `model_success`: `boolean`; `scores`: \{\[`key`: `string`]: `any`; }; }>

<div id="parameters-3">
  #### パラメーター
</div>

<ParamField path="__namedParameters" type="object" required>
  <Expandable title="プロパティ" defaultOpen>
    <ParamField path="columnMapping" type="{[key: string]: keyof R; __savedRef?: keyof R; }">
      <Expandable title="プロパティ" defaultOpen>
        <ParamField path="__savedRef" type="keyof R" />
      </Expandable>
    </ParamField>

    <ParamField path="example" type="R" required />

    <ParamField path="model" type="Op<(...args) => Promise<M>> | {…}" required>
      [`Op`](../type-aliases/op) を参照してください。

      完全なタイプ: `Op<(...args) => Promise<M>> | { id: string; invoke: (...args) => Promise<M>; }`
    </ParamField>
  </Expandable>
</ParamField>

<div id="returns-5">
  #### 戻り値
</div>

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

***

<div id="saveattrs">
  ### saveAttrs()
</div>

> **saveAttrs**(): `object`

<div id="returns-6">
  #### 戻り値
</div>

`object`

<div id="inherited-from-4">
  #### 継承元
</div>

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