diff --git a/MIGRATION.md b/MIGRATION.md index 7e16b11..67fd005 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -4,16 +4,14 @@ This major change refactors the client and types for all Howso Engine operations. -### Typing Changes +### Typing changes - Most of all the types are now autogenerated from the Engine API, and will have a different naming schema across the board. However, most of the type's properties should remain the same. -- `types/shims` have been added as a stop gap for types lost from this migration. These will be transitioned out as - types improve in the Howso Engine API specification. - The existing `Trainee` type has been renamed to `BaseTrainee` and no longer has a `features` property. Request features via the method `getFeatureAttributes` instead. -### Client Changes +### Client changes - `BaseClient` has been renamed to `AbstractBaseClient`. - `WasmClient` has been renamed to `HowsoWorkerClient`. @@ -23,15 +21,33 @@ This major change refactors the client and types for all Howso Engine operations - The client's `ClientOptions.libDir` property has been removed. - The client constructor now expects an instance of an `AbstractFileSystem` as its second parameter. A `BrowserFileSystem` and `NodeFileSystem` are provided for use in their respective environments. -- The `train` method no longer batches requests to the Amalgam worker service automatically. Use `batchTrain` instead. - The `createTrainee` method no longer sets feature attributes. Call `setFeatureAttributes` manually instead (this also returns the updated object back). +- The `Trainee` object returned from the client now provides all Trainee operation methods directly. Such as train, react, etc. - The `client/capabilities/*` interfaces have been removed. - The return value of all Trainee operations has been changed to be an object with properties: `payload` (this matches the previous return value format) and `warnings` (a list of warning messages, if applicable). +- The `train` method no longer batches requests to the Amalgam worker service automatically. Use `Trainee.batchTrain` instead. - The `react` method now uses `context_values` instead of `context` and `action_values` instead of `actions`. - `local_*` react features have been removed. Use their unqualified versions instead. +### Utilities changes + +- The options of `inferFeatureAttributes`'s `service.infer`'s `InferFeatureAttributesOptions` have been updated to + a subset of standard [engine options](https://docs.howso.com/en/release-latest/api_reference/_autosummary/howso.utilities.html#howso.utilities.infer_feature_attributes). Please remap to the following: + +```ts +type InferFeatureAttributesOptions = { + dependent_features?: Record; + features?: FeatureAttributesIndex; + include_sample?: boolean; + infer_bounds?: boolean; + mode_bound_features?: string[]; + ordinal_feature_values?: Record; + tight_bounds?: boolean; +}; +``` + ## 5.x The `inferFeatureAttributes` function now requires a `sourceFormat` argument, and is strongly typed through a union. diff --git a/README.md b/README.md index b76ffd7..8e71a46 100644 --- a/README.md +++ b/README.md @@ -85,15 +85,42 @@ import { type ClientOptions, HowsoWorkerClient, BrowserFileSystem } from "@howso const getClient = async (options?: ClientOptions): Promise => { const worker = new Worker(new URL("@/workers/AmalgamWorker", import.meta.url), { type: "module" }); const fs = new BrowserFileSystem(worker); - const client = new HowsoWorkerClient(worker, fs, { + return await HowsoWorkerClient.create(worker, fs, { howsoUrl, migrationsUrl, // Optional, used for upgrading Trainees saved to disk. ...options, }); - return client.setup(); }; ``` +Once you have a client you can then start by creating a Trainee with some initial features and data: + +```ts +const client: HowsoWorkerClient = await getClient(); +const trainee = await client.createTrainee({ name: "MyTrainee" }); +await trainee.setFeatureAttributes({ feature_attributes }); +await trainee.batchTrain({ cases: dataset.data, columns: dataset.columns }); +await trainee.analyze(); +const { payload, warnings } = await trainee.react({ + context_values: [ + [1, 2], + [3, 4], + ], + context_features: ["a", "b"], + action_features: ["target"], +}); +``` + +Or loading a trained trainee via an existing `.caml` file: + +```ts +import uri from "@/src/trainees/MyTrainee.caml?url"; + +const options = { id: "MyTrainee", uri }; +await client.acquireTraineeResources(options.id, options.uri); +const trainee = await client.getTrainee(options.id); +``` + ## Publishing Documentation changes do not require a version publishing. diff --git a/codegen/engine.ts b/codegen/engine.ts index 22d4628..ad9173d 100644 --- a/codegen/engine.ts +++ b/codegen/engine.ts @@ -3,11 +3,13 @@ import fs from "node:fs"; import { createRequire } from "node:module"; const require = createRequire(import.meta.url); +export const PRIMITIVE_TYPES = ["any", "boolean", "number", "string", "null"]; export type SchemaTypeOption = "any" | "assoc" | "boolean" | "list" | "number" | "string" | "null"; export type SchemaType = SchemaTypeOption | SchemaTypeOption[]; +export type TypeDefinition = SchemaType | Schema | Ref | AnyOf; export interface BaseSchema { - description?: string; + description?: string | null; required?: boolean; default?: any; } @@ -16,6 +18,10 @@ export interface Ref extends BaseSchema { ref: string; } +export interface AnyOf extends BaseSchema { + any_of: TypeDefinition[]; +} + export interface Schema extends BaseSchema { type: SchemaType; enum?: (number | string)[]; @@ -25,17 +31,21 @@ export interface Schema extends BaseSchema { exclusive_max?: number; min_size?: number; max_size?: number; - values?: SchemaType | Schema | Ref; - indices?: Record; - dynamic_indices?: Record; - additional_indices?: SchemaType | Schema | Ref | false; + values?: TypeDefinition; + min_indices?: number; + max_indices?: number; + indices?: Record; + dynamic_indices?: Record; + additional_indices?: TypeDefinition | false; } export interface LabelDefinition { - parameters: Record | null; - returns?: SchemaType | Schema | Ref | null; + parameters: Record> | null; + returns?: TypeDefinition | null; description?: string | null; - attribute?: boolean; + use_active_session?: boolean; + attribute?: SchemaType | null; + payload?: boolean; long_running?: boolean; read_only?: boolean; idempotent?: boolean; @@ -44,7 +54,7 @@ export interface LabelDefinition { export interface EngineApi { readonly labels: Record; - readonly schemas: Record; + readonly schemas: Record>; readonly description: string; readonly version: string; } @@ -72,8 +82,9 @@ export async function getEngineApi(): Promise { try { // Load the Howso Engine into Amalgam - amalgam.runtime.FS.writeFile("howso.caml", fs.readFileSync(enginePath)); - amalgam.loadEntity(handle, "howso.caml"); + const filePath = "howso.caml"; + amalgam.runtime.FS.writeFile(filePath, fs.readFileSync(enginePath)); + amalgam.loadEntity({ handle, filePath }); console.log(`Amalgam Version: ${amalgam.getVersion()}`); // Initialize the Engine @@ -83,7 +94,7 @@ export async function getEngineApi(): Promise { } // Get the api documentation from the Engine - const response = amalgam.executeEntityJson(handle, "get_api", ""); + const response = amalgam.executeEntityJson(handle, "get_api", {}); if (!Array.isArray(response) || response[0] != 1) { throw new Error("Failed to retrieve API documentation from the Howso Engine."); } @@ -95,21 +106,50 @@ export async function getEngineApi(): Promise { } } -export function isRef(value: SchemaType | Schema | Ref | null | undefined): value is Ref { +/** Check if a type is a AnyOf object. */ +export function isAnyOf(value: TypeDefinition | null | undefined): value is AnyOf { + if (value == null || Array.isArray(value) || typeof value === "string") { + return false; + } + return "any_of" in value && Array.isArray(value.any_of) && value.any_of.length > 0; +} + +/** Check if a type is a Ref object. */ +export function isRef(value: TypeDefinition | null | undefined): value is Ref { if (value == null || Array.isArray(value) || typeof value === "string") { return false; } return "ref" in value && value.ref != null; } -export function isSchema(value: SchemaType | Schema | Ref | null | undefined): value is Schema { +/** Check if a type is a Schema object. */ +export function isSchema(value: TypeDefinition | null | undefined): value is Schema { if (value == null || Array.isArray(value) || typeof value === "string") { return false; } return !isRef(value) && "type" in value && (typeof value.type === "string" || Array.isArray(value.type)); } -export function isSchemaOrRef(value: SchemaType | Schema | Ref | boolean | null | undefined): value is Schema | Ref { - if (typeof value === "boolean") return false; - return isRef(value) || isSchema(value); +/** Check if a type is a Schema, Ref, or AnyOf object. */ +export function isAnySchema(value: TypeDefinition | boolean | null | undefined): value is Schema | Ref { + if (value == null || typeof value === "boolean") return false; + return isRef(value) || isSchema(value) || isAnyOf(value); +} + +/** Check if a type is a primitive or simple array. */ +export function isSimpleType(value: any) { + if (value == null) return false; + if (typeof value === "string") { + return PRIMITIVE_TYPES.includes(value); + } else if (Array.isArray(value)) { + return value.map((v) => PRIMITIVE_TYPES.includes(v)).every(Boolean); + } else if (isRef(value)) { + return true; + } else if (isSchema(value)) { + if (value.type === "list") { + return isSimpleType(value.values); + } + return isSimpleType(value.type); + } + return false; } diff --git a/codegen/filters/comments.ts b/codegen/filters/comments.ts index 20190c7..531f3d2 100644 --- a/codegen/filters/comments.ts +++ b/codegen/filters/comments.ts @@ -6,9 +6,9 @@ */ export function blockComment(content: any) { // Ensure the content is a string - const str = typeof content === "string" ? content : String(content); + let str = typeof content === "string" ? content : String(content); - return str + str = str .split("\n") .reduceRight((accumulator, value) => { // Removing tailing empty lines @@ -34,4 +34,7 @@ export function blockComment(content: any) { }) .join("\n") .trimEnd(); + + // Capitalize first sentence. + return str.charAt(0).toUpperCase() + str.slice(1); } diff --git a/codegen/filters/index.ts b/codegen/filters/index.ts index fedd012..839e157 100644 --- a/codegen/filters/index.ts +++ b/codegen/filters/index.ts @@ -14,10 +14,12 @@ export function registerFilters(env: Environment) { env.addFilter(strings.camelCase.name, strings.camelCase); env.addFilter(strings.toJson.name, strings.toJson); env.addFilter(strings.autoQuote.name, strings.autoQuote); - env.addFilter(types.isString.name, types.isString); env.addFilter(types.isArray.name, types.isArray); + env.addFilter(types.enumMatchesType.name, types.enumMatchesType); env.addFilter(types.convertType.name, types.convertType); env.addFilter(engine.isRef.name, engine.isRef); + env.addFilter(engine.isAnyOf.name, engine.isAnyOf); env.addFilter(engine.isSchema.name, engine.isSchema); - env.addFilter(engine.isSchemaOrRef.name, engine.isSchemaOrRef); + env.addFilter(engine.isAnySchema.name, engine.isAnySchema); + env.addFilter(engine.isSimpleType.name, engine.isSimpleType); } diff --git a/codegen/filters/types.ts b/codegen/filters/types.ts index 4a3ef1a..f80c3ab 100644 --- a/codegen/filters/types.ts +++ b/codegen/filters/types.ts @@ -1,13 +1,23 @@ import { SchemaType } from "../engine"; -export function isString(value: any) { - return typeof value === "string"; -} - +/** Check if value is an Array. */ export function isArray(value: any) { return Array.isArray(value); } +/** + * Check if an enum contains at least one value of the specified type. + * + * This is required for properties that support both string and number values and defines an enum. When rendering the + * enum values we check if the enum contains any values for that type and if not we render just the type itself, + * otherwise we enumerate the valid options. + */ +export function enumMatchesType(enumeration: Array | null, type: "number" | "string") { + if (!Array.isArray(enumeration)) return false; + return enumeration.some((value) => typeof value === type); +} + +/** Convert Amalgam type to TypeScript type. */ export function convertType(schema: SchemaType) { let value: string; switch (schema) { @@ -33,8 +43,7 @@ export function convertType(schema: SchemaType) { value = "any"; break; default: - console.warn(`Unexpected type received: ${schema}`); - value = "any"; + throw new Error(`Unexpected Amalgam type received ${JSON.stringify(schema)}`); } return this.env.filters.safe(value); diff --git a/codegen/generator.ts b/codegen/generator.ts index 9196f06..5e4a79c 100644 --- a/codegen/generator.ts +++ b/codegen/generator.ts @@ -1,7 +1,18 @@ import fs from "node:fs"; import path from "node:path"; import nunjucks from "nunjucks"; -import { EngineApi, isRef, isSchemaOrRef, LabelDefinition, Ref, Schema } from "./engine"; +import { + AnyOf, + EngineApi, + isAnyOf, + isAnySchema, + isRef, + isSchema, + isSimpleType, + LabelDefinition, + Ref, + Schema, +} from "./engine"; import { registerFilters } from "./filters"; import { toPascalCase } from "./utils"; @@ -11,8 +22,8 @@ export class Generator { basePath: string; schemaDir: string; clientDir: string; + engineDir: string; ignoredLabels: string[]; - responseShims: Record; /** * Construct a new Generator. @@ -22,36 +33,24 @@ export class Generator { this.basePath = path.resolve(__dirname, "../../src"); this.schemaDir = path.resolve(this.basePath, "types/schemas"); this.clientDir = path.resolve(this.basePath, "client"); + this.engineDir = path.resolve(this.basePath, "engine"); this.doc = doc; this.ignoredLabels = [ - "root_filepath", - "filename", - "filepath", "debug_label", "initialize", "initialize_for_deployment", "set_contained_trainee_maps", - "major_version", - "minor_version", - "point_version", "version", "get_api", + "single_react", + "single_react_series", + ...Object.entries(doc.labels).reduce((ignored, [label, def]) => { + // Ignore all the attribute labels + if (def.attribute != null) ignored.push(label); + return ignored; + }, []), ]; - // Temporary shims until return values are defined - this.responseShims = { - analyze: "null", - get_cases: "shims.GetCasesResponse", - get_feature_attributes: "schemas.FeatureAttributesIndex", - set_feature_attributes: "schemas.FeatureAttributesIndex", - get_marginal_stats: "shims.GetMarginalStatsResponse", - get_params: "shims.GetParamsResponse", - react: "shims.ReactResponse", - react_aggregate: "shims.ReactAggregateResponse", - react_into_features: "null", - train: "shims.TrainResponse", - }; - // Setup template engine const loader = new nunjucks.FileSystemLoader(path.join(__dirname, "templates")); this.env = new nunjucks.Environment(loader, { throwOnUndefined: true }); @@ -72,13 +71,12 @@ export class Generator { private renderClient() { const targetLabels: Record = {}; for (const [label, definition] of Object.entries(this.doc.labels)) { - if (!this.ignoredLabels.includes(label) || definition.attribute) { + if (!this.ignoredLabels.includes(label)) { targetLabels[label] = definition; } } - this.renderFile(this.clientDir, "AbstractBaseClient.ts", "client/AbstractBaseClient.njk", { + this.renderFile(this.engineDir, "Trainee.ts", "engine/Trainee.njk", { labels: targetLabels, - shims: this.responseShims, }); } @@ -103,9 +101,10 @@ export class Generator { // Render label schemas for (const [label, definition] of Object.entries(this.doc.labels)) { - if (this.ignoredLabels.includes(label) || definition.attribute) continue; + if (this.ignoredLabels.includes(label)) continue; // Add schemas for label parameters and/or return value if it has any - if (definition.parameters != null || definition.returns != null) { + // For returns that are just a Ref, ignore them as they can already be referenced directly + if (definition.parameters != null || (definition.returns && !isSimpleType(definition.returns))) { const title = toPascalCase(label); allNames.push(title); this.renderFile(this.schemaDir, `${title}.ts`, "schemas/label.njk", { @@ -151,7 +150,7 @@ export class Generator { imports.push(...this.detectSchemaImports(schema)); } } - if (isSchemaOrRef(label.returns)) { + if (isAnySchema(label.returns) && !isSimpleType(label.returns)) { imports.push(...this.detectSchemaImports(label.returns)); } return [...new Set(imports)].sort(); @@ -162,21 +161,30 @@ export class Generator { * @param schema The schema to check. * @returns The list of referenced schema names. */ - private detectSchemaImports(schema: Ref | Schema): string[] { + private detectSchemaImports(schema: AnyOf | Ref | Schema): string[] { const imports: string[] = []; if (isRef(schema)) { - return [schema.ref]; - } - if (isSchemaOrRef(schema.values)) { - imports.push(...this.detectSchemaImports(schema.values)); - } - if (isSchemaOrRef(schema.additional_indices)) { - imports.push(...this.detectSchemaImports(schema.additional_indices)); - } - if (schema.indices != null) { - for (const value of Object.values(schema.indices)) { - if (isSchemaOrRef(value)) { - imports.push(...this.detectSchemaImports(value)); + imports.push(schema.ref); + } else if (isAnyOf(schema)) { + // Check all parts of the any of list + for (const item of schema.any_of) { + if (isAnySchema(item)) { + imports.push(...this.detectSchemaImports(item)); + } + } + } else if (isSchema(schema)) { + // Check nested parts of the schema + if (isAnySchema(schema.values)) { + imports.push(...this.detectSchemaImports(schema.values)); + } + if (isAnySchema(schema.additional_indices)) { + imports.push(...this.detectSchemaImports(schema.additional_indices)); + } + if (schema.indices != null) { + for (const value of Object.values(schema.indices)) { + if (isAnySchema(value)) { + imports.push(...this.detectSchemaImports(value)); + } } } } diff --git a/codegen/templates/client/AbstractBaseClient.njk b/codegen/templates/client/AbstractBaseClient.njk deleted file mode 100644 index 0caf994..0000000 --- a/codegen/templates/client/AbstractBaseClient.njk +++ /dev/null @@ -1,183 +0,0 @@ -/** - * WARNING: This file is auto generated, do not modify directly, instead modify the template. - * Generated via Howso Engine {{ version }} - */ -import type { Session, Trainee } from "../engine"; -import type { ClientResponse, FeatureAttributesIndex } from "../types"; -import type * as schemas from "../types/schemas"; -import type * as shims from "../types/shims"; -import { DEFAULT_ERROR_MESSAGE, HowsoError, HowsoValidationError } from "./errors"; -import type { CacheMap } from "./utilities/cache"; -import { type Logger, nullLogger } from "./utilities/logger"; - -export interface ClientCache { - trainee: Trainee; - feature_attributes?: FeatureAttributesIndex; -} - -export type ExecuteResponse = { - payload: R; - errors: HowsoError[]; - warnings: string[]; -}; - -export type AbstractBaseClientOptions = { - /** Enable logging for operations through your own methods */ - logger?: Logger; -}; - -export abstract class AbstractBaseClient { - protected abstract cache: CacheMap; - protected logger: Logger; - - constructor(options?: AbstractBaseClientOptions) { - this.logger = options?.logger || nullLogger; - } - - /** - * Prepare payload for an Engine request. - * @param payload The Engine payload. - * @returns The updated Engine payload. - */ - protected prepareRequest(payload: any) { - if (!payload) { - return payload; - } - - // Remove null properties from payload - const filtered = { ...payload }; - for (const key in filtered) { - if (filtered[key as keyof typeof filtered] == null) { - delete filtered[key as keyof typeof filtered]; - } - } - - return filtered; - } - - /** - * Process payload from an Engine response. - * @param data The Engine response. - * @returns The updated Engine response. - */ - protected processResponse(data: any): ExecuteResponse { - if (!data) { - throw new HowsoError("Null or empty response received from Engine."); - } - - if (Array.isArray(data) && data.length == 2) { - const errors: HowsoError[] = []; - const warnings: string[] = []; - const isSuccess = data[0]; - const value = data[1]; - - if (isSuccess) { - // Collect warnings - if (Array.isArray(value?.warnings)) { - for (const msg of value.warnings) { - if (msg != null) warnings.push(msg); - } - } - } else { - // Collect errors - if (value?.errors) { - errors.push(new HowsoValidationError(value.detail, value.code, value.errors)); - } else { - errors.push(new HowsoError(value.detail, value.code)); - } - if (errors.length == 0) { - errors.push(new HowsoError(DEFAULT_ERROR_MESSAGE)); - } - } - - errors.forEach(this.logger.error); - warnings.forEach(this.logger.warn); - - return { - errors, - warnings, - payload: isSuccess ? value?.payload : undefined, - }; - } else if (["string", "number", "bigint", "boolean"].indexOf(typeof data) != -1) { - return { errors: [], warnings: [], payload: data }; - } - - throw new HowsoError("Malformed response received from Engine."); - } - - /** Setup the client instance for interacting with the Howso Engine. */ - public abstract setup(): Promise; - - /** - * Execute a label of an Engine entity. - * @param handle The identifier of the entity. - * @param label The name of the method to execute. - * @param data The data to pass to the method. - * @param throwErrors If errors should be thrown automatically. - */ - public abstract execute( - handle: string, - label: string, - data: D, - throwErrors?: boolean, - ): Promise>; - - /** Create a new Trainee. */ - public abstract createTrainee(properties: Omit): Promise; - - /** Update an existing Trainee. */ - public abstract updateTrainee(trainee: Trainee): Promise; - - /** Copy an existing Trainee. */ - public abstract copyTrainee(traineeId: string, name?: string): Promise; - - /** Get an existing Trainee by Id. */ - public abstract getTrainee(traineeId: string): Promise; - - /** Search existing Trainees. */ - public abstract queryTrainees(keywords: string | string[]): Promise; - - /** Delete a Trainee. */ - public abstract deleteTrainee(traineeId: string): Promise; - - /** Acquire the resources for a Trainee. */ - public abstract acquireTraineeResources(traineeId: string): Promise; - - /** Release the resources for a Trainee. */ - public abstract releaseTraineeResources(traineeId: string): Promise; - - /** Persist a Trainee to storage. **/ - public abstract persistTrainee(traineeId: string): Promise; - - /** Automatically resolve a Trainee and ensure it is loaded. */ - protected abstract autoResolveTrainee(traineeId: string): Promise; - - /** Automatically persist Trainee object when appropriate based on persistence level. */ - protected abstract autoPersistTrainee(traineeId: string): Promise; - - /** Get active Session. */ - public abstract getActiveSession(): Promise>; - - /** Begin a new Session. */ - public abstract beginSession(name?: string, metadata?: Record): Promise; -{% for label, def in labels | dictsort %} -{% set requestName = "schemas." + label | pascalCase + "Request" %} -{% set responseName = "schemas." + label | pascalCase + "Response" %} - /** - * {{ def.description | capitalize | blockComment | safe | indent(2) }} - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async {{ label | camelCase }}(traineeId: string{% if def.parameters %}, request: {{ requestName }}{% endif %}): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute<{% if def.returns %}{{ responseName }}{% elif label in shims %}{{ shims[label] }}{% else %}any{% endif %}>(trainee.id, "{{ label }}", {% if def.parameters %}request{% else %}{}{% endif %}); - {%- if not def.read_only %} - this.autoPersistTrainee(trainee.id); - {%- endif %} - return { payload: response.payload, warnings: response.warnings }; - } -{%- if not loop.last %} -{% endif %} -{%- endfor %} -} \ No newline at end of file diff --git a/codegen/templates/engine/Trainee.njk b/codegen/templates/engine/Trainee.njk new file mode 100644 index 0000000..e630b90 --- /dev/null +++ b/codegen/templates/engine/Trainee.njk @@ -0,0 +1,166 @@ +{%- from "schemas/_macros.njk" import field %} +/** + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly, instead modify the Trainee.njk template file. + * + * Generated via Howso Engine {{ version }} + */ +import { AbstractBaseClient } from "../client/AbstractBaseClient"; +import { batcher, BatchOptions } from "../client/utilities"; +import type { BaseTrainee, ClientBatchResponse, ClientResponse } from "../types"; +import type * as schemas from "../types/schemas"; + +/** + * The interface for interacting with a Trainee. Should not be instantiated directly. Instead create or request a + * Trainee using the client. + */ +export class Trainee implements BaseTrainee { + public readonly id: string; + protected readonly client: AbstractBaseClient; + protected _name: BaseTrainee["name"]; + protected _persistence: BaseTrainee["persistence"]; + protected _metadata: BaseTrainee["metadata"]; + protected _deleted = false; + + constructor(client: AbstractBaseClient, obj: BaseTrainee) { + this.client = client; + this.id = obj.id; + this._name = obj.name; + this._metadata = obj.metadata; + this._persistence = obj.persistence; + } + + public get name() { + return this._name ?? null; + } + + public get persistence() { + return this._persistence || "allow"; + } + + public get metadata(): Readonly<{ [key: string]: any }> { + return this._metadata || {}; + } + + public get isDeleted(): boolean { + return this._deleted; + } + + public async update(properties: Partial): Promise { + const trainee = await this.client.updateTrainee({ ...properties, id: this.id }); + this._name = trainee.name; + this._metadata = trainee.metadata; + this._persistence = trainee.persistence; + } + + public async delete(): Promise { + await this.client.deleteTrainee(this.id); + this._deleted = true; + } + + public async copy(name?: string): Promise { + return await this.client.copyTrainee(this.id, name); + } + + public async acquireResources(): Promise { + return await this.client.acquireTraineeResources(this.id); + } + + public async releaseResources(): Promise { + return await this.client.releaseTraineeResources(this.id); + } + + public async persist(): Promise { + await this.client.persistTrainee(this.id); + } + + /** + * Train data into the Trainee using batched requests to the Engine. + * @param traineeId The Trainee identifier. + * @param request The train parameters. + * @returns The train result. + */ + public async batchTrain(request: schemas.TrainRequest): Promise> { + const { cases = [], ...rest } = request; + + // Limit to 10,000 cases at once maximum + const batchOptions: BatchOptions = { startSize: 100, limits: [1, 10000] }; + + let num_trained = 0; + let status = null; + const ablated_indices: number[] = []; + const warnings: string[][] = []; + + // Batch scale the requests + await batcher( + async function* (this: Trainee, size: number) { + let offset = 0; + while (offset < cases.length) { + const response = await this.train({ + ...rest, + cases: cases.slice(offset, offset + size), + }); + offset += size; + if (response.payload.status) status = response.payload.status; + if (response.payload.num_trained) num_trained += response.payload.num_trained; + if (response.payload.ablated_indices) ablated_indices.push(...response.payload.ablated_indices); + + // Warnings will be already output to the provided Logger in prepareResponse. Just aggregate. + if (response.warnings.length > 0) { + warnings.push(response.warnings); + } + size = yield; + } + }.bind(this), + batchOptions, + ); + + return { payload: { num_trained, status, ablated_indices }, warnings }; + } + + /** + * Include the active session in a request if not defined. + * @param request The Trainee request object. + * @returns The Trainee request object with a session. + */ + protected async includeSession>(request: T): Promise { + if (!request.session) { + // Include the active session + const session = await this.client.getActiveSession(); + return { ...request, session: session.id }; + } + return request; + } + +{% for label, def in labels | dictsort %} + {%- set requestName = "schemas." + label | pascalCase + "Request" %} + {%- if def.returns | isRef %} + {%- set responseName = "schemas." + def.returns.ref %} + {%- elif def.returns | isSimpleType %} + {%- set responseName = field(def.returns) %} + {%- elif def.returns %} + {%- set responseName = "schemas." + label | pascalCase + "Response" %} + {%- else %} + {%- set responseName = "null" %} + {%- endif %} + /** + * {{ def.description | blockComment | safe | indent(2) }} + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async {{ label | camelCase }}({% if def.parameters | length %}request: {{ requestName }}{% endif %}): Promise> { + await this.client.autoResolveTrainee(this.id); + {%- if def.use_active_session and def.parameters %} + request = await this.includeSession(request); + {%- endif %} + const response = await this.client.execute<{{ responseName }}>(this.id, "{{ label }}", {% if def.parameters | length %}request{% else %}{}{% endif %}); + {%- if not def.read_only %} + this.client.autoPersistTrainee(this.id); + {%- endif %} + return { payload: response.payload, warnings: response.warnings }; + } +{%- if not loop.last %} +{% endif %} +{%- endfor %} +} diff --git a/codegen/templates/schemas/_header.njk b/codegen/templates/schemas/_header.njk index e528a68..2629eb0 100644 --- a/codegen/templates/schemas/_header.njk +++ b/codegen/templates/schemas/_header.njk @@ -1,12 +1,15 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. +{%- if description %} * * {{ name }} -{%- if description %} * - * {{ description | capitalize | blockComment | safe }} + * {{ description | blockComment | safe }} {%- endif %} */ {%- for item in imports %} + {%- if item != name %} import type { {{ item }} } from "./{{ item }}"; + {%- endif %} {%- endfor %} \ No newline at end of file diff --git a/codegen/templates/schemas/_macros.njk b/codegen/templates/schemas/_macros.njk index 35d0e80..4b51975 100644 --- a/codegen/templates/schemas/_macros.njk +++ b/codegen/templates/schemas/_macros.njk @@ -1,6 +1,6 @@ {%- macro field(schema, type=null) %} {%- if not type %} - {%- if schema | isString or schema | isArray %} + {%- if schema is string or schema | isArray %} {%- set type = schema %} {%- else %} {%- set type = schema.type %} @@ -29,6 +29,8 @@ null {%- else -%} any {%- endif -%} + {%- elif schema | isAnyOf -%} +{% include "schemas/composition/_anyOf.njk" %} {%- else -%} {{ type | convertType }} {%- endif -%} @@ -36,13 +38,17 @@ any {%- endmacro %} -{%- macro comment(schema) %} +{%- macro comment(schema, default=null) %} {%- if schema.description %} /** - * {{ schema.description | capitalize | blockComment | safe }} + * {{ schema.description | blockComment | safe }} {%- if schema.default != null %} * @default {{ schema.default | toJson | safe }} {%- endif %} */ +{%- elif default %} +/** + * {{ default }} + */ {%- endif %} {%- endmacro %} diff --git a/codegen/templates/schemas/composition/_anyOf.njk b/codegen/templates/schemas/composition/_anyOf.njk new file mode 100644 index 0000000..e78f308 --- /dev/null +++ b/codegen/templates/schemas/composition/_anyOf.njk @@ -0,0 +1,4 @@ +{%- from "schemas/_macros.njk" import field %} +{%- for item in schema.any_of -%} +{{ field(item) }}{% if not loop.last %} | {% endif %} +{%- endfor %} \ No newline at end of file diff --git a/codegen/templates/schemas/label.njk b/codegen/templates/schemas/label.njk index 7f40cbe..aa4a06f 100644 --- a/codegen/templates/schemas/label.njk +++ b/codegen/templates/schemas/label.njk @@ -1,6 +1,7 @@ {%- include "schemas/_header.njk" %} {%- from "schemas/_macros.njk" import field, comment %} -{% if parameters %} +{% if parameters | length %} +/** Request parameters of the Trainee method: {{ label | camelCase }}. */ export type {{ name }}Request = { {%- for key, schema in parameters | dictsort -%} {{ comment(schema) | indent(2) }} @@ -11,7 +12,8 @@ export type {{ name }}Request = { }; {% endif -%} -{%- if returns %} +{%- if returns and not returns | isSimpleType %} +/** Response of the Trainee method: {{ label | camelCase }}. */ export type {{ name }}Response = {{ field(returns) }}; {%- endif %} \ No newline at end of file diff --git a/codegen/templates/schemas/schema.njk b/codegen/templates/schemas/schema.njk index 102caa4..9bf6fe1 100644 --- a/codegen/templates/schemas/schema.njk +++ b/codegen/templates/schemas/schema.njk @@ -1,5 +1,5 @@ {%- include "schemas/_header.njk" %} {%- from "schemas/_macros.njk" import field, comment %} -{{ comment(schema) }} +{{ comment(schema, name + " schema.") }} export type {{ name | pascalCase }} = {{ field(schema) }}; diff --git a/codegen/templates/schemas/types/_assoc.njk b/codegen/templates/schemas/types/_assoc.njk index 6765408..1efde18 100644 --- a/codegen/templates/schemas/types/_assoc.njk +++ b/codegen/templates/schemas/types/_assoc.njk @@ -3,17 +3,12 @@ { {%- for key, value in schema.indices | dictsort -%} {{ comment(value) | indent(2) }} - {{ key | autoQuote }}{% if not value | isSchemaOrRef or value.required != true %}?{% endif %}: {{ field(value) | indent(2) }}; + {{ key | autoQuote }}{% if not value | isAnySchema or value.required != true %}?{% endif %}: {{ field(value) | indent(2) }}; {%- endfor %} } {%- if schema.additional_indices %} & Record {%- endif %} - {%- if schema.dynamic_indices %} - {%- for dynamic_key, dynamic_value in schema.dynamic_indices | dictsort %} - & Record<`{{ dynamic_key }}`, {{ field(dynamic_value) }}> - {%- endfor %} - {%- endif %} {%- elif schema.additional_indices -%} Record {%- else -%} diff --git a/codegen/templates/schemas/types/_number.njk b/codegen/templates/schemas/types/_number.njk index 449a49c..01bdde9 100644 --- a/codegen/templates/schemas/types/_number.njk +++ b/codegen/templates/schemas/types/_number.njk @@ -1,6 +1,8 @@ -{%- if schema.enum -%} - {%- for item in schema.enum -%} +{%- if schema.enum | enumMatchesType("number") -%} + {%- for item in schema.enum | sort -%} + {%- if item is number -%} {{ item }}{% if not loop.last %} | {% endif %} + {%- endif -%} {%- endfor -%} {%- else -%} number diff --git a/codegen/templates/schemas/types/_string.njk b/codegen/templates/schemas/types/_string.njk index a8117fe..af31d7e 100644 --- a/codegen/templates/schemas/types/_string.njk +++ b/codegen/templates/schemas/types/_string.njk @@ -1,6 +1,8 @@ -{%- if schema.enum -%} - {%- for item in schema.enum -%} +{%- if schema.enum | enumMatchesType("string") -%} + {%- for item in schema.enum | sort -%} + {%- if item is string -%} "{{ item }}"{% if not loop.last %} | {% endif %} + {%- endif -%} {%- endfor -%} {%- else -%} string diff --git a/codegen/utils.ts b/codegen/utils.ts index d5d4603..5d6f9c5 100644 --- a/codegen/utils.ts +++ b/codegen/utils.ts @@ -1,7 +1,3 @@ -export function capitalize(value: string): string { - return value.charAt(0).toUpperCase() + value.slice(1); -} - export function toPascalCase(value: string) { return value .replace(/_+/g, " ") diff --git a/package-lock.json b/package-lock.json index 06a5328..7635e68 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.0.0", "license": "AGPL-3.0-only", "dependencies": { - "@howso/amalgam-lang": "^55.0.0", + "@howso/amalgam-lang": "^57.0.1", "uuid": "^9.0.0" }, "devDependencies": { @@ -1146,9 +1146,9 @@ } }, "node_modules/@howso/amalgam-lang": { - "version": "55.0.0", - "resolved": "https://registry.npmjs.org/@howso/amalgam-lang/-/amalgam-lang-55.0.0.tgz", - "integrity": "sha512-PG8cewFUShq5altkF1Zt28/PFILgieC/wI1wCmTibwyeWB4M80CUCeRTpJnBLXJmXrgTalc19cKhBV3aTgEsQg==" + "version": "57.0.1", + "resolved": "https://registry.npmjs.org/@howso/amalgam-lang/-/amalgam-lang-57.0.1.tgz", + "integrity": "sha512-NwebTGmAQ8duMe8hqosmobB8tl1VqUFU6jT+X1bxRVOHvuDabmyvJ+HRG4L0kbyhXOTb4GLH9VnDBDD1RWl5NA==" }, "node_modules/@humanwhocodes/module-importer": { "version": "1.0.1", @@ -8199,9 +8199,9 @@ } }, "@howso/amalgam-lang": { - "version": "55.0.0", - "resolved": "https://registry.npmjs.org/@howso/amalgam-lang/-/amalgam-lang-55.0.0.tgz", - "integrity": "sha512-PG8cewFUShq5altkF1Zt28/PFILgieC/wI1wCmTibwyeWB4M80CUCeRTpJnBLXJmXrgTalc19cKhBV3aTgEsQg==" + "version": "57.0.1", + "resolved": "https://registry.npmjs.org/@howso/amalgam-lang/-/amalgam-lang-57.0.1.tgz", + "integrity": "sha512-NwebTGmAQ8duMe8hqosmobB8tl1VqUFU6jT+X1bxRVOHvuDabmyvJ+HRG4L0kbyhXOTb4GLH9VnDBDD1RWl5NA==" }, "@humanwhocodes/module-importer": { "version": "1.0.1", diff --git a/package.json b/package.json index f34a970..eedbd88 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "lib" ], "dependencies": { - "@howso/amalgam-lang": "^55.0.0", + "@howso/amalgam-lang": "^57.0.1", "uuid": "^9.0.0" }, "devDependencies": { diff --git a/src/assets/howso.caml b/src/assets/howso.caml index 0029a57..b6129c9 100644 Binary files a/src/assets/howso.caml and b/src/assets/howso.caml differ diff --git a/src/assets/migrations.caml b/src/assets/migrations.caml index 58a4ae7..db2714d 100644 Binary files a/src/assets/migrations.caml and b/src/assets/migrations.caml differ diff --git a/src/client/AbstractBaseClient.ts b/src/client/AbstractBaseClient.ts index 6cab25b..c2925bf 100644 --- a/src/client/AbstractBaseClient.ts +++ b/src/client/AbstractBaseClient.ts @@ -1,18 +1,11 @@ -/** - * WARNING: This file is auto generated, do not modify directly, instead modify the template. - * Generated via Howso Engine 86.1.0+alpha - */ import type { Session, Trainee } from "../engine"; -import type { ClientResponse, FeatureAttributesIndex } from "../types"; -import type * as schemas from "../types/schemas"; -import type * as shims from "../types/shims"; +import type { BaseTrainee } from "../types"; import { DEFAULT_ERROR_MESSAGE, HowsoError, HowsoValidationError } from "./errors"; import type { CacheMap } from "./utilities/cache"; import { type Logger, nullLogger } from "./utilities/logger"; export interface ClientCache { trainee: Trainee; - feature_attributes?: FeatureAttributesIndex; } export type ExecuteResponse = { @@ -80,7 +73,7 @@ export abstract class AbstractBaseClient { } } else { // Collect errors - if (value?.errors) { + if (value?.errors || value?.code === "invalid") { errors.push(new HowsoValidationError(value.detail, value.code, value.errors)); } else { errors.push(new HowsoError(value.detail, value.code)); @@ -126,7 +119,7 @@ export abstract class AbstractBaseClient { public abstract createTrainee(properties: Omit): Promise; /** Update an existing Trainee. */ - public abstract updateTrainee(trainee: Trainee): Promise; + public abstract updateTrainee(trainee: BaseTrainee): Promise; /** Copy an existing Trainee. */ public abstract copyTrainee(traineeId: string, name?: string): Promise; @@ -150,979 +143,14 @@ export abstract class AbstractBaseClient { public abstract persistTrainee(traineeId: string): Promise; /** Automatically resolve a Trainee and ensure it is loaded. */ - protected abstract autoResolveTrainee(traineeId: string): Promise; + public abstract autoResolveTrainee(traineeId: string): Promise; /** Automatically persist Trainee object when appropriate based on persistence level. */ - protected abstract autoPersistTrainee(traineeId: string): Promise; + public abstract autoPersistTrainee(traineeId: string): Promise; /** Get active Session. */ public abstract getActiveSession(): Promise>; /** Begin a new Session. */ public abstract beginSession(name?: string, metadata?: Record): Promise; - - /** - * Adds the specified feature on all cases for a trainee that match the specified condition. overwrites features that - * if condition are not specified, adds feature for all cases and to the model. if condition is an empty assoc, will not modify feature metadata in the model. - * if feature attributes are passed in, will also set the model's feature attributes. - * updates the accumulated data mass for the model proportional to the number of cases modified. - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async addFeature(traineeId: string, request: schemas.AddFeatureRequest): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "add_feature", request); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Analyzes the data to compute the appropriate statistics, uncertainties, and select parameters as appropriate. - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async analyze(traineeId: string, request: schemas.AnalyzeRequest): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "analyze", request); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Append cases to a series - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async appendToSeriesStore( - traineeId: string, - request: schemas.AppendToSeriesStoreRequest, - ): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "append_to_series_store", request); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Automatically analyze the model using stored parameters from previous analyze calls - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async autoAnalyze(traineeId: string): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "auto_analyze", {}); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Clear values that were imputed during a specified session, but won't clear values that were manually set by user after the impute - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async clearImputedData( - traineeId: string, - request: schemas.ClearImputedDataRequest, - ): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "clear_imputed_data", request); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Creates a copy of a trainee and stores it a subtrainee, returns the name of the copied trainee on success - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async copySubtrainee(traineeId: string, request: schemas.CopySubtraineeRequest): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "copy_subtrainee", request); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Creates a new instance of a contained trainee as specified by the entity label "trainee". - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async createSubtrainee( - traineeId: string, - request: schemas.CreateSubtraineeRequest, - ): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "create_subtrainee", request); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Removes replay specified by session and any references within cases - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async deleteSession(traineeId: string, request: schemas.DeleteSessionRequest): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "delete_session", request); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Destroys the instance of the trainee specified by the parameter "trainee". - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async deleteSubtrainee( - traineeId: string, - request: schemas.DeleteSubtraineeRequest, - ): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "delete_subtrainee", request); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Edit feature values for the specified cases. - * cases are specified by either case_indices or by the condition. if neither is provided, edits all cases. - * updates the accumulated data mass for the model proportional to the number of cases and features modified. - * returns null if invalid features specified or an assoc with "count" - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async editCases(traineeId: string, request: schemas.EditCasesRequest): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "edit_cases", request); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Evaluate custom amalgam code for feature values of every case in the model and returns - * a list of the custom code's return values for each feature specified. - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async evaluate(traineeId: string, request: schemas.EvaluateRequest): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "evaluate", request); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Execute any method in the api directly on any child trainee of this trainee, used for hierarchy operations. - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async executeOnSubtrainee( - traineeId: string, - request: schemas.ExecuteOnSubtraineeRequest, - ): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "execute_on_subtrainee", request); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Export trainee's metadata, case and session data into json files. - * this method should be run by a script from the ./migrations folder - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async exportTrainee(traineeId: string, request: schemas.ExportTraineeRequest): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "export_trainee", request); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Get auto-ablation parameters set by #set_auto_ablation_params - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async getAutoAblationParams(traineeId: string): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "get_auto_ablation_params", {}); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Returns assoc with features and cases - a list of lists of all feature values. retrieves all feature values for cases for - * all (unordered) sessions in the order they were trained within each session. if a session is specified, only that session's - * cases wil be output. - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async getCases( - traineeId: string, - request: schemas.GetCasesRequest, - ): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "get_cases", request); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Returns an assoc with case distances, containing a list of case session indices and a list of lists (matrix) of the computed distances. - * in the following format: - * { - * 'column_case_indices' : [ session-indices ], - * 'row_case_indices' : [ session-indices ], - * 'distances': [ [ pairwise distances ] ] - * } - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async getDistances(traineeId: string, request: schemas.GetDistancesRequest): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "get_distances", request); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Returns the full entity path to a child trainee provided its unique trainee id if it is contained in the hierarchy. - * iterates down the hierarchy searching for a trainee that matches the specified id, returns null if not found or - * a string error if found but trainee is stored externally as an independent trainee. - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async getEntityPathById( - traineeId: string, - request: schemas.GetEntityPathByIdRequest, - ): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "get_entity_path_by_id", request); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Method to return the list of all model attributes that can be exported/imported - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async getExportAttributes(traineeId: string): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "get_export_attributes", {}); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Retrieve the top or bottom number of cases for a specified feature, sorted top to bottom for top, and bottom to top for bottom - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async getExtremeCases( - traineeId: string, - request: schemas.GetExtremeCasesRequest, - ): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "get_extreme_cases", request); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Output all feature attributes - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async getFeatureAttributes(traineeId: string): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "get_feature_attributes", {}); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Computes the conviction for each feature and returns an assoc of feature -> conviction value - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async getFeatureConviction( - traineeId: string, - request: schemas.GetFeatureConvictionRequest, - ): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "get_feature_conviction", request); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Pull the hierarchy for a trainee, returns an assoc of: - * the currently contained hierarchy as a nested assoc with (false) for trainees that are stored independently. - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async getHierarchy(traineeId: string): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "get_hierarchy", {}); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Outputs all marginal stats (min, max, median, mean, mode, count, uniques, mean_absdev, variance, stddev, skew, kurtosis, entropy) - * for all features in the format of feature -> assoc stat -> value. the marginal stats can be computed for a subset of the data using condition, precision, and num_cases - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async getMarginalStats( - traineeId: string, - request: schemas.GetMarginalStatsRequest, - ): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "get_marginal_stats", request); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Get metadata for model - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async getMetadata(traineeId: string): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "get_metadata", {}); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Returns the total number of training cases for trainee - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async getNumTrainingCases(traineeId: string): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "get_num_training_cases", {}); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Returns a list of computed distances between respective cases specified in either from_values or from_case_indices to to_values or to_case_indices. - * if one case is specified in any of the lists, all respective distances are computed to/from that one case. - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async getPairwiseDistances( - traineeId: string, - request: schemas.GetPairwiseDistancesRequest, - ): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "get_pairwise_distances", request); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Return the full internal parameters map if no parameters are specified. - * if any of the parameters are specified, then gethyperparameters is called, which uses the specified parameters to find the most suitable set of hyperparameters to return - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async getParams( - traineeId: string, - request: schemas.GetParamsRequest, - ): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "get_params", request); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Returns the trainee's !revision - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async getRevision(traineeId: string): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "get_revision", {}); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Returns a list of all of the training sessions, assoc of id->session, and whatever other attributes specified. - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async getSessions(traineeId: string, request: schemas.GetSessionsRequest): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "get_sessions", request); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Return list of all session indices for a specified session. - * session indices are 0-based index of number of the case for the session used for replays; may change if cases are removed - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async getSessionIndices( - traineeId: string, - request: schemas.GetSessionIndicesRequest, - ): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "get_session_indices", request); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Returns all the metadata for a specified session - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async getSessionMetadata( - traineeId: string, - request: schemas.GetSessionMetadataRequest, - ): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "get_session_metadata", request); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Return list of all session training indices for a specified session. - * session training indices are 0-based index of the case, ordered by training during the session; is not changed - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async getSessionTrainingIndices( - traineeId: string, - request: schemas.GetSessionTrainingIndicesRequest, - ): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "get_session_training_indices", request); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Returns the substitution map - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async getSubstituteFeatureValues(traineeId: string): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "get_substitute_feature_values", {}); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Returns the trainee's unique id - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async getTraineeId(traineeId: string): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "get_trainee_id", {}); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * The version stored in trainee - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async getTraineeVersion(traineeId: string): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "get_trainee_version", {}); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Imputes the model, filling in all the (null) feature values - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async impute(traineeId: string, request: schemas.ImputeRequest): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "impute", request); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Attempts to load a subtrainee with the following optional parameters. - * if a parameter is not specified, it will look to this entity's own label of the same name. - * if the saved instance does not exist the existing trainee will remain unmodified and the function will return null. - * assumes loaded trainee filenames need to be escaped - * returns the trainee name if successful, null if not - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async loadSubtrainee(traineeId: string, request: schemas.LoadSubtraineeRequest): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "load_subtrainee", request); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Moves all cases that match the specified conditions in the hierarchy of the specified trainee - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async moveCases(traineeId: string, request: schemas.MoveCasesRequest): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "move_cases", request); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Run reacts in a batch, output a an assoc of list of outputs from each individual react. - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async react(traineeId: string, request: schemas.ReactRequest): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "react", request); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Computes, caches, and returns specified details and feature prediction statistics such as mean decrease in accuracy (mda), residuals (accuracy, mean absolute error), - * precision, recall, etc. returns details and feature prediction stats for all features in the format of feature -> assoc stat -> value - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async reactAggregate( - traineeId: string, - request: schemas.ReactAggregateRequest, - ): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "react_aggregate", request); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Computes the convictions of an average case for each given hypothetical set of cases specified - * output an assoc react key -> list of corresponding values from each individual group. - * example output for 2 groups: - * (assoc - * "base_model_average_distance_contribution" (list 4.0 4.1) - * "combined_model_average_distance_contribution" (list 4.05 3.9) - * "distance_contributions" (list 4.5 3.2) - * ) - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async reactGroup(traineeId: string, request: schemas.ReactGroupRequest): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "react_group", request); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Computes various data, such as familiarity convictions and distance contribution for each case in the model and stores them into specified features. - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async reactIntoFeatures( - traineeId: string, - request: schemas.ReactIntoFeaturesRequest, - ): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "react_into_features", request); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * React in a series until a series_stop_map condition is met. aggregates rows of data corresponding to the specified context, action, - * derived_context and derived_action features, utilizing previous rows to derive values as necessary. outputs an assoc of "action_features" and - * corresponding "series" where "series" is the completed 'matrix' for the corresponding action_features and derived_action_features. - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async reactSeries(traineeId: string, request: schemas.ReactSeriesRequest): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "react_series", request); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Reduce the trained data by removing cases which have an influence weight entropy that falls above - * a threshold. - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async reduceData(traineeId: string, request: schemas.ReduceDataRequest): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "reduce_data", request); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Removes all cases that match the specified conditions from trainee - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async removeCases(traineeId: string, request: schemas.RemoveCasesRequest): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "remove_cases", request); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Removes the specified feature on all cases for a trainee that match the specified condition - * if conditions are not specified, removes feature for all cases and from the model, if condition is an empty assoc, leaves the feature metadata in the model. - * updates the accumulated data mass for the model proportional to the number of cases modified. - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async removeFeature(traineeId: string, request: schemas.RemoveFeatureRequest): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "remove_feature", request); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Clears stored series - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async removeSeriesStore( - traineeId: string, - request: schemas.RemoveSeriesStoreRequest, - ): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "remove_series_store", request); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Rename a contained trainee - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async renameSubtrainee( - traineeId: string, - request: schemas.RenameSubtraineeRequest, - ): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "rename_subtrainee", request); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Resets all hyperparameters and thresholds back to original values, while leaving feature definitions alone - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async resetParams(traineeId: string): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "reset_params", {}); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Saves a subtrainee with the following optional parameters, escapes trainee filenames on save - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async saveSubtrainee(traineeId: string, request: schemas.SaveSubtraineeRequest): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "save_subtrainee", request); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Sets the model to auto-ablate by tracking its size and training certain cases as weights - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async setAutoAblationParams( - traineeId: string, - request: schemas.SetAutoAblationParamsRequest, - ): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "set_auto_ablation_params", request); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Sets the model to auto-analyze by tracking its size and notifying the clients in train responses when it should be analyzed - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async setAutoAnalyzeParams( - traineeId: string, - request: schemas.SetAutoAnalyzeParamsRequest, - ): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "set_auto_analyze_params", request); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Set all features and their attributes for the trainee, and returns the updated feature attributes - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async setFeatureAttributes( - traineeId: string, - request: schemas.SetFeatureAttributesRequest, - ): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "set_feature_attributes", request); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Set the influence weight threshold for outputting only the k neighbors whose influence weight is <= to this threshold - * default value is 0.99 - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async setInfluenceWeightThreshold( - traineeId: string, - request: schemas.SetInfluenceWeightThresholdRequest, - ): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "set_influence_weight_threshold", request); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Set metadata for model - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async setMetadata(traineeId: string, request: schemas.SetMetadataRequest): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "set_metadata", request); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Sets internal hyperparameters - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async setParams(traineeId: string, request: schemas.SetParamsRequest): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "set_params", request); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Set trainee's unique parent id - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async setParentId(traineeId: string, request: schemas.SetParentIdRequest): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "set_parent_id", request); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Set the random seed on a trainee - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async setRandomSeed(traineeId: string, request: schemas.SetRandomSeedRequest): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "set_random_seed", request); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Set session metadata for a specified session. - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async setSessionMetadata( - traineeId: string, - request: schemas.SetSessionMetadataRequest, - ): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "set_session_metadata", request); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Sets substitution feature values used in case generation - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async setSubstituteFeatureValues( - traineeId: string, - request: schemas.SetSubstituteFeatureValuesRequest, - ): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "set_substitute_feature_values", request); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Set trainee's unique id - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async setTraineeId(traineeId: string, request: schemas.SetTraineeIdRequest): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "set_trainee_id", request); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * React to a provided context. if desired_conviction is provided, it does a generative react. - * - * output: - * default output of this method is a react object in the format of - * , where all_action_values is a list of all action - * values, reacted/generated and derived, in the same order as all_action_features, e.g., [2, "a", .75384] to match ['width','name','height'] - * if details is specified, the react object will contain appropriate additional details properties and values, - * details example: { 'action_values': [2, "a", .75384], 'action_features' : ['width','name','height'], 'residual_conviction': 1.3, - * 'influential_cases' : etc... } - * see api docs for documentation of all output properties - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async singleReact(traineeId: string, request: schemas.SingleReactRequest): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "single_react", request); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * React in a series until a series_stop_map condition is met. aggregates rows of data corresponding to the specified context, action, - * derived_context and derived_action features, utilizing previous rows to derive values as necessary. outputs an assoc of "action_features" and - * corresponding "series" where "series" is the completed 'matrix' for the corresponding action_features and derived_action_features. - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async singleReactSeries( - traineeId: string, - request: schemas.SingleReactSeriesRequest, - ): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "single_react_series", request); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Train the passed in cases, filtering out cases that match optionally passed in ablation parameters - * returns a response object in the following format: - * (associate - * "num_trained" num_trained_cases - * "ablated_indices" (list of session training indices for the ablated cases) - * "status" "status output message" - * ) - * list of 'status' values: - * (null) - default output, no status output - * "analyzed" - if auto analysis is enabled and model has grown large enough to be analyzed again and was analyzed - * "analyze" - if auto analysis is enabled and model has grown large enough to be analyzed again but was not analyzed - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async train(traineeId: string, request: schemas.TrainRequest): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "train", request); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } - - /** - * Update version to latest, auto importing any exported data. - * @param traineeId The Trainee identifier. - * @param request The operation parameters. - * @returns The response of the operation, including any warnings. - */ - public async upgradeTrainee(traineeId: string, request: schemas.UpgradeTraineeRequest): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "upgrade_trainee", request); - this.autoPersistTrainee(trainee.id); - return { payload: response.payload, warnings: response.warnings }; - } } diff --git a/src/client/worker/HowsoWorkerClient.node.test.ts b/src/client/worker/HowsoWorkerClient.node.test.ts index 75b9682..52644bd 100644 --- a/src/client/worker/HowsoWorkerClient.node.test.ts +++ b/src/client/worker/HowsoWorkerClient.node.test.ts @@ -27,7 +27,8 @@ describe("Node HowsoWorkerClient", () => { const data = JSON.parse(readFileSync(dataPath, { encoding: "utf8" })); const feature_attributes = await inferFeatureAttributes(data, "array", {}); const trainee = await client.createTrainee({ name: "My Trainee" }); - await client.setFeatureAttributes(trainee.id, { feature_attributes }); + const { payload: set_feature_attributes } = await trainee.setFeatureAttributes({ feature_attributes }); + expect(set_feature_attributes).toEqual(feature_attributes); }); afterAll(() => { diff --git a/src/client/worker/HowsoWorkerClient.ts b/src/client/worker/HowsoWorkerClient.ts index 17fdd8a..49aac38 100644 --- a/src/client/worker/HowsoWorkerClient.ts +++ b/src/client/worker/HowsoWorkerClient.ts @@ -8,8 +8,7 @@ import { import type { Worker as NodeWorker } from "node:worker_threads"; import { v4 as uuid } from "uuid"; import { Session, Trainee } from "../../engine"; -import type { BaseTrainee, ClientBatchResponse, TrainResponse } from "../../types"; -import type * as schemas from "../../types/schemas"; +import type { BaseTrainee } from "../../types"; import { AbstractBaseClient, type AbstractBaseClientOptions, @@ -17,7 +16,7 @@ import { type ExecuteResponse, } from "../AbstractBaseClient"; import { HowsoError, RequiredError } from "../errors"; -import { batcher, BatchOptions, CacheMap } from "../utilities"; +import { CacheMap } from "../utilities"; import { AbstractFileSystem } from "./filesystem"; export type ClientOptions = AbstractBaseClientOptions & { @@ -26,7 +25,7 @@ export type ClientOptions = AbstractBaseClientOptions & { /** Trainee migrations caml file. This will not be loaded unless a function request it, such as `upgradeTrainee` */ migrationsUrl?: string | URL; /** Enable tracing all Trainee operations for debugging. */ - trace?: boolean; + trace?: AmalgamOptions["trace"]; }; export class HowsoWorkerClient extends AbstractBaseClient { @@ -84,7 +83,7 @@ export class HowsoWorkerClient extends AbstractBaseClient { const result = this.processResponse(response); if (throwErrors && Array.isArray(result.errors)) { for (const err of result.errors) { - throw new HowsoError(err?.message, err?.code); + throw err; } } return result; @@ -141,13 +140,32 @@ export class HowsoWorkerClient extends AbstractBaseClient { return entities; } + /** + * Constructs Trainee object from it's Engine metadata. + * + * @param traineeId The Trainee identifier. + * @returns The Trainee object and its feature attributes. + */ + protected async getTraineeFromEngine(traineeId: string): Promise { + const { payload } = await this.execute>(traineeId, "get_metadata", {}); + if (!payload) { + throw new HowsoError(`Trainee "${traineeId}" not found.`, "not_found"); + } + return new Trainee(this, { + id: traineeId, + name: payload?.name, + persistence: payload?.persistence ?? "allow", + metadata: payload?.metadata, + }); + } + /** * Automatically resolve a Trainee and ensure it is loaded given an identifier. * * @param traineeId The Trainee identifier. * @returns The Trainee object. */ - protected async autoResolveTrainee(traineeId: string): Promise { + public async autoResolveTrainee(traineeId: string): Promise { if (traineeId == null) { throw new TypeError("A Trainee identifier is required."); } @@ -163,46 +181,13 @@ export class HowsoWorkerClient extends AbstractBaseClient { * Automatically persist Trainee object when appropriate based on persistence level. * @param traineeId The Trainee identifier. */ - protected async autoPersistTrainee(traineeId: string): Promise { + public async autoPersistTrainee(traineeId: string): Promise { const cached = this.cache.get(traineeId); if (cached?.trainee?.persistence === "always") { await this.persistTrainee(traineeId); } } - /** - * Constructs Trainee object from it's Engine metadata. - * - * @param traineeId The Trainee identifier. - * @returns The Trainee object and its feature attributes. - */ - protected async getTraineeFromEngine(traineeId: string): Promise { - const { payload } = await this.execute>(traineeId, "get_metadata", {}); - if (!payload) { - throw new HowsoError(`Trainee "${traineeId}" not found.`, "not_found"); - } - return new Trainee(this, { - id: traineeId, - name: payload?.name, - persistence: payload?.persistence ?? "allow", - metadata: payload?.metadata, - }); - } - - /** - * Include the active session in a request if not defined. - * @param request The Trainee request object. - * @returns The Trainee request object with a session. - */ - protected async includeSession>(request: T): Promise { - if (!request.session) { - // Include the active session - const session = await this.getActiveSession(); - return { ...request, session: session.id }; - } - return request; - } - /** * Setup client. * Prepares the file system and initializes the worker. @@ -273,11 +258,11 @@ export class HowsoWorkerClient extends AbstractBaseClient { * @param traineeId The Trainee identifier. */ public async persistTrainee(traineeId: string): Promise { - const fileUri = this.fs.join(this.fs.traineeDir, this.fs.traineeFilename(traineeId)); + const filePath = this.fs.join(this.fs.traineeDir, this.fs.traineeFilename(traineeId)); await this.dispatch({ type: "request", command: "storeEntity", - parameters: [traineeId, fileUri], + parameters: [{ handle: traineeId, filePath }], }); } @@ -311,7 +296,7 @@ export class HowsoWorkerClient extends AbstractBaseClient { const status = await this.dispatch({ type: "request", command: "loadEntity", - parameters: [traineeId, filePath], + parameters: [{ handle: traineeId, filePath }], }); if (!status.loaded) { throw new HowsoError(`Failed to acquire the Trainee "${traineeId}": ${status.message}`); @@ -362,11 +347,11 @@ export class HowsoWorkerClient extends AbstractBaseClient { public async createTrainee(properties: Omit): Promise { const traineeId = properties.name || uuid(); // Load the Engine entity - const howsoPath = this.fs.join(this.fs.libDir, `howso.${this.fs.entityExt}`); + const filePath = this.fs.join(this.fs.libDir, `howso.${this.fs.entityExt}`); const status = await this.dispatch({ type: "request", command: "loadEntity", - parameters: [traineeId, howsoPath], + parameters: [{ handle: traineeId, filePath }], }); if (!status.loaded) { throw new HowsoError(`Failed to initialize the Trainee "${traineeId}": ${status.message}`); @@ -375,7 +360,7 @@ export class HowsoWorkerClient extends AbstractBaseClient { // Create the Trainee entity await this.execute(traineeId, "initialize", { trainee_id: traineeId, - filepath: howsoPath, + filepath: filePath, }); // Set Trainee metadata @@ -435,7 +420,7 @@ export class HowsoWorkerClient extends AbstractBaseClient { const cloned = await this.dispatch({ type: "request", command: "cloneEntity", - parameters: [traineeId, newTraineeId], + parameters: [{ handle: traineeId, cloneHandle: newTraineeId }], }); if (!cloned) { throw new HowsoError( @@ -465,7 +450,10 @@ export class HowsoWorkerClient extends AbstractBaseClient { }); this.cache.discard(traineeId); const filename = this.fs.traineeFilename(traineeId); - this.fs.unlink(this.fs.join(this.fs.traineeDir, filename)); + const existingTrainees = await this.fs.readdir(this.fs.traineeDir); + if (existingTrainees.includes(filename)) { + await this.fs.unlink(this.fs.join(this.fs.traineeDir, filename)); + } } /** @@ -500,88 +488,4 @@ export class HowsoWorkerClient extends AbstractBaseClient { return accumulator; }, []); } - - public async impute(traineeId: string, request: schemas.ImputeRequest) { - request = await this.includeSession(request); - return await super.impute(traineeId, request); - } - - public async clearImputedData(traineeId: string, request: schemas.ClearImputedDataRequest) { - request = await this.includeSession(request); - return await super.clearImputedData(traineeId, request); - } - - public async moveCases(traineeId: string, request: schemas.MoveCasesRequest) { - request = await this.includeSession(request); - return await super.moveCases(traineeId, request); - } - - public async editCases(traineeId: string, request: schemas.EditCasesRequest) { - request = await this.includeSession(request); - return await super.editCases(traineeId, request); - } - - public async addFeature(traineeId: string, request: schemas.AddFeatureRequest) { - request = await this.includeSession(request); - return await super.addFeature(traineeId, request); - } - - public async removeFeature(traineeId: string, request: schemas.RemoveFeatureRequest) { - request = await this.includeSession(request); - return await super.removeFeature(traineeId, request); - } - - public async train(traineeId: string, request: schemas.TrainRequest) { - request = await this.includeSession(request); - return await super.train(traineeId, request); - } - - /** - * Train data into the Trainee using batched requests to the Engine. - * @param traineeId The Trainee identifier. - * @param request The train parameters. - * @returns The train result. - */ - public async batchTrain( - traineeId: string, - request: schemas.TrainRequest, - ): Promise> { - const trainee = await this.autoResolveTrainee(traineeId); - const { cases = [], ...rest } = request; - - // Limit to 10,000 cases at once maximum - const batchOptions: BatchOptions = { startSize: 100, limits: [1, 10000] }; - - let num_trained = 0; - let status = null; - const ablated_indices: number[] = []; - const warnings: string[][] = []; - - // Batch scale the requests - await batcher( - async function* (this: HowsoWorkerClient, size: number) { - let offset = 0; - while (offset < cases.length) { - const response = await this.train(trainee.id, { - ...rest, - cases: cases.slice(offset, offset + size), - }); - offset += size; - if (response.payload.status) status = response.payload.status; - if (response.payload.num_trained) num_trained += response.payload.num_trained; - if (response.payload.ablated_indices) ablated_indices.push(...response.payload.ablated_indices); - - // Warnings will be already output to the provided Logger in prepareResponse. Just aggregate. - if (response.warnings.length > 0) { - warnings.push(response.warnings); - } - size = yield; - } - }.bind(this), - batchOptions, - ); - - await this.autoPersistTrainee(trainee.id); - return { payload: { num_trained, status, ablated_indices }, warnings }; - } } diff --git a/src/engine/Session.ts b/src/engine/Session.ts index d97fc92..56e2845 100644 --- a/src/engine/Session.ts +++ b/src/engine/Session.ts @@ -1,6 +1,10 @@ import { AbstractBaseClient } from "../client/AbstractBaseClient"; import type { BaseSession } from "../types"; +/** + * The interface for interacting with a Session. Should not be instantiated directly. Instead begin or request a + * Session using the client. + */ export class Session implements BaseSession { public readonly id: string; protected readonly client: AbstractBaseClient; diff --git a/src/engine/Trainee.ts b/src/engine/Trainee.ts index 5917034..97e9b74 100644 --- a/src/engine/Trainee.ts +++ b/src/engine/Trainee.ts @@ -1,12 +1,25 @@ +/** + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly, instead modify the Trainee.njk template file. + * + * Generated via Howso Engine 88.0.1 + */ import { AbstractBaseClient } from "../client/AbstractBaseClient"; -import type { BaseTrainee } from "../types"; +import { batcher, BatchOptions } from "../client/utilities"; +import type { BaseTrainee, ClientBatchResponse, ClientResponse } from "../types"; +import type * as schemas from "../types/schemas"; +/** + * The interface for interacting with a Trainee. Should not be instantiated directly. Instead create or request a + * Trainee using the client. + */ export class Trainee implements BaseTrainee { public readonly id: string; protected readonly client: AbstractBaseClient; protected _name: BaseTrainee["name"]; protected _persistence: BaseTrainee["persistence"]; protected _metadata: BaseTrainee["metadata"]; + protected _deleted = false; constructor(client: AbstractBaseClient, obj: BaseTrainee) { this.client = client; @@ -27,4 +40,995 @@ export class Trainee implements BaseTrainee { public get metadata(): Readonly<{ [key: string]: any }> { return this._metadata || {}; } + + public get isDeleted(): boolean { + return this._deleted; + } + + public async update(properties: Partial): Promise { + const trainee = await this.client.updateTrainee({ ...properties, id: this.id }); + this._name = trainee.name; + this._metadata = trainee.metadata; + this._persistence = trainee.persistence; + } + + public async delete(): Promise { + await this.client.deleteTrainee(this.id); + this._deleted = true; + } + + public async copy(name?: string): Promise { + return await this.client.copyTrainee(this.id, name); + } + + public async acquireResources(): Promise { + return await this.client.acquireTraineeResources(this.id); + } + + public async releaseResources(): Promise { + return await this.client.releaseTraineeResources(this.id); + } + + public async persist(): Promise { + await this.client.persistTrainee(this.id); + } + + /** + * Train data into the Trainee using batched requests to the Engine. + * @param traineeId The Trainee identifier. + * @param request The train parameters. + * @returns The train result. + */ + public async batchTrain(request: schemas.TrainRequest): Promise> { + const { cases = [], ...rest } = request; + + // Limit to 10,000 cases at once maximum + const batchOptions: BatchOptions = { startSize: 100, limits: [1, 10000] }; + + let num_trained = 0; + let status = null; + const ablated_indices: number[] = []; + const warnings: string[][] = []; + + // Batch scale the requests + await batcher( + async function* (this: Trainee, size: number) { + let offset = 0; + while (offset < cases.length) { + const response = await this.train({ + ...rest, + cases: cases.slice(offset, offset + size), + }); + offset += size; + if (response.payload.status) status = response.payload.status; + if (response.payload.num_trained) num_trained += response.payload.num_trained; + if (response.payload.ablated_indices) ablated_indices.push(...response.payload.ablated_indices); + + // Warnings will be already output to the provided Logger in prepareResponse. Just aggregate. + if (response.warnings.length > 0) { + warnings.push(response.warnings); + } + size = yield; + } + }.bind(this), + batchOptions, + ); + + return { payload: { num_trained, status, ablated_indices }, warnings }; + } + + /** + * Include the active session in a request if not defined. + * @param request The Trainee request object. + * @returns The Trainee request object with a session. + */ + protected async includeSession>(request: T): Promise { + if (!request.session) { + // Include the active session + const session = await this.client.getActiveSession(); + return { ...request, session: session.id }; + } + return request; + } + + /** + * Adds the specified feature on all cases for a trainee that match the specified condition. overwrites features that + * If condition are not specified, adds feature for all cases and to the model. If condition is an empty assoc, will not modify feature metadata in the model. + * If feature attributes are passed in, will also set the model's feature attributes. + * Updates the accumulated data mass for the model proportional to the number of cases modified. + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async addFeature(request: schemas.AddFeatureRequest): Promise> { + await this.client.autoResolveTrainee(this.id); + request = await this.includeSession(request); + const response = await this.client.execute(this.id, "add_feature", request); + this.client.autoPersistTrainee(this.id); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Analyzes the data to compute the appropriate statistics, uncertainties, and select parameters as appropriate. + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async analyze(request: schemas.AnalyzeRequest): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "analyze", request); + this.client.autoPersistTrainee(this.id); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Append cases to a series + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async appendToSeriesStore(request: schemas.AppendToSeriesStoreRequest): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "append_to_series_store", request); + this.client.autoPersistTrainee(this.id); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Automatically analyze the model using stored parameters from previous analyze calls + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async autoAnalyze(): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "auto_analyze", {}); + this.client.autoPersistTrainee(this.id); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Clear values that were imputed during a specified session, but won't clear values that were manually set by user after the impute + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async clearImputedData(request: schemas.ClearImputedDataRequest): Promise> { + await this.client.autoResolveTrainee(this.id); + request = await this.includeSession(request); + const response = await this.client.execute(this.id, "clear_imputed_data", request); + this.client.autoPersistTrainee(this.id); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Creates a copy of a trainee and stores it a subtrainee, returns the name of the copied trainee on success + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async copySubtrainee( + request: schemas.CopySubtraineeRequest, + ): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "copy_subtrainee", request); + this.client.autoPersistTrainee(this.id); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Creates a new instance of a contained trainee as specified by the entity label "trainee". + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async createSubtrainee( + request: schemas.CreateSubtraineeRequest, + ): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "create_subtrainee", request); + this.client.autoPersistTrainee(this.id); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Removes replay specified by session and any references within cases + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async deleteSession(request: schemas.DeleteSessionRequest): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "delete_session", request); + this.client.autoPersistTrainee(this.id); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Destroys the instance of the trainee specified by the parameter "trainee". + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async deleteSubtrainee(request: schemas.DeleteSubtraineeRequest): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "delete_subtrainee", request); + this.client.autoPersistTrainee(this.id); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Edit feature values for the specified cases. + * Cases are specified by either case_indices or by the condition. If neither is provided, edits all cases. + * Updates the accumulated data mass for the model proportional to the number of cases and features modified. + * returns null if invalid features specified or an assoc with "count" + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async editCases(request: schemas.EditCasesRequest): Promise> { + await this.client.autoResolveTrainee(this.id); + request = await this.includeSession(request); + const response = await this.client.execute(this.id, "edit_cases", request); + this.client.autoPersistTrainee(this.id); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Evaluate custom Amalgam code for feature values of every case in the model and returns + * a list of the custom code's return values for each feature specified. + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async evaluate(request: schemas.EvaluateRequest): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "evaluate", request); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Execute any method in the API directly on any child trainee of this trainee, used for hierarchy operations. + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async executeOnSubtrainee(request: schemas.ExecuteOnSubtraineeRequest): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "execute_on_subtrainee", request); + this.client.autoPersistTrainee(this.id); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Export trainee's metadata, case and session data into json files. + * this method should be run by a script from the ./migrations folder + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async exportTrainee(request: schemas.ExportTraineeRequest): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "export_trainee", request); + this.client.autoPersistTrainee(this.id); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Get auto-ablation parameters set by #set_auto_ablation_params + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async getAutoAblationParams(): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute( + this.id, + "get_auto_ablation_params", + {}, + ); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Returns assoc with features and cases - a list of lists of all feature values. Retrieves all feature values for cases for + * all (unordered) sessions in the order they were trained within each session. If a session is specified, only that session's + * cases wil be output. + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async getCases(request: schemas.GetCasesRequest): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "get_cases", request); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Returns an assoc with case distances, containing a list of case session indices and a list of lists (matrix) of the computed distances. + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async getDistances( + request: schemas.GetDistancesRequest, + ): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "get_distances", request); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Returns the full entity path to a child trainee provided its unique trainee id if it is contained in the hierarchy. + * Iterates down the hierarchy searching for a trainee that matches the specified id, returns null if not found or + * a string error if found but trainee is stored externally as an independent trainee. + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async getEntityPathById( + request: schemas.GetEntityPathByIdRequest, + ): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute( + this.id, + "get_entity_path_by_id", + request, + ); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Method to return the list of all model attributes that can be exported/imported + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async getExportAttributes(): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "get_export_attributes", {}); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Retrieve the top or bottom number of cases for a specified feature, sorted top to bottom for top, and bottom to top for bottom + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async getExtremeCases( + request: schemas.GetExtremeCasesRequest, + ): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "get_extreme_cases", request); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Output all feature attributes + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async getFeatureAttributes(): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "get_feature_attributes", {}); + this.client.autoPersistTrainee(this.id); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Computes the conviction for each feature and returns an assoc of feature -> conviction value + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async getFeatureConviction( + request: schemas.GetFeatureConvictionRequest, + ): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute( + this.id, + "get_feature_conviction", + request, + ); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Pull the hierarchy for a trainee, returns an assoc of: + * the currently contained hierarchy as a nested assoc with (false) for trainees that are stored independently. + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async getHierarchy(): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "get_hierarchy", {}); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Outputs all marginal stats (min, max, median, mean, mode, count, uniques, mean_absdev, variance, stddev, skew, kurtosis, entropy) + * for all features in the format of feature -> assoc stat -> value. The marginal stats can be computed for a subset of the data using condition, precision, and num_cases + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async getMarginalStats( + request: schemas.GetMarginalStatsRequest, + ): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute( + this.id, + "get_marginal_stats", + request, + ); + this.client.autoPersistTrainee(this.id); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Get metadata for model + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async getMetadata(): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "get_metadata", {}); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Returns the total number of training cases for trainee + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async getNumTrainingCases(): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute( + this.id, + "get_num_training_cases", + {}, + ); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Returns a list of computed distances between respective cases specified in either from_values or from_case_indices to to_values or to_case_indices. + * If one case is specified in any of the lists, all respective distances are computed to/from that one case. + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async getPairwiseDistances(request: schemas.GetPairwiseDistancesRequest): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "get_pairwise_distances", request); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Return the full internal parameters map if no parameters are specified. + * if any of the parameters are specified, then GetHyperparameters is called, which uses the specified parameters to find the most suitable set of hyperparameters to return + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async getParams(request: schemas.GetParamsRequest): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "get_params", request); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Returns the trainee's !revision + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async getRevision(): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "get_revision", {}); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Returns a list of all of the training sessions, assoc of id->session, and whatever other attributes specified. + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async getSessions(request: schemas.GetSessionsRequest): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "get_sessions", request); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Return list of all session indices for a specified session. + * session indices are 0-based index of number of the case for the session used for replays; may change if cases are removed + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async getSessionIndices(request: schemas.GetSessionIndicesRequest): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "get_session_indices", request); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Returns all the metadata for a specified session + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async getSessionMetadata( + request: schemas.GetSessionMetadataRequest, + ): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute( + this.id, + "get_session_metadata", + request, + ); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Return list of all session training indices for a specified session. + * session training indices are 0-based index of the case, ordered by training during the session; is not changed + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async getSessionTrainingIndices( + request: schemas.GetSessionTrainingIndicesRequest, + ): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "get_session_training_indices", request); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Returns the substitution map + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async getSubstituteFeatureValues(): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute( + this.id, + "get_substitute_feature_values", + {}, + ); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Returns the trainee's unique id + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async getTraineeId(): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "get_trainee_id", {}); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * The version stored in trainee + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async getTraineeVersion(): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "get_trainee_version", {}); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Imputes the model, filling in all the (null) feature values + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async impute(request: schemas.ImputeRequest): Promise> { + await this.client.autoResolveTrainee(this.id); + request = await this.includeSession(request); + const response = await this.client.execute(this.id, "impute", request); + this.client.autoPersistTrainee(this.id); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Attempts to load a subtrainee with the following optional parameters. + * If a parameter is not specified, it will look to this entity's own label of the same name. + * If the saved instance does not exist the existing trainee will remain unmodified and the function will return null. + * assumes loaded trainee filenames need to be escaped + * returns the trainee name if successful, null if not + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async loadSubtrainee( + request: schemas.LoadSubtraineeRequest, + ): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "load_subtrainee", request); + this.client.autoPersistTrainee(this.id); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Moves all cases that match the specified conditions in the hierarchy of the specified trainee + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async moveCases(request: schemas.MoveCasesRequest): Promise> { + await this.client.autoResolveTrainee(this.id); + request = await this.includeSession(request); + const response = await this.client.execute(this.id, "move_cases", request); + this.client.autoPersistTrainee(this.id); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Run reacts in a batch, output a an assoc of list of outputs from each individual react. + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async react(request: schemas.ReactRequest): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "react", request); + this.client.autoPersistTrainee(this.id); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Computes, caches, and returns specified details and feature prediction statistics such as Mean Decrease in Accuracy (MDA), residuals (accuracy, Mean Absolute Error), + * precision, recall, etc. Returns details and feature prediction stats for all features in the format of feature -> assoc stat -> value + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async reactAggregate( + request: schemas.ReactAggregateRequest, + ): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "react_aggregate", request); + this.client.autoPersistTrainee(this.id); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Computes the convictions of an average case for each given hypothetical set of cases specified + * output an assoc react key -> list of corresponding values from each individual group. + * example output for 2 groups: + * (assoc + * "base_model_average_distance_contribution" (list 4.0 4.1) + * "combined_model_average_distance_contribution" (list 4.05 3.9) + * "distance_contributions" (list 4.5 3.2) + * ) + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async reactGroup(request: schemas.ReactGroupRequest): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "react_group", request); + this.client.autoPersistTrainee(this.id); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Computes various data, such as familiarity convictions and distance contribution for each case in the model and stores them into specified features. + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async reactIntoFeatures(request: schemas.ReactIntoFeaturesRequest): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "react_into_features", request); + this.client.autoPersistTrainee(this.id); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * React in a series until a series_stop_map condition is met. Aggregates rows of data corresponding to the specified context, action, + * derived_context and derived_action features, utilizing previous rows to derive values as necessary. Outputs an assoc of "action_features" and + * corresponding "series" where "series" is the completed 'matrix' for the corresponding action_features and derived_action_features. + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async reactSeries(request: schemas.ReactSeriesRequest): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "react_series", request); + this.client.autoPersistTrainee(this.id); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Reduce the trained data by removing cases which have an influence weight entropy that falls above + * a threshold. + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async reduceData(request: schemas.ReduceDataRequest): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "reduce_data", request); + this.client.autoPersistTrainee(this.id); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Removes all cases that match the specified conditions from trainee + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async removeCases(request: schemas.RemoveCasesRequest): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "remove_cases", request); + this.client.autoPersistTrainee(this.id); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Removes the specified feature on all cases for a trainee that match the specified condition + * if conditions are not specified, removes feature for all cases and from the model, if condition is an empty assoc, leaves the feature metadata in the model. + * Updates the accumulated data mass for the model proportional to the number of cases modified. + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async removeFeature(request: schemas.RemoveFeatureRequest): Promise> { + await this.client.autoResolveTrainee(this.id); + request = await this.includeSession(request); + const response = await this.client.execute(this.id, "remove_feature", request); + this.client.autoPersistTrainee(this.id); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Clears stored series + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async removeSeriesStore(request: schemas.RemoveSeriesStoreRequest): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "remove_series_store", request); + this.client.autoPersistTrainee(this.id); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Rename a contained trainee + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async renameSubtrainee(request: schemas.RenameSubtraineeRequest): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "rename_subtrainee", request); + this.client.autoPersistTrainee(this.id); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Resets all hyperparameters and thresholds back to original values, while leaving feature definitions alone + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async resetParams(): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "reset_params", {}); + this.client.autoPersistTrainee(this.id); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Saves a subtrainee with the following optional parameters, escapes trainee filenames on save + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async saveSubtrainee(request: schemas.SaveSubtraineeRequest): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "save_subtrainee", request); + this.client.autoPersistTrainee(this.id); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Sets the model to auto-ablate by tracking its size and training certain cases as weights + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async setAutoAblationParams(request: schemas.SetAutoAblationParamsRequest): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "set_auto_ablation_params", request); + this.client.autoPersistTrainee(this.id); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Sets the model to auto-analyze by tracking its size and notifying the clients in train responses when it should be analyzed + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async setAutoAnalyzeParams(request: schemas.SetAutoAnalyzeParamsRequest): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "set_auto_analyze_params", request); + this.client.autoPersistTrainee(this.id); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Set all features and their attributes for the trainee, and returns the updated feature attributes + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async setFeatureAttributes( + request: schemas.SetFeatureAttributesRequest, + ): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute( + this.id, + "set_feature_attributes", + request, + ); + this.client.autoPersistTrainee(this.id); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Set the influence weight threshold for outputting only the K neighbors whose influence weight is <= to this threshold + * default value is 0.99 + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async setInfluenceWeightThreshold( + request: schemas.SetInfluenceWeightThresholdRequest, + ): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "set_influence_weight_threshold", request); + this.client.autoPersistTrainee(this.id); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Set metadata for model + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async setMetadata(request: schemas.SetMetadataRequest): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "set_metadata", request); + this.client.autoPersistTrainee(this.id); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Sets internal hyperparameters + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async setParams(request: schemas.SetParamsRequest): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "set_params", request); + this.client.autoPersistTrainee(this.id); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Set trainee's unique parent id + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async setParentId(request: schemas.SetParentIdRequest): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "set_parent_id", request); + this.client.autoPersistTrainee(this.id); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Set the random seed on a trainee + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async setRandomSeed(request: schemas.SetRandomSeedRequest): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "set_random_seed", request); + this.client.autoPersistTrainee(this.id); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Set session metadata for a specified session. + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async setSessionMetadata(request: schemas.SetSessionMetadataRequest): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "set_session_metadata", request); + this.client.autoPersistTrainee(this.id); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Sets substitution feature values used in case generation + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async setSubstituteFeatureValues( + request: schemas.SetSubstituteFeatureValuesRequest, + ): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "set_substitute_feature_values", request); + this.client.autoPersistTrainee(this.id); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Set trainee's unique id + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async setTraineeId(request: schemas.SetTraineeIdRequest): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "set_trainee_id", request); + this.client.autoPersistTrainee(this.id); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Train the provided cases, filtering out cases that match optionally passed in ablation parameters. + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async train(request: schemas.TrainRequest): Promise> { + await this.client.autoResolveTrainee(this.id); + request = await this.includeSession(request); + const response = await this.client.execute(this.id, "train", request); + this.client.autoPersistTrainee(this.id); + return { payload: response.payload, warnings: response.warnings }; + } + + /** + * Update version to latest, auto importing any exported data. + * @param traineeId The Trainee identifier. + * @param request The operation parameters. + * @returns The response of the operation, including any warnings. + */ + public async upgradeTrainee(request: schemas.UpgradeTraineeRequest): Promise> { + await this.client.autoResolveTrainee(this.id); + const response = await this.client.execute(this.id, "upgrade_trainee", request); + this.client.autoPersistTrainee(this.id); + return { payload: response.payload, warnings: response.warnings }; + } } diff --git a/src/features/base.ts b/src/features/base.ts index f78ae80..2411a99 100644 --- a/src/features/base.ts +++ b/src/features/base.ts @@ -2,24 +2,20 @@ import type { FeatureAttributesIndex } from "../types"; export type FeatureSourceFormat = "unknown" | "array" | "parsed_array"; -export interface InferFeatureBoundsOptions { - tightBounds?: boolean | string[]; - modeBounds?: boolean | string[]; -} - -export interface InferFeatureTimeSeriesOptions { - timeFeature: string; - idFeatureName?: string; -} - -export interface InferFeatureAttributesOptions { - defaults?: FeatureAttributesIndex; - inferBounds?: boolean | InferFeatureBoundsOptions; - timeSeries?: InferFeatureTimeSeriesOptions; - ordinalFeatureValues?: Record; - dependentFeatures?: Record; - includeSample?: boolean; -} +/** + * A subset of supported options. + * Full options are available only when using the Python direct client or Platform installation. + * @see https://docs.howso.com/en/release-latest/api_reference/_autosummary/howso.utilities.html#howso.utilities.infer_feature_attributes + **/ +export type InferFeatureAttributesOptions = { + dependent_features?: Record; + features?: FeatureAttributesIndex; + include_sample?: boolean; + infer_bounds?: boolean; + mode_bound_features?: string[]; + ordinal_feature_values?: Record; + tight_bounds?: boolean; +}; export interface ArrayData { readonly columns: C[]; diff --git a/src/features/sources/Array.test.ts b/src/features/sources/Array.test.ts index e04ccc4..027860d 100644 --- a/src/features/sources/Array.test.ts +++ b/src/features/sources/Array.test.ts @@ -70,7 +70,7 @@ describe("features/sources/Array", () => { number: { type: "continuous", data_type: "number" }, date: { type: "continuous", data_type: "formatted_date_time", date_time_format: "%Y-%m-%dT%h-%m-%s" }, }; - const features = await service.infer({ defaults, includeSample: true }); + const features = await service.infer({ features: defaults, include_sample: true }); expectFeatureAttributesIndex(features); // Id diff --git a/src/features/sources/Array.ts b/src/features/sources/Array.ts index 5df94cb..a5fc782 100644 --- a/src/features/sources/Array.ts +++ b/src/features/sources/Array.ts @@ -1,12 +1,5 @@ import type { FeatureAttributes } from "../../types"; -import { - AbstractDataType, - ArrayData, - FeatureSourceFormat, - InferFeatureBoundsOptions, - InferFeatureTimeSeriesOptions, - isArrayData, -} from "../base"; +import { AbstractDataType, ArrayData, FeatureSourceFormat, InferFeatureAttributesOptions, isArrayData } from "../base"; import * as utils from "../utils"; import { FeatureSerializerBase, InferFeatureAttributeFeatureStatistics, InferFeatureAttributesBase } from "./Base"; @@ -124,7 +117,7 @@ export class InferFeatureAttributesFromArray extends InferFeatureAttributesBase public async inferBounds( attributes: Readonly, featureName: string, - options: InferFeatureBoundsOptions, + options: InferFeatureAttributesOptions, ): Promise { const { minimum, maximum, hasNulls, samples, uniqueValues, totalValues } = await this.getStatistics(featureName); @@ -167,15 +160,12 @@ export class InferFeatureAttributesFromArray extends InferFeatureAttributesBase const actualMax = maxValue; if (minValue !== undefined && maxValue !== undefined) { - if ( - !options.tightBounds || - (Array.isArray(options.tightBounds) && options.tightBounds.indexOf(featureName) === -1) - ) { + if (!options.tight_bounds) { // Use loose bounds [minValue, maxValue] = utils.guessLooseBounds(minValue, maxValue); - const { modeBounds = true } = options; - if (modeBounds || (Array.isArray(modeBounds) && modeBounds.indexOf(featureName) >= 0)) { + const { mode_bound_features } = options; + if (!mode_bound_features || mode_bound_features.includes(featureName)) { // Check for mode bounds if (uniqueValues !== totalValues) { const [modes, modeCount] = utils.allModes(column); @@ -234,7 +224,7 @@ export class InferFeatureAttributesFromArray extends InferFeatureAttributesBase /* eslint-disable-next-line @typescript-eslint/no-unused-vars*/ featureName: string, /* eslint-disable-next-line @typescript-eslint/no-unused-vars*/ - options: InferFeatureTimeSeriesOptions, + options: InferFeatureAttributesOptions, ): Promise> { // TODO - infer time series throw new Error("Method not implemented."); diff --git a/src/features/sources/Base.ts b/src/features/sources/Base.ts index 57ad586..460f02c 100644 --- a/src/features/sources/Base.ts +++ b/src/features/sources/Base.ts @@ -1,11 +1,5 @@ import { FeatureAttributes, FeatureAttributesIndex, FeatureOriginalType } from "../../types"; -import { - AbstractDataType, - FeatureSourceFormat, - InferFeatureAttributesOptions, - InferFeatureBoundsOptions, - InferFeatureTimeSeriesOptions, -} from "../base"; +import { AbstractDataType, FeatureSourceFormat, InferFeatureAttributesOptions } from "../base"; import { coerceDate } from "../utils"; export type InferFeatureAttributeFeatureStatistics = { @@ -37,10 +31,10 @@ export abstract class InferFeatureAttributesBase { // Loop the columns into attributes immediately to get order assigned. Probably should be a Map... const columns = await this.getFeatureNames(); const attributes: FeatureAttributesIndex = columns.reduce((attributes, column) => { - attributes[column] = (options.defaults?.[column] || {}) as FeatureAttributes; + attributes[column] = (options.features?.[column] || {}) as FeatureAttributes; return attributes; }, {} as FeatureAttributesIndex); - const { ordinalFeatureValues = {}, dependentFeatures = {} } = options; + const { ordinal_feature_values: ordinalFeatureValues = {}, dependent_features: dependentFeatures = {} } = options; const getFeatureAttributes = async (featureName: string): Promise => { const originalFeatureType = await this.getOriginalFeatureType(featureName); @@ -100,7 +94,7 @@ export abstract class InferFeatureAttributesBase { } // Infer bounds - const { inferBounds = true } = options; + const { infer_bounds: inferBounds = true } = options; if (inferBounds && !attributes[featureName].bounds) { const bounds = await this.inferBounds( attributes[featureName], @@ -117,7 +111,7 @@ export abstract class InferFeatureAttributesBase { // TODO - infer time series // } - if (options.includeSample) { + if (options.include_sample) { additions.sample = await this.getSample(featureName); } @@ -248,12 +242,12 @@ export abstract class InferFeatureAttributesBase { public abstract inferBounds( attributes: Readonly, featureName: string, - options: InferFeatureBoundsOptions, + options: InferFeatureAttributesOptions, ): Promise; public abstract inferTimeSeries( attributes: Readonly, featureName: string, - options: InferFeatureTimeSeriesOptions, + options: InferFeatureAttributesOptions, ): Promise>; protected async getSample(featureName: string): Promise { diff --git a/src/features/sources/examples/CSV.test.ts b/src/features/sources/examples/CSV.test.ts index 5f1b163..c2de658 100644 --- a/src/features/sources/examples/CSV.test.ts +++ b/src/features/sources/examples/CSV.test.ts @@ -60,7 +60,7 @@ describe("features/sources/CSV", () => { const service = new InferFeatureAttributesFromCSV(data, serviceOptions); expect(service.samples?.length).toBe(serviceOptions.samplesLimit); - const features = await service.infer({ includeSample: true }); + const features = await service.infer({ include_sample: true }); expect(Object.keys(features)).toStrictEqual(columns); expectFeatureAttributesIndex(features); expectAsteroids(features); diff --git a/src/types/index.ts b/src/types/index.ts index 75bc95a..e952903 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -1,5 +1,4 @@ export * from "./client"; export * from "./schemas"; export * from "./session"; -export * from "./shims"; export * from "./trainee"; diff --git a/src/types/schemas/AblationThresholdMap.ts b/src/types/schemas/AblationThresholdMap.ts index 66f2f7f..b73759c 100644 --- a/src/types/schemas/AblationThresholdMap.ts +++ b/src/types/schemas/AblationThresholdMap.ts @@ -1,10 +1,9 @@ /** - * WARNING: This file is auto generated, do not modify manually. - * - * AblationThresholdMap + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. */ /** - * Map of prediction stats to map of feature name to threshold value. thresholds can be absolute, delta, or relative depending on which parameter is being used. + * Map of prediction stats to map of feature name to threshold value. Thresholds can be absolute, delta, or relative depending on which parameter is being used. */ export type AblationThresholdMap = Record>; diff --git a/src/types/schemas/AddFeature.ts b/src/types/schemas/AddFeature.ts index 4d20c9f..680b9da 100644 --- a/src/types/schemas/AddFeature.ts +++ b/src/types/schemas/AddFeature.ts @@ -1,16 +1,18 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * AddFeature * * Adds the specified feature on all cases for a trainee that match the specified condition. overwrites features that - * if condition are not specified, adds feature for all cases and to the model. if condition is an empty assoc, will not modify feature metadata in the model. - * if feature attributes are passed in, will also set the model's feature attributes. - * updates the accumulated data mass for the model proportional to the number of cases modified. + * If condition are not specified, adds feature for all cases and to the model. If condition is an empty assoc, will not modify feature metadata in the model. + * If feature attributes are passed in, will also set the model's feature attributes. + * Updates the accumulated data mass for the model proportional to the number of cases modified. */ import type { Condition } from "./Condition"; import type { FeatureAttributes } from "./FeatureAttributes"; +/** Request parameters of the Trainee method: addFeature. */ export type AddFeatureRequest = { /** * Assoc of feature->value(s). @@ -39,7 +41,7 @@ export type AddFeatureRequest = { feature: string; /** - * Assoc of feature specific attributes for this feature. if unspecified and conditions are not specified, will assume feature type as 'continuous'. + * Assoc of feature specific attributes for this feature. If unspecified and conditions are not specified, will assume feature type as 'continuous'. */ feature_attributes?: FeatureAttributes; diff --git a/src/types/schemas/Analyze.ts b/src/types/schemas/Analyze.ts index 93ad8ce..7ae74e4 100644 --- a/src/types/schemas/Analyze.ts +++ b/src/types/schemas/Analyze.ts @@ -1,5 +1,6 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * Analyze * @@ -7,6 +8,7 @@ */ import type { UseCaseWeights } from "./UseCaseWeights"; +/** Request parameters of the Trainee method: analyze. */ export type AnalyzeRequest = { /** * List of action features to analyze for. applicable only to 'single_targeted' mode @@ -47,10 +49,10 @@ export type AnalyzeRequest = { /** * List of values for dt (the distance transform) to grid search during analysis */ - dt_values?: number[]; + dt_values?: (number | string)[]; /** - * Whether to use inverse residuals as feature weights. if unspecified, inverse residuals will be used as weights for + * Whether to use inverse residuals as feature weights. If unspecified, inverse residuals will be used as weights for * targetless params, otherwise this method will not be used. */ inverse_residuals_as_weights?: boolean | null; @@ -77,7 +79,7 @@ export type AnalyzeRequest = { num_samples?: number; /** - * List of values for p (the parameter of the lebesgue space) to grid search during analysis + * List of values for p (the parameter of the Lebesgue space) to grid search during analysis */ p_values?: number[]; @@ -88,7 +90,7 @@ export type AnalyzeRequest = { * "targetless" = analyze hyperparameters for all context features as possible action features, ignores action_features parameter * @default "single_targeted" */ - targeted_model?: "single_targeted" | "omni_targeted" | "targetless"; + targeted_model?: "omni_targeted" | "single_targeted" | "targetless"; /** * When true will scale influence weights by each case's weight_feature weight. if use_case_weights isn't specified, it will @@ -97,8 +99,8 @@ export type AnalyzeRequest = { use_case_weights?: UseCaseWeights; /** - * Whether to use deviations for lk metric in queries. when true forces the use - * of deviations, when false will not use deviations. if unspecified, the better performing option will be selected. + * Whether to use deviations for LK metric in queries. When true forces the use + * of deviations, when false will not use deviations. If unspecified, the better performing option will be selected. */ use_deviations?: boolean | null; diff --git a/src/types/schemas/AppendToSeriesStore.ts b/src/types/schemas/AppendToSeriesStore.ts index f96daf0..16c2f9f 100644 --- a/src/types/schemas/AppendToSeriesStore.ts +++ b/src/types/schemas/AppendToSeriesStore.ts @@ -1,11 +1,13 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * AppendToSeriesStore * * Append cases to a series */ +/** Request parameters of the Trainee method: appendToSeriesStore. */ export type AppendToSeriesStoreRequest = { /** * List of context features for the corresponding context_values @@ -13,7 +15,7 @@ export type AppendToSeriesStoreRequest = { context_features: string[]; /** - * List of lists. case values corresponding to the context features to store into a series. + * List of lists. Case values corresponding to the context features to store into a series. */ context_values: any[][]; diff --git a/src/types/schemas/BuiltInFeatures.ts b/src/types/schemas/BuiltInFeatures.ts index f665d69..356359d 100644 --- a/src/types/schemas/BuiltInFeatures.ts +++ b/src/types/schemas/BuiltInFeatures.ts @@ -1,12 +1,11 @@ /** - * WARNING: This file is auto generated, do not modify manually. - * - * BuiltInFeatures + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. */ import type { EditHistory } from "./EditHistory"; /** - * The features and their values created by the howso engine automatically + * The features and their values created by the Howso Engine automatically */ export type BuiltInFeatures = { ".case_edit_history"?: EditHistory; @@ -46,6 +45,4 @@ export type BuiltInFeatures = { * The 0-based index of the case's order in training within its session. */ ".session_training_index"?: number; -} & Record<`${string}_delta_${number}`, number | null> & - Record<`${string}_lag_${number}`, any> & - Record<`${string}_rate_${number}`, number | null>; +}; diff --git a/src/types/schemas/Case.ts b/src/types/schemas/Case.ts new file mode 100644 index 0000000..3f2df83 --- /dev/null +++ b/src/types/schemas/Case.ts @@ -0,0 +1,9 @@ +/** + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. + */ + +/** + * Case schema. + */ +export type Case = Record; diff --git a/src/types/schemas/CaseIndices.ts b/src/types/schemas/CaseIndices.ts index 13b344f..d8aa8bd 100644 --- a/src/types/schemas/CaseIndices.ts +++ b/src/types/schemas/CaseIndices.ts @@ -1,10 +1,9 @@ /** - * WARNING: This file is auto generated, do not modify manually. - * - * CaseIndices + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. */ /** - * List of tuples containing the session id and index, where index is the original 0-based index of the case as it was trained into the session. this explicitly specifies the cases to retrieve. + * List of tuples containing the session id and index, where index is the original 0-based index of the case as it was trained into the session. This explicitly specifies the cases to retrieve. */ export type CaseIndices = (string | number)[][]; diff --git a/src/types/schemas/CaseMDA.ts b/src/types/schemas/CaseMDA.ts new file mode 100644 index 0000000..b2d7d2c --- /dev/null +++ b/src/types/schemas/CaseMDA.ts @@ -0,0 +1,13 @@ +/** + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. + */ + +/** + * A map for an influential case of a reaction that describes its training index, session, and MDA for the action feature. + */ +export type CaseMDA = { + ".session"?: string; + ".session_training_index"?: number; + mda?: number; +}; diff --git a/src/types/schemas/Cases.ts b/src/types/schemas/Cases.ts new file mode 100644 index 0000000..18ed053 --- /dev/null +++ b/src/types/schemas/Cases.ts @@ -0,0 +1,10 @@ +/** + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. + */ +import type { Case } from "./Case"; + +/** + * A list of maps representing the cases that influenced a react. + */ +export type Cases = Case[]; diff --git a/src/types/schemas/CategoricalActionProbabilities.ts b/src/types/schemas/CategoricalActionProbabilities.ts new file mode 100644 index 0000000..187706d --- /dev/null +++ b/src/types/schemas/CategoricalActionProbabilities.ts @@ -0,0 +1,9 @@ +/** + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. + */ + +/** + * A map of giving the estimated probability of each class for a feature in a given prediction. + */ +export type CategoricalActionProbabilities = Record; diff --git a/src/types/schemas/ClearImputedData.ts b/src/types/schemas/ClearImputedData.ts index 27318cb..c4f7a67 100644 --- a/src/types/schemas/ClearImputedData.ts +++ b/src/types/schemas/ClearImputedData.ts @@ -1,11 +1,13 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * ClearImputedData * * Clear values that were imputed during a specified session, but won't clear values that were manually set by user after the impute */ +/** Request parameters of the Trainee method: clearImputedData. */ export type ClearImputedDataRequest = { /** * Session id of the impute for which to clear the data. if null, will clear all imputed diff --git a/src/types/schemas/Condition.ts b/src/types/schemas/Condition.ts index 68eb6ca..9b8cdec 100644 --- a/src/types/schemas/Condition.ts +++ b/src/types/schemas/Condition.ts @@ -1,14 +1,13 @@ /** - * WARNING: This file is auto generated, do not modify manually. - * - * Condition + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. */ /** - * The condition map to select the cases to remove that meet all the provided conditions. the dictionary keys are the feature name and values are one of: - * - none - * - a value, must match exactly. - * - an array of two numeric values, specifying an inclusive range. only applicable to continuous and numeric ordinal features. - * - an array of string values, must match any of these values exactly. only applicable to nominal and string ordinal features. + * The condition map to select the cases to remove that meet all the provided conditions. The dictionary keys are the feature name and values are one of: + * - None + * - A value, must match exactly. + * - An array of two numeric values, specifying an inclusive range. Only applicable to continuous and numeric ordinal features. + * - An array of string values, must match any of these values exactly. Only applicable to nominal and string ordinal features. */ export type Condition = Record; diff --git a/src/types/schemas/ConfusionMatrix.ts b/src/types/schemas/ConfusionMatrix.ts new file mode 100644 index 0000000..f13d5fd --- /dev/null +++ b/src/types/schemas/ConfusionMatrix.ts @@ -0,0 +1,26 @@ +/** + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. + */ + +/** + * The confusion matrix in the form of maps from actual classes to maps of predicted classes to frequencies alongside counts for insignficant predictions. + */ +export type ConfusionMatrix = { + /** + * Total number of correct predictions for classes that were not statistically significant. + */ + leftover_correct?: number | null; + /** + * Total number of incorrect predictions for classes with any correct but statistically insignificant predictions. + */ + leftover_incorrect?: number | null; + /** + * A map of actual values to map of predicted values to counts. + */ + matrix?: Record>; + /** + * Total number of all other statistically insignificant predictions. + */ + other_counts?: Record | number | null; +}; diff --git a/src/types/schemas/CopySubtrainee.ts b/src/types/schemas/CopySubtrainee.ts index 4d1736f..7752cc9 100644 --- a/src/types/schemas/CopySubtrainee.ts +++ b/src/types/schemas/CopySubtrainee.ts @@ -1,15 +1,17 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * CopySubtrainee * * Creates a copy of a trainee and stores it a subtrainee, returns the name of the copied trainee on success */ +/** Request parameters of the Trainee method: copySubtrainee. */ export type CopySubtraineeRequest = { /** - * Id of source trainee to copy. ignored if source_name_path is specified. - * if neither source_name_path nor source_id are specified, copies the trainee itself. + * Id of source trainee to copy. Ignored if source_name_path is specified. + * If neither source_name_path nor source_id are specified, copies the trainee itself. */ source_id?: string; @@ -19,8 +21,8 @@ export type CopySubtraineeRequest = { source_name_path?: string[]; /** - * Id of target trainee to copy trainee into. ignored if target_name_path is specified. - * if neither target_name_path nor target_id are specified, copies as a direct child of trainee + * Id of target trainee to copy trainee into. Ignored if target_name_path is specified. + * If neither target_name_path nor target_id are specified, copies as a direct child of trainee */ target_id?: string; @@ -34,3 +36,8 @@ export type CopySubtraineeRequest = { */ target_trainee: string | string[]; }; + +/** Response of the Trainee method: copySubtrainee. */ +export type CopySubtraineeResponse = { + name: string[] | string; +}; diff --git a/src/types/schemas/CreateSubtrainee.ts b/src/types/schemas/CreateSubtrainee.ts index e3a9c23..8be38b3 100644 --- a/src/types/schemas/CreateSubtrainee.ts +++ b/src/types/schemas/CreateSubtrainee.ts @@ -1,11 +1,13 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * CreateSubtrainee * * Creates a new instance of a contained trainee as specified by the entity label "trainee". */ +/** Request parameters of the Trainee method: createSubtrainee. */ export type CreateSubtraineeRequest = { /** * Path to the file (optional) @@ -23,3 +25,15 @@ export type CreateSubtraineeRequest = { */ trainee_id?: string; }; + +/** Response of the Trainee method: createSubtrainee. */ +export type CreateSubtraineeResponse = { + /** + * The ID of the resulting trainee that was created. + */ + id?: string; + /** + * The name of the resulting trainee that was created. + */ + name?: string | string[]; +}; diff --git a/src/types/schemas/DeleteSession.ts b/src/types/schemas/DeleteSession.ts index 951a9cb..8eddd6d 100644 --- a/src/types/schemas/DeleteSession.ts +++ b/src/types/schemas/DeleteSession.ts @@ -1,11 +1,13 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * DeleteSession * * Removes replay specified by session and any references within cases */ +/** Request parameters of the Trainee method: deleteSession. */ export type DeleteSessionRequest = { /** * Session to remove diff --git a/src/types/schemas/DeleteSubtrainee.ts b/src/types/schemas/DeleteSubtrainee.ts index 12cac82..3a8ee29 100644 --- a/src/types/schemas/DeleteSubtrainee.ts +++ b/src/types/schemas/DeleteSubtrainee.ts @@ -1,11 +1,13 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * DeleteSubtrainee * * Destroys the instance of the trainee specified by the parameter "trainee". */ +/** Request parameters of the Trainee method: deleteSubtrainee. */ export type DeleteSubtraineeRequest = { /** * Name path of trainee diff --git a/src/types/schemas/DerivationParameters.ts b/src/types/schemas/DerivationParameters.ts new file mode 100644 index 0000000..d019f8a --- /dev/null +++ b/src/types/schemas/DerivationParameters.ts @@ -0,0 +1,39 @@ +/** + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. + */ +import type { FeatureMetricIndex } from "./FeatureMetricIndex"; + +/** + * A map containing the parameters used in the derivation of a reaction. + */ +export type DerivationParameters = { + /** + * The distance transform used to convert the distance to influence weight. + */ + distance_transform?: number | "surprisal_to_prob"; + /** + * A map of feature names to feature deviations. Values and their shape depend on the properties of the feature. + */ + feature_deviations?: Record; + /** + * A map of feature names to feature weights. + */ + feature_weights?: FeatureMetricIndex; + /** + * The number of most similar cases used to make the prediction. + */ + k?: number; + /** + * A map of nominal feature names to the number of unique classes for each feature. + */ + nominal_class_counts?: FeatureMetricIndex; + /** + * The parameter of the Lebesgue space used in the Minkowski distance. + */ + p?: number; + /** + * Flag indicating if feature weights are derived using inverse-residual weighting. + */ + use_irw?: boolean; +}; diff --git a/src/types/schemas/DesiredConviction.ts b/src/types/schemas/DesiredConviction.ts index 27ba0cf..403d686 100644 --- a/src/types/schemas/DesiredConviction.ts +++ b/src/types/schemas/DesiredConviction.ts @@ -1,10 +1,9 @@ /** - * WARNING: This file is auto generated, do not modify manually. - * - * DesiredConviction + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. */ /** - * If null, will do a discriminative react. if specified, will do a generative react. for generative react, value of desired avg conviction of generated cases, in the range of (0,infinity] with 1 as standard. larger values will increase the variance (or creativity) of the generated case from the existing model. smaller values will decrease the variance (or creativity) of the generated case from the existing model. + * If null, will do a discriminative react. If specified, will do a generative react. For Generative React, value of desired avg conviction of generated cases, in the range of (0,infinity] with 1 as standard. Larger values will increase the variance (or creativity) of the generated case from the existing model. Smaller values will decrease the variance (or creativity) of the generated case from the existing model. */ export type DesiredConviction = number | null; diff --git a/src/types/schemas/DistanceRatioParts.ts b/src/types/schemas/DistanceRatioParts.ts new file mode 100644 index 0000000..39afa79 --- /dev/null +++ b/src/types/schemas/DistanceRatioParts.ts @@ -0,0 +1,18 @@ +/** + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. + */ + +/** + * Map containing the two terms that are used to compute the distance ratio. + */ +export type DistanceRatioParts = { + /** + * The minimum distance between any two cases among the case's most similar trained cases. + */ + local_distance_contribution?: number; + /** + * The distance from the case to its most similar trained case. + */ + nearest_distance?: number; +}; diff --git a/src/types/schemas/EditCases.ts b/src/types/schemas/EditCases.ts index d635853..503c7f9 100644 --- a/src/types/schemas/EditCases.ts +++ b/src/types/schemas/EditCases.ts @@ -1,20 +1,22 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * EditCases * * Edit feature values for the specified cases. - * cases are specified by either case_indices or by the condition. if neither is provided, edits all cases. - * updates the accumulated data mass for the model proportional to the number of cases and features modified. + * Cases are specified by either case_indices or by the condition. If neither is provided, edits all cases. + * Updates the accumulated data mass for the model proportional to the number of cases and features modified. * returns null if invalid features specified or an assoc with "count" */ import type { CaseIndices } from "./CaseIndices"; import type { Condition } from "./Condition"; +/** Request parameters of the Trainee method: editCases. */ export type EditCasesRequest = { /** * List of pair (list) of session id and index, where index is the original 0-based session_training_index of the case as - * it was trained. if specified, ignores condition and condition_session + * it was trained. If specified, ignores condition and condition_session * @default [] */ case_indices?: CaseIndices; @@ -47,8 +49,8 @@ export type EditCasesRequest = { feature_values: any[]; /** - * Limit on the number of cases to edit; if set to zero there will be no limit. - * if null, will be set to k if precision is "similar" or no limit if precision is "exact". default is null + * Limit on the number of cases to edit; If set to zero there will be no limit. + * If null, will be set to k if precision is "similar" or no limit if precision is "exact". default is null */ num_cases?: number; @@ -64,3 +66,8 @@ export type EditCasesRequest = { */ session?: string; }; + +/** Response of the Trainee method: editCases. */ +export type EditCasesResponse = { + count: number; +}; diff --git a/src/types/schemas/EditHistory.ts b/src/types/schemas/EditHistory.ts index 2c9c003..ee9dfaf 100644 --- a/src/types/schemas/EditHistory.ts +++ b/src/types/schemas/EditHistory.ts @@ -1,11 +1,10 @@ /** - * WARNING: This file is auto generated, do not modify manually. - * - * EditHistory + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. */ import type { EditHistoryRecord } from "./EditHistoryRecord"; /** - * The edit history of a given case. keyed by the session id and in order of occurrence. + * The edit history of a given case. Keyed by the session id and in order of occurrence. */ export type EditHistory = Record; diff --git a/src/types/schemas/EditHistoryRecord.ts b/src/types/schemas/EditHistoryRecord.ts index 834ce3b..e04d04d 100644 --- a/src/types/schemas/EditHistoryRecord.ts +++ b/src/types/schemas/EditHistoryRecord.ts @@ -1,7 +1,6 @@ /** - * WARNING: This file is auto generated, do not modify manually. - * - * EditHistoryRecord + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. */ /** @@ -19,7 +18,7 @@ export type EditHistoryRecord = { /** * The type of modification. */ - type?: "set" | "remove" | "impute" | "edit"; + type?: "edit" | "impute" | "remove" | "set"; /** * The new value. */ diff --git a/src/types/schemas/Evaluate.ts b/src/types/schemas/Evaluate.ts index a7a8edc..1d2a802 100644 --- a/src/types/schemas/Evaluate.ts +++ b/src/types/schemas/Evaluate.ts @@ -1,12 +1,14 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * Evaluate * - * Evaluate custom amalgam code for feature values of every case in the model and returns + * Evaluate custom Amalgam code for feature values of every case in the model and returns * a list of the custom code's return values for each feature specified. */ +/** Request parameters of the Trainee method: evaluate. */ export type EvaluateRequest = { /** * Custom code to aggregrate the results from using features_to_code @@ -18,3 +20,15 @@ export type EvaluateRequest = { */ features_to_code_map: Record; }; + +/** Response of the Trainee method: evaluate. */ +export type EvaluateResponse = { + /** + * The resulting value of the aggregation code. + */ + aggregated: any; + /** + * A map of feature names to list of resulting values for the evaluation code for each case. + */ + evaluated: Record; +}; diff --git a/src/types/schemas/ExecuteOnSubtrainee.ts b/src/types/schemas/ExecuteOnSubtrainee.ts index 430b26d..7a49926 100644 --- a/src/types/schemas/ExecuteOnSubtrainee.ts +++ b/src/types/schemas/ExecuteOnSubtrainee.ts @@ -1,21 +1,23 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * ExecuteOnSubtrainee * - * Execute any method in the api directly on any child trainee of this trainee, used for hierarchy operations. + * Execute any method in the API directly on any child trainee of this trainee, used for hierarchy operations. */ +/** Request parameters of the Trainee method: executeOnSubtrainee. */ export type ExecuteOnSubtraineeRequest = { /** * Flag, applicable only to 'load_subtrainee' and 'save_subtrainee' and if specifying child_name_path or child_id. - * for 'save_subtrainee', stores the child out as an independent trainee and removes it as a contained entity. - * for 'load_subtrainee' updates hierarchy by adding the child as an independently stored trainee to the hierarchy without loading the trainee as a subtrainee. + * For 'save_subtrainee', stores the child out as an independent trainee and removes it as a contained entity. + * For 'load_subtrainee' updates hierarchy by adding the child as an independently stored trainee to the hierarchy without loading the trainee as a subtrainee. */ as_external?: boolean; /** - * Id of child trainee to execute method. ignored if child_name_path is specified + * Id of child trainee to execute method. Ignored if child_name_path is specified */ child_id?: string; diff --git a/src/types/schemas/ExportTrainee.ts b/src/types/schemas/ExportTrainee.ts index 7127328..f0238c4 100644 --- a/src/types/schemas/ExportTrainee.ts +++ b/src/types/schemas/ExportTrainee.ts @@ -1,5 +1,6 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * ExportTrainee * @@ -7,16 +8,17 @@ * this method should be run by a script from the ./migrations folder */ +/** Request parameters of the Trainee method: exportTrainee. */ export type ExportTraineeRequest = { /** * Flag, default false. if true will decode (e.g., convert from epoch to datetime) any encoded feature values - * when exporting cases if false case feature values will be exported just as they are stored in the trainee + * when exporting cases If false case feature values will be exported just as they are stored in the trainee * @default false */ decode_cases?: boolean; /** - * Base path to howso engine core installation + * Base path to Howso Engine Core installation */ root_filepath?: string; @@ -27,7 +29,7 @@ export type ExportTraineeRequest = { /** * Path to save the exported meta.json and exp.json files. - * if unspecified, will save them into the base installation /migrations/ directory. + * If unspecified, will save them into the base installation /migrations/ directory. */ trainee_filepath?: string; }; diff --git a/src/types/schemas/FeatureAttributes.ts b/src/types/schemas/FeatureAttributes.ts index 7572716..2b8f1fb 100644 --- a/src/types/schemas/FeatureAttributes.ts +++ b/src/types/schemas/FeatureAttributes.ts @@ -1,26 +1,28 @@ /** - * WARNING: This file is auto generated, do not modify manually. - * - * FeatureAttributes + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. */ -import type { FeatureBoundsMap } from "./FeatureBoundsMap"; +import type { FeatureBounds } from "./FeatureBounds"; +import type { FeatureDataType } from "./FeatureDataType"; +import type { FeatureOriginalType } from "./FeatureOriginalType"; +import type { FeatureType } from "./FeatureType"; /** * The mapping of attributes for a single feature */ export type FeatureAttributes = { /** - * Derive feature by creating two new continuous features: `.series_progress` and `.series_progress_delta`. series progress values range from 0 to 1.0 for each case in the series. series progress delta values are the delta value of the progress for each case. both of these features are used to determine when to stop series synthesis. + * Derive feature by creating two new continuous features: `.series_progress` and `.series_progress_delta`. Series progress values range from 0 to 1.0 for each case in the series. Series progress delta values are the delta value of the progress for each case. Both of these features are used to determine when to stop series synthesis. */ auto_derive_on_train?: { /** - * The amalgam code used to derive the feature value. + * The Amalgam code used to derive the feature value. */ code?: string; /** * The train derive operation type. */ - derive_type?: "custom" | "start" | "end" | "progress"; + derive_type?: "custom" | "end" | "progress" | "start"; /** * Feature name(s) that define the order of the series. */ @@ -30,51 +32,43 @@ export type FeatureAttributes = { */ series_id_features?: string[]; }; - bounds?: FeatureBoundsMap; + bounds?: FeatureBounds; /** - * Cyclic features are set by specifying a `cycle_length` value in the feature attributes. `cycle_length` requires a single value, which is the upper bound of the difference for the cycle range. for example, if `cycle_length` is 360, then a value of 1 and 359 will have a difference of 2. cyclic features have no restrictions in the input dataset, however, cyclic features will be output on a scale from 0 to `cycle_length`. to constrain the output to a different range, modify the `min` and `max` `bounds` feature attribute. + * Cyclic features are set by specifying a `cycle_length` value in the feature attributes. `cycle_length` requires a single value, which is the upper bound of the difference for the cycle range. For example, if `cycle_length` is 360, then a value of 1 and 359 will have a difference of 2. Cyclic features have no restrictions in the input dataset, however, cyclic features will be output on a scale from 0 to `cycle_length`. To constrain the output to a different range, modify the `min` and `max` `bounds` feature attribute. * - * examples: + * Examples: * - degrees: values should be 0-359, cycle_length = 360 * - days: values should be 0-6, cycle_length = 7 * - hours: values should be 0-23, cycle_length = 24 */ cycle_length?: number; + data_type?: FeatureDataType; /** - * Specify the data type for features with a type of nominal or continuous. default is `string` for nominals and `number` for continuous. - * - * valid values include: - * - `string`, `number`, `formatted_date_time`, `json`, `amalgam`, `yaml`: valid for both nominal and continuous. - * - `string_mixable`: valid only when type is continuous (predicted values may result in interpolated strings containing a combination of characters from multiple original values). - * - `boolean`: valid only for nominals. - */ - data_type?: "string" | "number" | "boolean" | "formatted_date_time" | "string_mixable" | "json" | "yaml" | "amalgam"; - /** - * If specified, feature values should match the date format specified by this string. only applicable to continuous features. + * If specified, feature values should match the date format specified by this string. Only applicable to continuous features. */ date_time_format?: string; /** - * Decimal places to round to, default is no rounding. if `significant_digits` is also specified, the number will be rounded to the specified number of significant digits first, then rounded to the number of decimal points as specified by this parameter. + * Decimal places to round to, default is no rounding. If `significant_digits` is also specified, the number will be rounded to the specified number of significant digits first, then rounded to the number of decimal points as specified by this parameter. */ decimal_places?: number; /** - * A list of other feature names that this feature either depends on or features that depend on this feature. should be used when there are multi-type value features that tightly depend on values based on other multi-type value features. + * A list of other feature names that this feature either depends on or features that depend on this feature. Should be used when there are multi-type value features that tightly depend on values based on other multi-type value features. */ dependent_features?: string[]; /** - * Code defining how the value for this feature could be derived if this feature is specified as a `derived_context_feature` or a `derived_action_feature` during react flows. for `react_series`, the data referenced is the accumulated series data (as a list of rows), and for non-series reacts, the data is the one single row. each row is comprised of all the combined context and action features. referencing data in these rows uses 0-based indexing, where the current row index is 0, the previous row's is 1, etc. the specified code may do simple logic and numeric operations on feature values referenced via feature name and row offset + * Code defining how the value for this feature could be derived if this feature is specified as a `derived_context_feature` or a `derived_action_feature` during react flows. For `react_series`, the data referenced is the accumulated series data (as a list of rows), and for non-series reacts, the data is the one single row. Each row is comprised of all the combined context and action features. Referencing data in these rows uses 0-based indexing, where the current row index is 0, the previous row's is 1, etc. The specified code may do simple logic and numeric operations on feature values referenced via feature name and row offset * - * examples: - * - ``"#x 1"``: use the value for feature 'x' from the previously processed row (offset of 1, one lag value). - * - ``"(- #y 0 #x 1)"``: feature 'y' value from current (offset 0) row minus feature 'x' value from previous (offset 1) row. + * Examples: + * - ``"#x 1"``: Use the value for feature 'x' from the previously processed row (offset of 1, one lag value). + * - ``"(- #y 0 #x 1)"``: Feature 'y' value from current (offset 0) row minus feature 'x' value from previous (offset 1) row. */ derived_feature_code?: string; /** - * Set to true for nominal features containing nominal ids, specifying that his feature should be used to compute case weights for id based privacy. for time series, this feature will be used as the id for each time series generation. + * Set to true for nominal features containing nominal IDs, specifying that his feature should be used to compute case weights for id based privacy. For time series, this feature will be used as the id for each time series generation. */ id_feature?: boolean; /** - * The date time format locale. if unspecified, uses platform default locale. + * The date time format locale. If unspecified, uses platform default locale. */ locale?: string; /** @@ -82,34 +76,29 @@ export type FeatureAttributes = { */ max_row_lag?: number; /** - * Flag a categorical nominal feature as non-sensitive. it is recommended that all nominal features be represented with either an `int-id` subtype or another available nominal subtype using the `subtype` attribute. however, if the nominal feature is non-sensitive, setting this parameter to true will bypass the `subtype` requirement. only applicable to nominal features. + * Flag a categorical nominal feature as non-sensitive. It is recommended that all nominal features be represented with either an `int-id` subtype or another available nominal subtype using the `subtype` attribute. However, if the nominal feature is non-sensitive, setting this parameter to true will bypass the `subtype` requirement. Only applicable to nominal features. */ non_sensitive?: boolean; /** - * Modify how dependent features with nulls are treated during a react, specifically when they use null as a context value. only applicable to dependent features. + * Modify how dependent features with nulls are treated during a react, specifically when they use null as a context value. Only applicable to dependent features. * - * when false (default), the feature will be treated as a non-dependent context feature. - * when true for nominal types, treats null as an individual dependent class value, only cases that also have nulls as this feature's value will be considered. - * when true for continuous types, only the cases with the same dependent feature values as the cases that also have nulls as this feature's value will be considered. + * When false (default), the feature will be treated as a non-dependent context feature. + * When true for nominal types, treats null as an individual dependent class value, only cases that also have nulls as this feature's value will be considered. + * When true for continuous types, only the cases with the same dependent feature values as the cases that also have nulls as this feature's value will be considered. */ null_is_dependent?: boolean; /** - * Specifies the observational mean absolute error for this feature. use when the error value is already known. + * Specifies the observational mean absolute error for this feature. Use when the error value is already known. */ observational_error?: number; /** - * Original data formats used by clients. automatically populated by clients to store client language specific context about features. + * Original data formats used by clients. Automatically populated by clients to store client language specific context about features. */ original_format?: any; /** - * Original data type details. used by clients to determine how to serialize and deserialize feature data. + * Original data type details. Used by clients to determine how to serialize and deserialize feature data. */ - original_type?: { - /** - * The original type of the data. - */ - data_type: "object" | "string" | "numeric" | "integer" | "boolean" | "datetime" | "time" | "date" | "timedelta"; - } & Record; + original_type?: FeatureOriginalType; /** * The feature whose values this time-series feature's values are derived from. */ @@ -119,7 +108,7 @@ export type FeatureAttributes = { */ parent_type?: "delta" | "rate"; /** - * Custom amalgam code that is called on resulting values of this feature during react operations. + * Custom Amalgam code that is called on resulting values of this feature during react operations. */ post_process?: string; /** @@ -139,23 +128,23 @@ export type FeatureAttributes = { */ time_series?: { /** - * If specified, ensures that the largest difference between feature values is not larger than this specified value. a null value means no max boundary. the length of the list must match the number of derivatives as specified by `order`. only applicable when time series type is set to `delta`. + * If specified, ensures that the largest difference between feature values is not larger than this specified value. A null value means no max boundary. The length of the list must match the number of derivatives as specified by `order`. Only applicable when time series type is set to `delta`. */ delta_max?: number[]; /** - * If specified, ensures that the smallest difference between features values is not smaller than this specified value. a null value means no min boundary. the length of the list must match the number of derivatives as specified by `order`. only applicable when time series type is set to `delta`. + * If specified, ensures that the smallest difference between features values is not smaller than this specified value. A null value means no min boundary. The length of the list must match the number of derivatives as specified by `order`. Only applicable when time series type is set to `delta`. */ delta_min?: number[]; /** - * The number of orders of derivatives that should be derived instead of synthesized. ignored if order is not provided. + * The number of orders of derivatives that should be derived instead of synthesized. Ignored if order is not provided. */ derived_orders?: number; /** - * If specified, generates lag features containing previous values using the enumerated lag offsets. takes precedence over `num_lags`. if neither `num_lags` nor `lags` is specified for a feature, then a single lag feature is generated. + * If specified, generates lag features containing previous values using the enumerated lag offsets. Takes precedence over `num_lags`. If neither `num_lags` nor `lags` is specified for a feature, then a single lag feature is generated. */ lags?: number[]; /** - * If specified, generates the specified amount of lag features containing previous values. if `lags` is specified, then this parameter will be ignored. if neither `num_lags` nor `lags` is specified for a feature, then a single lag feature is generated. + * If specified, generates the specified amount of lag features containing previous values. If `lags` is specified, then this parameter will be ignored. If neither `num_lags` nor `lags` is specified for a feature, then a single lag feature is generated. */ num_lags?: number; /** @@ -163,31 +152,31 @@ export type FeatureAttributes = { */ order?: number; /** - * If specified, ensures that the rate (the difference quotient, the discrete version of derivative) for this feature won't be more than the value provided. a null value means no max boundary. the value must be in epoch format for the time feature. the length of the list must match the number of derivatives as specified by `order`. only applicable when time series type is set to `rate`. + * If specified, ensures that the rate (the difference quotient, the discrete version of derivative) for this feature won't be more than the value provided. A null value means no max boundary. The value must be in epoch format for the time feature. The length of the list must match the number of derivatives as specified by `order`. Only applicable when time series type is set to `rate`. */ rate_max?: number[]; /** - * If specified, ensures that the rate (the difference quotient, the discrete version of derivative) for this feature won't be less than the value provided. a null value means no min boundary. the value must be in epoch format for the time feature. the length of the list must match the number of derivatives as specified by `order`. only applicable when time series type is set to `rate`. + * If specified, ensures that the rate (the difference quotient, the discrete version of derivative) for this feature won't be less than the value provided. A null value means no min boundary. The value must be in epoch format for the time feature. The length of the list must match the number of derivatives as specified by `order`. Only applicable when time series type is set to `rate`. */ rate_min?: number[]; /** - * When true, requires that the model identify and learn values that explicitly denote the end of a series. only applicable to id features for a series. + * When true, requires that the model identify and learn values that explicitly denote the end of a series. Only applicable to id features for a series. */ series_has_terminators?: boolean; /** - * When true, requires that a series ends on a terminator value. only applicable to id features for a series. + * When true, requires that a series ends on a terminator value. Only applicable to id features for a series. */ stop_on_terminator?: boolean; /** - * When true, the feature will be treated as the time feature for time series modeling. additionally, time features must use type `delta`. + * When true, the feature will be treated as the time feature for time series modeling. Additionally, time features must use type `delta`. */ time_feature?: boolean; /** - * When `rate` is specified, uses the difference of the current value from its previous value divided by the change in time since the previous value. when `delta` is specified, uses the difference of the current value from its previous value regardless of the elapsed time. set to `delta` if feature has `time_feature` set to true. + * When `rate` is specified, uses the difference of the current value from its previous value divided by the change in time since the previous value. When `delta` is specified, uses the difference of the current value from its previous value regardless of the elapsed time. Set to `delta` if feature has `time_feature` set to true. */ - type?: "rate" | "delta"; + type?: "delta" | "rate"; /** - * Controls whether future values of independent time series are considered. applicable only to the time feature. when false, the time feature is not universal and allows using future data from other series in decisions; this is applicable when the time is not globally relevant and is independent for each time series. when true, universally excludes using any data with from the future from all series; this is applicable when time is globally relevant and there are events that may affect all time series. if there is any possibility of global relevancy of time, it is generally recommended to set this value to true, which is the default. + * Controls whether future values of independent time series are considered. Applicable only to the time feature. When false, the time feature is not universal and allows using future data from other series in decisions; this is applicable when the time is not globally relevant and is independent for each time series. When true, universally excludes using any data with from the future from all series; this is applicable when time is globally relevant and there are events that may affect all time series. If there is any possibility of global relevancy of time, it is generally recommended to set this value to true, which is the default. */ universal?: boolean; }; @@ -198,17 +187,10 @@ export type FeatureAttributes = { /** * The type of value being captured by this time-series feature. */ - ts_type?: "lag" | "delta" | "rate"; - /** - * The type of the feature. - * - * - continuous: a continuous numeric value. (e.g. temperature or humidity) - * - nominal: a numeric or string value with no ordering. (e.g. the name of a fruit) - * - ordinal: a nominal numeric value with ordering. (e.g. rating scale, 1-5 stars) - */ - type: "continuous" | "ordinal" | "nominal"; + ts_type?: "delta" | "lag" | "rate"; + type: FeatureType; /** - * Flag feature as only having unique values. only applicable to nominals features. + * Flag feature as only having unique values. Only applicable to nominals features. */ unique?: boolean; }; diff --git a/src/types/schemas/FeatureAttributesIndex.ts b/src/types/schemas/FeatureAttributesIndex.ts index 5c1c7d6..51a7ecf 100644 --- a/src/types/schemas/FeatureAttributesIndex.ts +++ b/src/types/schemas/FeatureAttributesIndex.ts @@ -1,7 +1,6 @@ /** - * WARNING: This file is auto generated, do not modify manually. - * - * FeatureAttributesIndex + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. */ import type { FeatureAttributes } from "./FeatureAttributes"; diff --git a/src/types/schemas/FeatureBoundsMap.ts b/src/types/schemas/FeatureBounds.ts similarity index 57% rename from src/types/schemas/FeatureBoundsMap.ts rename to src/types/schemas/FeatureBounds.ts index 44316bb..fc7cdd9 100644 --- a/src/types/schemas/FeatureBoundsMap.ts +++ b/src/types/schemas/FeatureBounds.ts @@ -1,33 +1,32 @@ /** - * WARNING: This file is auto generated, do not modify manually. - * - * FeatureBoundsMap + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. */ /** * A map defining any feature bounds, allowed values, and constraints. */ -export type FeatureBoundsMap = { +export type FeatureBounds = { /** * Explicitly allowed values to be output. */ allowed?: any[]; /** - * Allow nulls to be output, per their distribution in the data. defaults to true. + * Allow nulls to be output, per their distribution in the data. Defaults to true. */ allow_null?: boolean; /** - * Amalgam code, whose logic has to evaluate to true for value to be considered valid when this feature is being generated. same format as 'derived_feature_code'. - * examples: - * - ``"(> #f1 0 #f2 0)"``: feature 'f1' value from current (offset 0) data must be bigger than feature 'f2' value from current (offset 0) data. + * Amalgam code, whose logic has to evaluate to true for value to be considered valid when this feature is being generated. Same format as 'derived_feature_code'. + * Examples: + * - ``"(> #f1 0 #f2 0)"``: Feature 'f1' value from current (offset 0) data must be bigger than feature 'f2' value from current (offset 0) data. */ constraint?: string; /** - * The maximum value to be output. may be a number or date string. + * The maximum value to be output. May be a number or date string. */ max?: number | string; /** - * The minimum value to be output. may be a number or date string. + * The minimum value to be output. May be a number or date string. */ min?: number | string; }; diff --git a/src/types/schemas/FeatureDataType.ts b/src/types/schemas/FeatureDataType.ts new file mode 100644 index 0000000..32075c6 --- /dev/null +++ b/src/types/schemas/FeatureDataType.ts @@ -0,0 +1,23 @@ +/** + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. + */ + +/** + * The data type of a feature. Default is `string` for nominals and `number` for continuous. + * + * Valid values include: + * - `string`, `number`, `formatted_date_time`, `formatted_time`, `json`, `amalgam`, `yaml`: Valid for both nominal and continuous. + * - `string_mixable`: Valid only when type is continuous (predicted values may result in interpolated strings containing a combination of characters from multiple original values). + * - `boolean`: Valid only for nominals. + */ +export type FeatureDataType = + | "amalgam" + | "boolean" + | "formatted_date_time" + | "formatted_time" + | "json" + | "number" + | "string" + | "string_mixable" + | "yaml"; diff --git a/src/types/schemas/FeatureMetricIndex.ts b/src/types/schemas/FeatureMetricIndex.ts new file mode 100644 index 0000000..ae82225 --- /dev/null +++ b/src/types/schemas/FeatureMetricIndex.ts @@ -0,0 +1,9 @@ +/** + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. + */ + +/** + * Map of feature names to numeric values. + */ +export type FeatureMetricIndex = Record; diff --git a/src/types/schemas/FeatureOriginalType.ts b/src/types/schemas/FeatureOriginalType.ts new file mode 100644 index 0000000..611250a --- /dev/null +++ b/src/types/schemas/FeatureOriginalType.ts @@ -0,0 +1,27 @@ +/** + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. + */ +import type { FeatureOriginalTypeBoolean } from "./FeatureOriginalTypeBoolean"; +import type { FeatureOriginalTypeDate } from "./FeatureOriginalTypeDate"; +import type { FeatureOriginalTypeDatetime } from "./FeatureOriginalTypeDatetime"; +import type { FeatureOriginalTypeInteger } from "./FeatureOriginalTypeInteger"; +import type { FeatureOriginalTypeNumeric } from "./FeatureOriginalTypeNumeric"; +import type { FeatureOriginalTypeObject } from "./FeatureOriginalTypeObject"; +import type { FeatureOriginalTypeString } from "./FeatureOriginalTypeString"; +import type { FeatureOriginalTypeTime } from "./FeatureOriginalTypeTime"; +import type { FeatureOriginalTypeTimedelta } from "./FeatureOriginalTypeTimedelta"; + +/** + * Original data type details. Used by clients to determine how to serialize and deserialize feature data. + */ +export type FeatureOriginalType = + | FeatureOriginalTypeBoolean + | FeatureOriginalTypeDate + | FeatureOriginalTypeDatetime + | FeatureOriginalTypeInteger + | FeatureOriginalTypeNumeric + | FeatureOriginalTypeString + | FeatureOriginalTypeTime + | FeatureOriginalTypeTimedelta + | FeatureOriginalTypeObject; diff --git a/src/types/schemas/FeatureOriginalTypeBoolean.ts b/src/types/schemas/FeatureOriginalTypeBoolean.ts new file mode 100644 index 0000000..4be4e88 --- /dev/null +++ b/src/types/schemas/FeatureOriginalTypeBoolean.ts @@ -0,0 +1,14 @@ +/** + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. + */ + +/** + * FeatureOriginalTypeBoolean schema. + */ +export type FeatureOriginalTypeBoolean = { + /** + * The data type kind. + */ + data_type: "boolean"; +}; diff --git a/src/types/schemas/FeatureOriginalTypeDate.ts b/src/types/schemas/FeatureOriginalTypeDate.ts new file mode 100644 index 0000000..8274158 --- /dev/null +++ b/src/types/schemas/FeatureOriginalTypeDate.ts @@ -0,0 +1,14 @@ +/** + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. + */ + +/** + * FeatureOriginalTypeDate schema. + */ +export type FeatureOriginalTypeDate = { + /** + * The data type kind. + */ + data_type: "date"; +}; diff --git a/src/types/schemas/FeatureOriginalTypeDatetime.ts b/src/types/schemas/FeatureOriginalTypeDatetime.ts new file mode 100644 index 0000000..eefdc66 --- /dev/null +++ b/src/types/schemas/FeatureOriginalTypeDatetime.ts @@ -0,0 +1,18 @@ +/** + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. + */ + +/** + * FeatureOriginalTypeDatetime schema. + */ +export type FeatureOriginalTypeDatetime = { + /** + * The data type kind. + */ + data_type: "datetime"; + /** + * The standardized timezone name. + */ + timezone?: string | null; +}; diff --git a/src/types/schemas/FeatureOriginalTypeInteger.ts b/src/types/schemas/FeatureOriginalTypeInteger.ts new file mode 100644 index 0000000..a46ea6a --- /dev/null +++ b/src/types/schemas/FeatureOriginalTypeInteger.ts @@ -0,0 +1,22 @@ +/** + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. + */ + +/** + * FeatureOriginalTypeInteger schema. + */ +export type FeatureOriginalTypeInteger = { + /** + * The data type kind. + */ + data_type: "integer"; + /** + * The size of the integer (in bytes). + */ + size?: number | null; + /** + * If the integer is unsigned. + */ + unsigned?: boolean; +}; diff --git a/src/types/schemas/FeatureOriginalTypeNumeric.ts b/src/types/schemas/FeatureOriginalTypeNumeric.ts new file mode 100644 index 0000000..8bd41c2 --- /dev/null +++ b/src/types/schemas/FeatureOriginalTypeNumeric.ts @@ -0,0 +1,22 @@ +/** + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. + */ + +/** + * FeatureOriginalTypeNumeric schema. + */ +export type FeatureOriginalTypeNumeric = { + /** + * The data type kind. + */ + data_type: "numeric"; + /** + * The format of the number. + */ + format?: "decimal" | null; + /** + * The size of the number (in bytes). + */ + size?: number | null; +}; diff --git a/src/types/schemas/FeatureOriginalTypeObject.ts b/src/types/schemas/FeatureOriginalTypeObject.ts new file mode 100644 index 0000000..13bda16 --- /dev/null +++ b/src/types/schemas/FeatureOriginalTypeObject.ts @@ -0,0 +1,14 @@ +/** + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. + */ + +/** + * FeatureOriginalTypeObject schema. + */ +export type FeatureOriginalTypeObject = { + /** + * The data type kind. + */ + data_type: "object"; +}; diff --git a/src/types/schemas/FeatureOriginalTypeString.ts b/src/types/schemas/FeatureOriginalTypeString.ts new file mode 100644 index 0000000..9d9caf3 --- /dev/null +++ b/src/types/schemas/FeatureOriginalTypeString.ts @@ -0,0 +1,22 @@ +/** + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. + */ + +/** + * FeatureOriginalTypeString schema. + */ +export type FeatureOriginalTypeString = { + /** + * The data type kind. + */ + data_type: "string"; + /** + * The string encoding type. + */ + encoding?: string | null; + /** + * The maximum allowed length of the string. + */ + length?: number | null; +}; diff --git a/src/types/schemas/FeatureOriginalTypeTime.ts b/src/types/schemas/FeatureOriginalTypeTime.ts new file mode 100644 index 0000000..1ba51c7 --- /dev/null +++ b/src/types/schemas/FeatureOriginalTypeTime.ts @@ -0,0 +1,18 @@ +/** + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. + */ + +/** + * FeatureOriginalTypeTime schema. + */ +export type FeatureOriginalTypeTime = { + /** + * The data type kind. + */ + data_type: "time"; + /** + * The standardized timezone name. + */ + timezone?: string | null; +}; diff --git a/src/types/schemas/FeatureOriginalTypeTimedelta.ts b/src/types/schemas/FeatureOriginalTypeTimedelta.ts new file mode 100644 index 0000000..b369c0e --- /dev/null +++ b/src/types/schemas/FeatureOriginalTypeTimedelta.ts @@ -0,0 +1,18 @@ +/** + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. + */ + +/** + * FeatureOriginalTypeTimedelta schema. + */ +export type FeatureOriginalTypeTimedelta = { + /** + * The data type kind. + */ + data_type: "timedelta"; + /** + * The unit of the time delta. + */ + unit?: "days" | "nanoseconds" | "seconds"; +}; diff --git a/src/types/schemas/FeatureType.ts b/src/types/schemas/FeatureType.ts new file mode 100644 index 0000000..347c14a --- /dev/null +++ b/src/types/schemas/FeatureType.ts @@ -0,0 +1,13 @@ +/** + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. + */ + +/** + * The type of the feature. + * + * - continuous: A continuous numeric value. (e.g. Temperature or humidity) + * - nominal: A numeric or string value with no ordering. (e.g. The name of a fruit) + * - ordinal: A nominal numeric value with ordering. (e.g. Rating scale, 1-5 stars) + */ +export type FeatureType = "continuous" | "nominal" | "ordinal"; diff --git a/src/types/schemas/FullCaseContribution.ts b/src/types/schemas/FullCaseContribution.ts new file mode 100644 index 0000000..765347a --- /dev/null +++ b/src/types/schemas/FullCaseContribution.ts @@ -0,0 +1,13 @@ +/** + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. + */ + +/** + * A map for an influential case that describes its training index, session, and the full contribution to the action feature. + */ +export type FullCaseContribution = { + ".session"?: string; + ".session_training_index"?: number; + case_contributions_full?: number; +}; diff --git a/src/types/schemas/FullHyperparameterMap.ts b/src/types/schemas/FullHyperparameterMap.ts deleted file mode 100644 index e9e1f5f..0000000 --- a/src/types/schemas/FullHyperparameterMap.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * WARNING: This file is auto generated, do not modify manually. - * - * FullHyperparameterMap - */ -import type { HyperparameterMap } from "./HyperparameterMap"; - -export type FullHyperparameterMap = Record>>>; diff --git a/src/types/schemas/GenerateNewCases.ts b/src/types/schemas/GenerateNewCases.ts index 12d2d0b..491cda2 100644 --- a/src/types/schemas/GenerateNewCases.ts +++ b/src/types/schemas/GenerateNewCases.ts @@ -1,13 +1,12 @@ /** - * WARNING: This file is auto generated, do not modify manually. - * - * GenerateNewCases + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. */ /** - * Control whether generated cases can be those that already exist in the model. this parameter takes in a string that could be one of the following: + * Control whether generated cases can be those that already exist in the model. This parameter takes in a string that could be one of the following: * a. "attempt": attempts to generate new cases and if its not possible to generate a new case, it might generate cases in "no" mode (see point c.) * b. "always": always generates new cases and if its not possible to generate a new case, it returns nulls. * c. "no": generates data based on the `desired_conviction` specified and the generated data is not guaranteed to be a new case (that is, a case not found in original dataset.) */ -export type GenerateNewCases = "no" | "attempt" | "always"; +export type GenerateNewCases = "always" | "attempt" | "no"; diff --git a/src/types/schemas/GetAutoAblationParams.ts b/src/types/schemas/GetAutoAblationParams.ts new file mode 100644 index 0000000..60dacbe --- /dev/null +++ b/src/types/schemas/GetAutoAblationParams.ts @@ -0,0 +1,65 @@ +/** + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. + * + * GetAutoAblationParams + * + * Get auto-ablation parameters set by #set_auto_ablation_params + */ +import type { AblationThresholdMap } from "./AblationThresholdMap"; + +/** Response of the Trainee method: getAutoAblationParams. */ +export type GetAutoAblationParamsResponse = { + /** + * The absolute threshold map set by set_auto_ablation_params, if any. + */ + abs_threshold_map?: AblationThresholdMap; + /** + * Flag indicating if automatic ablation is enabled. + */ + auto_ablation_enabled?: boolean; + /** + * The name of the weight feature which is accumulated and used in automatic ablation. + */ + auto_ablation_weight_feature?: string; + /** + * The conviction threshold above which cases will be ablated. + */ + conviction_lower_threshold?: number; + /** + * The conviction threshold below which cases will be ablated. + */ + conviction_upper_threshold?: number; + /** + * The delta threshold map set by set_auto_ablation_params, if any. + */ + delta_threshold_map?: AblationThresholdMap; + /** + * The list of features that if predicted correctly on a new case will trigger the ablation of the case. + */ + exact_prediction_features?: string[]; + /** + * The minimum threshold of influence weight entropy for a case to be ablated in the process of automatic ablation. + */ + influence_weight_entropy_threshold?: number; + /** + * The minimum number of cases to train before automatic ablation begins. + */ + minimum_num_cases?: number; + /** + * The map of features to relative thresholds that if predicted within on a new case will trigger the ablation of the case. + */ + relative_prediction_threshold_map?: Record; + /** + * The relative threshold map set by set_auto_ablation_params, if any. + */ + rel_threshold_map?: AblationThresholdMap; + /** + * The list of features that if predicted within their residual on a new case will trigger the ablation of the case. + */ + residual_prediction_features?: string[]; + /** + * The map of features to absolute thresholds that if predicted within on a new case will trigger the ablation of the case. + */ + tolerance_prediction_threshold_map?: Record; +}; diff --git a/src/types/schemas/GetCases.ts b/src/types/schemas/GetCases.ts index e8a680e..b68a55b 100644 --- a/src/types/schemas/GetCases.ts +++ b/src/types/schemas/GetCases.ts @@ -1,20 +1,22 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * GetCases * - * Returns assoc with features and cases - a list of lists of all feature values. retrieves all feature values for cases for - * all (unordered) sessions in the order they were trained within each session. if a session is specified, only that session's + * Returns assoc with features and cases - a list of lists of all feature values. Retrieves all feature values for cases for + * all (unordered) sessions in the order they were trained within each session. If a session is specified, only that session's * cases wil be output. */ import type { CaseIndices } from "./CaseIndices"; import type { Condition } from "./Condition"; import type { Precision } from "./Precision"; +/** Request parameters of the Trainee method: getCases. */ export type GetCasesRequest = { /** * List of pair (list) of session id and index, where index is the original 0-based session_training_index of the - * case as it was trained. if specified, ignores session and condition/precision parameters. + * case as it was trained. If specified, ignores session and condition/precision parameters. */ case_indices?: CaseIndices; @@ -36,8 +38,8 @@ export type GetCasesRequest = { indicate_imputed?: boolean; /** - * Limit on the number of cases to retrieve; if set to zero there will be no limit. - * if null, will be set to k if precision is "similar" or no limit if precision is "exact". default is null + * Limit on the number of cases to retrieve; If set to zero there will be no limit. + * If null, will be set to k if precision is "similar" or no limit if precision is "exact". default is null */ num_cases?: number; @@ -65,7 +67,14 @@ export type GetCasesRequest = { skip_decoding?: number; }; +/** Response of the Trainee method: getCases. */ export type GetCasesResponse = { - cases?: any[][]; - features?: string[]; + /** + * A list of lists of case values in the order specified by 'features'. + */ + cases: any[][]; + /** + * The list of features in the order of values of the sublists in 'cases'. + */ + features: string[]; }; diff --git a/src/types/schemas/GetDistances.ts b/src/types/schemas/GetDistances.ts index a7f4585..df77b5c 100644 --- a/src/types/schemas/GetDistances.ts +++ b/src/types/schemas/GetDistances.ts @@ -1,19 +1,15 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * GetDistances * * Returns an assoc with case distances, containing a list of case session indices and a list of lists (matrix) of the computed distances. - * in the following format: - * { - * 'column_case_indices' : [ session-indices ], - * 'row_case_indices' : [ session-indices ], - * 'distances': [ [ pairwise distances ] ] - * } */ import type { CaseIndices } from "./CaseIndices"; import type { UseCaseWeights } from "./UseCaseWeights"; +/** Request parameters of the Trainee method: getDistances. */ export type GetDistancesRequest = { /** * If specified, uses targeted hyperparameters used to predict this action_feature, otherwise uses targetless hyperparameters. @@ -22,13 +18,13 @@ export type GetDistancesRequest = { /** * List of pair (list) of session id and index, where index is the original 0-based session_training_index of the case as it was - * trained. if specified, returns pairwise distances for all of these cases. ignored if feature_values is provided. if neither feature_values nor + * trained. If specified, returns pairwise distances for all of these cases. Ignored if feature_values is provided. If neither feature_values nor * case_indices is specified, runs on the full dataset. */ case_indices?: CaseIndices; /** - * Number of columns to compute in the matrix. if unspecified, is set to the same number as all the cases. + * Number of columns to compute in the matrix. If unspecified, is set to the same number as all the cases. */ column_count?: number; @@ -39,7 +35,7 @@ export type GetDistancesRequest = { column_offset?: number; /** - * Which features to use when computing case distances. if unspecified uses all features. + * Which features to use when computing case distances. If unspecified uses all features. */ features?: string[]; @@ -49,7 +45,7 @@ export type GetDistancesRequest = { feature_values?: any[]; /** - * Number of rows to compute in the matrix. if unspecified, is set to the same number as all the cases. + * Number of rows to compute in the matrix. If unspecified, is set to the same number as all the cases. */ row_count?: number; @@ -60,7 +56,7 @@ export type GetDistancesRequest = { row_offset?: number; /** - * Flag, if set to true will scale influence weights by each case's weight_feature weight. if unspecified, + * Flag, if set to true will scale influence weights by each case's weight_feature weight. If unspecified, * case weights will be used if the trainee has them. */ use_case_weights?: UseCaseWeights; @@ -71,3 +67,19 @@ export type GetDistancesRequest = { */ weight_feature?: string; }; + +/** Response of the Trainee method: getDistances. */ +export type GetDistancesResponse = { + /** + * The case indices of the cases represented by the columns of the distance matrix. + */ + column_case_indices?: CaseIndices; + /** + * The case indices of the cases represented by the columns of the distance matrix. + */ + distances: number[][]; + /** + * The case indices of the cases represented by the columns of the distance matrix. + */ + row_case_indices?: CaseIndices; +}; diff --git a/src/types/schemas/GetEntityPathById.ts b/src/types/schemas/GetEntityPathById.ts index 4ddb04d..302497a 100644 --- a/src/types/schemas/GetEntityPathById.ts +++ b/src/types/schemas/GetEntityPathById.ts @@ -1,13 +1,15 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * GetEntityPathById * * Returns the full entity path to a child trainee provided its unique trainee id if it is contained in the hierarchy. - * iterates down the hierarchy searching for a trainee that matches the specified id, returns null if not found or + * Iterates down the hierarchy searching for a trainee that matches the specified id, returns null if not found or * a string error if found but trainee is stored externally as an independent trainee. */ +/** Request parameters of the Trainee method: getEntityPathById. */ export type GetEntityPathByIdRequest = { /** * Unique id of trainee @@ -19,3 +21,6 @@ export type GetEntityPathByIdRequest = { */ path: string[]; }; + +/** Response of the Trainee method: getEntityPathById. */ +export type GetEntityPathByIdResponse = string[] | string | null; diff --git a/src/types/schemas/GetExtremeCases.ts b/src/types/schemas/GetExtremeCases.ts index 0c6f5b4..2bea1ee 100644 --- a/src/types/schemas/GetExtremeCases.ts +++ b/src/types/schemas/GetExtremeCases.ts @@ -1,11 +1,13 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * GetExtremeCases * * Retrieve the top or bottom number of cases for a specified feature, sorted top to bottom for top, and bottom to top for bottom */ +/** Request parameters of the Trainee method: getExtremeCases. */ export type GetExtremeCasesRequest = { /** * The features for which values should be returned @@ -22,3 +24,15 @@ export type GetExtremeCasesRequest = { */ sort_feature: string; }; + +/** Response of the Trainee method: getExtremeCases. */ +export type GetExtremeCasesResponse = { + /** + * A list of lists of case values in the order specified by 'features'. + */ + cases: any[][]; + /** + * The list of features in the order of values of the sublists in 'cases'. + */ + features: string[]; +}; diff --git a/src/types/schemas/GetFeatureConviction.ts b/src/types/schemas/GetFeatureConviction.ts index 9d030b6..f31061f 100644 --- a/src/types/schemas/GetFeatureConviction.ts +++ b/src/types/schemas/GetFeatureConviction.ts @@ -1,5 +1,6 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * GetFeatureConviction * @@ -7,6 +8,7 @@ */ import type { UseCaseWeights } from "./UseCaseWeights"; +/** Request parameters of the Trainee method: getFeatureConviction. */ export type GetFeatureConvictionRequest = { /** * List of action features to use as the baseline for conviction instead of the full model @@ -39,7 +41,7 @@ export type GetFeatureConvictionRequest = { features?: string[]; /** - * Flag, if set to true will scale influence weights by each case's weight_feature weight. if unspecified, + * Flag, if set to true will scale influence weights by each case's weight_feature weight. If unspecified, * case weights will be used if the trainee has them. */ use_case_weights?: UseCaseWeights; @@ -50,3 +52,15 @@ export type GetFeatureConvictionRequest = { */ weight_feature?: string; }; + +/** Response of the Trainee method: getFeatureConviction. */ +export type GetFeatureConvictionResponse = { + /** + * A the familiarity conviction of adding the feature to the model. + */ + familiarity_conviction_addition?: Record; + /** + * A the familiarity conviction of removing the feature from the model. + */ + familiarity_conviction_removal?: Record; +}; diff --git a/src/types/schemas/GetHierarchy.ts b/src/types/schemas/GetHierarchy.ts new file mode 100644 index 0000000..001cc00 --- /dev/null +++ b/src/types/schemas/GetHierarchy.ts @@ -0,0 +1,12 @@ +/** + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. + * + * GetHierarchy + * + * Pull the hierarchy for a trainee, returns an assoc of: + * the currently contained hierarchy as a nested assoc with (false) for trainees that are stored independently. + */ + +/** Response of the Trainee method: getHierarchy. */ +export type GetHierarchyResponse = Record; diff --git a/src/types/schemas/GetMarginalStats.ts b/src/types/schemas/GetMarginalStats.ts index a15c328..d20b196 100644 --- a/src/types/schemas/GetMarginalStats.ts +++ b/src/types/schemas/GetMarginalStats.ts @@ -1,14 +1,16 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * GetMarginalStats * * Outputs all marginal stats (min, max, median, mean, mode, count, uniques, mean_absdev, variance, stddev, skew, kurtosis, entropy) - * for all features in the format of feature -> assoc stat -> value. the marginal stats can be computed for a subset of the data using condition, precision, and num_cases + * for all features in the format of feature -> assoc stat -> value. The marginal stats can be computed for a subset of the data using condition, precision, and num_cases */ import type { Condition } from "./Condition"; import type { Precision } from "./Precision"; +/** Request parameters of the Trainee method: getMarginalStats. */ export type GetMarginalStatsRequest = { /** * Assoc of feature->value(s) @@ -22,8 +24,8 @@ export type GetMarginalStatsRequest = { condition?: Condition; /** - * Limit on the number of cases to use in calculating conditional prediction stats; if set to zero there will be no limit. - * if null, will be set to k if precision is "similar" or no limit if precision is "exact". default is null + * Limit on the number of cases to use in calculating conditional prediction stats; If set to zero there will be no limit. + * If null, will be set to k if precision is "similar" or no limit if precision is "exact". default is null */ num_cases?: number; @@ -38,3 +40,25 @@ export type GetMarginalStatsRequest = { */ weight_feature?: string; }; + +/** Response of the Trainee method: getMarginalStats. */ +export type GetMarginalStatsResponse = Record< + string, + { + count?: number | null; + entropy?: number | null; + kurtosis?: number | null; + max?: number | null; + mean?: number | null; + mean_absdev?: number | null; + median?: number | null; + min?: number | null; + mode?: any | null; + percentile_25?: number | null; + percentile_75?: number | null; + skew?: number | null; + stddev?: number | null; + uniques?: number | null; + variance?: number | null; + } +>; diff --git a/src/types/schemas/GetMetadata.ts b/src/types/schemas/GetMetadata.ts new file mode 100644 index 0000000..3c93101 --- /dev/null +++ b/src/types/schemas/GetMetadata.ts @@ -0,0 +1,11 @@ +/** + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. + * + * GetMetadata + * + * Get metadata for model + */ + +/** Response of the Trainee method: getMetadata. */ +export type GetMetadataResponse = Record | null; diff --git a/src/types/schemas/GetNumTrainingCases.ts b/src/types/schemas/GetNumTrainingCases.ts new file mode 100644 index 0000000..67329d6 --- /dev/null +++ b/src/types/schemas/GetNumTrainingCases.ts @@ -0,0 +1,16 @@ +/** + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. + * + * GetNumTrainingCases + * + * Returns the total number of training cases for trainee + */ + +/** Response of the Trainee method: getNumTrainingCases. */ +export type GetNumTrainingCasesResponse = { + /** + * The number of trained cases. + */ + count: number; +}; diff --git a/src/types/schemas/GetPairwiseDistances.ts b/src/types/schemas/GetPairwiseDistances.ts index d31d2b0..0d46335 100644 --- a/src/types/schemas/GetPairwiseDistances.ts +++ b/src/types/schemas/GetPairwiseDistances.ts @@ -1,14 +1,16 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * GetPairwiseDistances * * Returns a list of computed distances between respective cases specified in either from_values or from_case_indices to to_values or to_case_indices. - * if one case is specified in any of the lists, all respective distances are computed to/from that one case. + * If one case is specified in any of the lists, all respective distances are computed to/from that one case. */ import type { CaseIndices } from "./CaseIndices"; import type { UseCaseWeights } from "./UseCaseWeights"; +/** Request parameters of the Trainee method: getPairwiseDistances. */ export type GetPairwiseDistancesRequest = { /** * If specified, uses targeted hyperparameters used to predict this action_feature, otherwise uses targetless hyperparameters. @@ -16,7 +18,7 @@ export type GetPairwiseDistancesRequest = { action_feature?: string; /** - * Which features to use when computing pairwise distances. if unspecified uses all features. + * Which features to use when computing pairwise distances. If unspecified uses all features. */ features?: string[]; @@ -28,7 +30,7 @@ export type GetPairwiseDistancesRequest = { from_case_indices?: CaseIndices; /** - * List of cases (lists of values), i.e., a 2d-list of values. either from_values or from_case_indices must be specified, not both. + * List of cases (lists of values), i.e., a 2d-list of values. Either from_values or from_case_indices must be specified, not both. * if specified must be either length of 1 or match length of to_values or to_case_indices. * @default [] */ @@ -42,14 +44,14 @@ export type GetPairwiseDistancesRequest = { to_case_indices?: CaseIndices; /** - * List of cases (lists of values), i.e., a 2d-list of values. either to_values or to_case_indices must be specified, not both. + * List of cases (lists of values), i.e., a 2d-list of values. Either to_values or to_case_indices must be specified, not both. * if specified must be either length of 1 or match length of from_values or from_case_indices. * @default [] */ to_values?: any[][]; /** - * Flag, if set to true will scale influence weights by each case's weight_feature weight. if unspecified, + * Flag, if set to true will scale influence weights by each case's weight_feature weight. If unspecified, * case weights will be used if the trainee has them. */ use_case_weights?: UseCaseWeights; diff --git a/src/types/schemas/GetParams.ts b/src/types/schemas/GetParams.ts index 928a3fc..a916217 100644 --- a/src/types/schemas/GetParams.ts +++ b/src/types/schemas/GetParams.ts @@ -1,12 +1,16 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * GetParams * * Return the full internal parameters map if no parameters are specified. - * if any of the parameters are specified, then gethyperparameters is called, which uses the specified parameters to find the most suitable set of hyperparameters to return + * if any of the parameters are specified, then GetHyperparameters is called, which uses the specified parameters to find the most suitable set of hyperparameters to return */ +import type { HyperparameterMap } from "./HyperparameterMap"; +import type { HyperparameterMapTree } from "./HyperparameterMapTree"; +/** Request parameters of the Trainee method: getParams. */ export type GetParamsRequest = { /** * The target feature of the desired hyperparameters @@ -21,10 +25,34 @@ export type GetParamsRequest = { /** * The method of calculation used to find the desired hyperparameters */ - mode?: "robust" | "full"; + mode?: "full" | "robust"; /** * The weight feature used in the calculation of the desired hyperparameters */ weight_feature?: string; }; + +/** Response of the Trainee method: getParams. */ +export type GetParamsResponse = { + /** + * The scalar rate at which the number of cases to trigger an auto-analysis grows with each iteration + */ + analyze_growth_factor?: number; + /** + * The number of cases at which the auto-analysis is triggered. + */ + analyze_threshold?: number; + /** + * Flag indicating of auto-analysis is enabled. + */ + auto_analyze_enabled?: boolean; + /** + * The map of default hyperparameters + */ + default_hyperparameter_map?: HyperparameterMap; + /** + * The full map of hyperparameters or a specific map of hyperparameters if any parameters were given + */ + hyperparameter_map?: HyperparameterMap | HyperparameterMapTree; +}; diff --git a/src/types/schemas/GetRevision.ts b/src/types/schemas/GetRevision.ts new file mode 100644 index 0000000..108b7e5 --- /dev/null +++ b/src/types/schemas/GetRevision.ts @@ -0,0 +1,13 @@ +/** + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. + * + * GetRevision + * + * Returns the trainee's !revision + */ + +/** Response of the Trainee method: getRevision. */ +export type GetRevisionResponse = { + count: number; +}; diff --git a/src/types/schemas/GetSessionIndices.ts b/src/types/schemas/GetSessionIndices.ts index 664aca4..cabd4a6 100644 --- a/src/types/schemas/GetSessionIndices.ts +++ b/src/types/schemas/GetSessionIndices.ts @@ -1,5 +1,6 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * GetSessionIndices * @@ -7,6 +8,7 @@ * session indices are 0-based index of number of the case for the session used for replays; may change if cases are removed */ +/** Request parameters of the Trainee method: getSessionIndices. */ export type GetSessionIndicesRequest = { /** * Id of session diff --git a/src/types/schemas/GetSessionMetadata.ts b/src/types/schemas/GetSessionMetadata.ts index 989b3c8..aa34966 100644 --- a/src/types/schemas/GetSessionMetadata.ts +++ b/src/types/schemas/GetSessionMetadata.ts @@ -1,14 +1,19 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * GetSessionMetadata * * Returns all the metadata for a specified session */ +/** Request parameters of the Trainee method: getSessionMetadata. */ export type GetSessionMetadataRequest = { /** * Name of session to return metadata for */ session: string; }; + +/** Response of the Trainee method: getSessionMetadata. */ +export type GetSessionMetadataResponse = Record | null; diff --git a/src/types/schemas/GetSessionTrainingIndices.ts b/src/types/schemas/GetSessionTrainingIndices.ts index 5534d5b..e2bce62 100644 --- a/src/types/schemas/GetSessionTrainingIndices.ts +++ b/src/types/schemas/GetSessionTrainingIndices.ts @@ -1,5 +1,6 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * GetSessionTrainingIndices * @@ -7,6 +8,7 @@ * session training indices are 0-based index of the case, ordered by training during the session; is not changed */ +/** Request parameters of the Trainee method: getSessionTrainingIndices. */ export type GetSessionTrainingIndicesRequest = { /** * Id of session diff --git a/src/types/schemas/GetSessions.ts b/src/types/schemas/GetSessions.ts index 00f9284..0b52e4a 100644 --- a/src/types/schemas/GetSessions.ts +++ b/src/types/schemas/GetSessions.ts @@ -1,11 +1,13 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * GetSessions * * Returns a list of all of the training sessions, assoc of id->session, and whatever other attributes specified. */ +/** Request parameters of the Trainee method: getSessions. */ export type GetSessionsRequest = { /** * List of metadata attributes to return from the session @@ -13,3 +15,11 @@ export type GetSessionsRequest = { */ attributes?: string[]; }; + +/** Response of the Trainee method: getSessions. */ +export type GetSessionsResponse = ({ + /** + * The session ID + */ + id: string; +} & Record)[]; diff --git a/src/types/schemas/GetSubstituteFeatureValues.ts b/src/types/schemas/GetSubstituteFeatureValues.ts new file mode 100644 index 0000000..d82eec9 --- /dev/null +++ b/src/types/schemas/GetSubstituteFeatureValues.ts @@ -0,0 +1,11 @@ +/** + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. + * + * GetSubstituteFeatureValues + * + * Returns the substitution map + */ + +/** Response of the Trainee method: getSubstituteFeatureValues. */ +export type GetSubstituteFeatureValuesResponse = Record; diff --git a/src/types/schemas/HyperparameterMap.ts b/src/types/schemas/HyperparameterMap.ts index 159eb2e..4515c71 100644 --- a/src/types/schemas/HyperparameterMap.ts +++ b/src/types/schemas/HyperparameterMap.ts @@ -1,9 +1,11 @@ /** - * WARNING: This file is auto generated, do not modify manually. - * - * HyperparameterMap + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. */ +/** + * HyperparameterMap schema. + */ export type HyperparameterMap = { /** * Flag indicating if all feature's residuals have been cached. @@ -14,17 +16,17 @@ export type HyperparameterMap = { */ derivedAutoAnalyzed?: boolean; /** - * The distance transform. used as an exponent to convert distance to influence before normalization. + * The distance transform. Used as an exponent to convert distance to influence before normalization. Also accepts string value "surprisal_to_prob" as experimental option that converts distances to surprisal. */ - dt: number; + dt: number | "surprisal_to_prob"; /** - * Internal map of features to their deviations. includes null deviations and sparse deviation matrices. + * Internal map of features to their deviations. Includes null deviations and sparse deviation matrices. */ - featureDeviations?: Record; + featureDeviations?: Record | null; /** * Internal map of features to various domain attributes. */ - featureDomainAttributes?: Record; + featureDomainAttributes?: Record | null; /** * Map of ordinal features to their deviations. */ @@ -32,11 +34,11 @@ export type HyperparameterMap = { /** * Map of features to their computed feature residuals. */ - featureResiduals?: Record; + featureResiduals?: Record; /** * Map of features to feature weights used in the distance metric. */ - featureWeights?: Record; + featureWeights?: Record | null; /** * Error computed during the grid search in analysis. */ @@ -48,9 +50,9 @@ export type HyperparameterMap = { /** * Map of features to null uncertainties which describes the distances in the context of missing values. */ - nullUncertainties?: Record; + nullUncertainties?: Record; /** - * The parameter of the lebesgue space. + * The parameter of the Lebesgue space. */ p: number; /** diff --git a/src/types/schemas/HyperparameterMapTree.ts b/src/types/schemas/HyperparameterMapTree.ts new file mode 100644 index 0000000..2e29768 --- /dev/null +++ b/src/types/schemas/HyperparameterMapTree.ts @@ -0,0 +1,10 @@ +/** + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. + */ +import type { HyperparameterMap } from "./HyperparameterMap"; + +/** + * HyperparameterMapTree schema. + */ +export type HyperparameterMapTree = Record>>>; diff --git a/src/types/schemas/Impute.ts b/src/types/schemas/Impute.ts index bbf31cb..43fffa2 100644 --- a/src/types/schemas/Impute.ts +++ b/src/types/schemas/Impute.ts @@ -1,15 +1,17 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * Impute * * Imputes the model, filling in all the (null) feature values */ +/** Request parameters of the Trainee method: impute. */ export type ImputeRequest = { /** * A positive integer, specifying how many rows to fill before recomputing entropy. default is 1 which should return the - * best accuracy since it'll recompute it everytime. higher values should improve performance but may decrease accuracy of results + * best accuracy since it'll recompute it everytime. Higher values should improve performance but may decrease accuracy of results * @default 1 */ batch_size?: number; diff --git a/src/types/schemas/LoadSubtrainee.ts b/src/types/schemas/LoadSubtrainee.ts index c9d80f8..419d55c 100644 --- a/src/types/schemas/LoadSubtrainee.ts +++ b/src/types/schemas/LoadSubtrainee.ts @@ -1,15 +1,17 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * LoadSubtrainee * * Attempts to load a subtrainee with the following optional parameters. - * if a parameter is not specified, it will look to this entity's own label of the same name. - * if the saved instance does not exist the existing trainee will remain unmodified and the function will return null. + * If a parameter is not specified, it will look to this entity's own label of the same name. + * If the saved instance does not exist the existing trainee will remain unmodified and the function will return null. * assumes loaded trainee filenames need to be escaped * returns the trainee name if successful, null if not */ +/** Request parameters of the Trainee method: loadSubtrainee. */ export type LoadSubtraineeRequest = { /** * Name to load (without extension) @@ -35,3 +37,11 @@ export type LoadSubtraineeRequest = { */ trainee?: string | string[]; }; + +/** Response of the Trainee method: loadSubtrainee. */ +export type LoadSubtraineeResponse = { + /** + * The name of the resulting trainee that was loaded. + */ + name: string; +}; diff --git a/src/types/schemas/MoveCases.ts b/src/types/schemas/MoveCases.ts index bd3646e..1a5709a 100644 --- a/src/types/schemas/MoveCases.ts +++ b/src/types/schemas/MoveCases.ts @@ -1,5 +1,6 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * MoveCases * @@ -9,6 +10,7 @@ import type { CaseIndices } from "./CaseIndices"; import type { Condition } from "./Condition"; import type { Precision } from "./Precision"; +/** Request parameters of the Trainee method: moveCases. */ export type MoveCasesRequest = { /** * A list of session id and training index tuples that specify which cases are to be moved @@ -16,25 +18,25 @@ export type MoveCasesRequest = { case_indices?: CaseIndices; /** - * Assoc of feature->value(s) (no value = must have feature, one value = must equal exactly the value, two values = inclusive between). ignored if case_indices is specified. + * Assoc of feature->value(s) (no value = must have feature, one value = must equal exactly the value, two values = inclusive between). Ignored if case_indices is specified. * @default {} */ condition?: Condition; /** * Name of feature into which to distribute the removed cases' weights to their neighbors. - * applicable only if not preserving session data. + * Applicable only if not preserving session data. */ distribute_weight_feature?: string; /** - * Limit on the number of cases to move; if set to zero there will be no limit. ignored if case_indices is specified. - * if null, will be set to k if precision is "similar" or no limit if precision is "exact". default is null + * Limit on the number of cases to move; If set to zero there will be no limit. Ignored if case_indices is specified. + * If null, will be set to k if precision is "similar" or no limit if precision is "exact". default is null */ num_cases?: number; /** - * Flag, whether to query for 'exact' matches; if set to 'similar' will move num_cases with the most similar values. ignored if case_indices is specified. + * Flag, whether to query for 'exact' matches; if set to 'similar' will move num_cases with the most similar values. Ignored if case_indices is specified. * @default "exact" */ precision?: Precision; @@ -46,14 +48,14 @@ export type MoveCasesRequest = { preserve_session_data?: boolean; /** - * The session id when this call is being made. used for training the cases into the target_trainee once when not preserving session data. + * The session id when this call is being made. Used for training the cases into the target_trainee once when not preserving session data. * @default "none" */ session?: string; /** - * Id of source trainee from which to move cases. ignored if source_name_path is specified. - * if neither source_name_path nor source_id are specified, moves cases from the trainee itself. + * Id of source trainee from which to move cases. Ignored if source_name_path is specified. + * If neither source_name_path nor source_id are specified, moves cases from the trainee itself. */ source_id?: string; @@ -63,8 +65,8 @@ export type MoveCasesRequest = { source_name_path?: string[]; /** - * Id of target trainee to move cases to. ignored if target_name_path is specified. - * if neither target_name_path nor target_id are specified, moves cases to the trainee itself. + * Id of target trainee to move cases to. Ignored if target_name_path is specified. + * If neither target_name_path nor target_id are specified, moves cases to the trainee itself. */ target_id?: string; @@ -73,3 +75,8 @@ export type MoveCasesRequest = { */ target_name_path?: string[]; }; + +/** Response of the Trainee method: moveCases. */ +export type MoveCasesResponse = { + count: number; +}; diff --git a/src/types/schemas/NewCaseThreshold.ts b/src/types/schemas/NewCaseThreshold.ts index f5dc17e..143deb7 100644 --- a/src/types/schemas/NewCaseThreshold.ts +++ b/src/types/schemas/NewCaseThreshold.ts @@ -1,10 +1,9 @@ /** - * WARNING: This file is auto generated, do not modify manually. - * - * NewCaseThreshold + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. */ /** * The privacy distance criteria for generated new cases. */ -export type NewCaseThreshold = "min" | "max" | "most_similar"; +export type NewCaseThreshold = "max" | "min" | "most_similar"; diff --git a/src/types/schemas/OutlyingFeatureValuesIndex.ts b/src/types/schemas/OutlyingFeatureValuesIndex.ts new file mode 100644 index 0000000..be46aa0 --- /dev/null +++ b/src/types/schemas/OutlyingFeatureValuesIndex.ts @@ -0,0 +1,25 @@ +/** + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. + */ + +/** + * Map of feature name to map indicating the case value and the maximum or minimum value of the feature observed in the most similar cases. + */ +export type OutlyingFeatureValuesIndex = Record< + string, + { + /** + * The case value for the specified feature. + */ + input_case_value?: number; + /** + * The largest value observed for the specified feature among the most similar cases. + */ + local_max?: number; + /** + * The smallest value observed for the specified feature among the most similar cases. + */ + local_min?: number; + } +>; diff --git a/src/types/schemas/Precision.ts b/src/types/schemas/Precision.ts index 6eba86c..651c0fc 100644 --- a/src/types/schemas/Precision.ts +++ b/src/types/schemas/Precision.ts @@ -1,7 +1,6 @@ /** - * WARNING: This file is auto generated, do not modify manually. - * - * Precision + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. */ /** diff --git a/src/types/schemas/PredictionStat.ts b/src/types/schemas/PredictionStat.ts index 72e5642..2bc751d 100644 --- a/src/types/schemas/PredictionStat.ts +++ b/src/types/schemas/PredictionStat.ts @@ -1,21 +1,22 @@ /** - * WARNING: This file is auto generated, do not modify manually. - * - * PredictionStat + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. */ /** * Types of prediction statistics. */ export type PredictionStat = - | "mae" + | "accuracy" + | "adjusted_smape" + | "all" | "confusion_matrix" - | "r2" - | "rmse" - | "spearman_coeff" + | "mae" + | "mcc" + | "missing_value_accuracy" | "precision" + | "r2" | "recall" - | "accuracy" - | "mcc" - | "all" - | "missing_value_accuracy"; + | "rmse" + | "smape" + | "spearman_coeff"; diff --git a/src/types/schemas/React.ts b/src/types/schemas/React.ts index 8feb249..a40c4ea 100644 --- a/src/types/schemas/React.ts +++ b/src/types/schemas/React.ts @@ -1,17 +1,30 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * React * * Run reacts in a batch, output a an assoc of list of outputs from each individual react. */ import type { CaseIndices } from "./CaseIndices"; +import type { CaseMDA } from "./CaseMDA"; +import type { Cases } from "./Cases"; +import type { CategoricalActionProbabilities } from "./CategoricalActionProbabilities"; import type { DesiredConviction } from "./DesiredConviction"; -import type { FeatureBoundsMap } from "./FeatureBoundsMap"; +import type { DistanceRatioParts } from "./DistanceRatioParts"; +import type { FeatureBounds } from "./FeatureBounds"; +import type { FeatureMetricIndex } from "./FeatureMetricIndex"; +import type { FullCaseContribution } from "./FullCaseContribution"; import type { GenerateNewCases } from "./GenerateNewCases"; +import type { NewCaseThreshold } from "./NewCaseThreshold"; +import type { OutlyingFeatureValuesIndex } from "./OutlyingFeatureValuesIndex"; import type { ReactDetails } from "./ReactDetails"; +import type { ReactionPredictionStats } from "./ReactionPredictionStats"; +import type { RobustCaseContribution } from "./RobustCaseContribution"; +import type { SimilarCaseIndex } from "./SimilarCaseIndex"; import type { UseCaseWeights } from "./UseCaseWeights"; +/** Request parameters of the Trainee method: react. */ export type ReactRequest = { /** * Full list of features to output values for the case @@ -20,13 +33,13 @@ export type ReactRequest = { action_features?: string[]; /** - * ;values of action features. if specified will bypass react and only do the explanation if details is set. - * if specified must be either length of 1 or num_reacts. one list us used per individual reaction + * ;values of action features. If specified will bypass react and only do the explanation if details is set. + * if specified must be either length of 1 or num_reacts. One list us used per individual reaction */ action_values?: any[][]; /** - * Flag, if set to true will allow return of null values if there are nulls in the local model for the action features. applicable + * Flag, if set to true will allow return of null values if there are nulls in the local model for the action features. Applicable * only to discriminative reacts. * @default false */ @@ -34,42 +47,42 @@ export type ReactRequest = { /** * Pair (list) of session id and index, where index is the original 0-based session_training_index of the case as it was - * trained into the session. if this case does not exist, discriminative react outputs null, generative react ignores it. - * if specified must be either length of 1 or num_reacts. + * trained into the session. If this case does not exist, discriminative react outputs null, generative react ignores it. + * If specified must be either length of 1 or num_reacts. */ case_indices?: CaseIndices; /** - * List of context features. for generative react, features used to condition the generated case + * List of context features. For generative react, features used to condition the generated case * @default [] */ context_features?: string[]; /** - * 2d-list of context values. for generative react, values used to condition the generated case - * if specified must be either length of 1 or num_reacts. one list is used per individual reaction + * 2d-list of context values. For generative react, values used to condition the generated case + * if specified must be either length of 1 or num_reacts. One list is used per individual reaction */ context_values?: any[][]; /** * List of action features whose values should be computed from the resulting action prior to output, in the specified - * order. must be a subset of action_features. - * note: both of these derived feature lists rely on the features' "derived_feature_code" attribute to compute the values. - * if 'derived_feature_code' attribute is undefined or references non-0 feature indices, the derived value will be null. + * order. Must be a subset of action_features. + * Note: both of these derived feature lists rely on the features' "derived_feature_code" attribute to compute the values. + * If 'derived_feature_code' attribute is undefined or references non-0 feature indices, the derived value will be null. * @default [] */ derived_action_features?: string[]; /** * List of context features whose values should be computed from the provided contexts in the specified order. - * must be different than context_features. + * Must be different than context_features. * @default [] */ derived_context_features?: string[]; /** - * If null, will do a discriminative react. if specified, will do a generative react - * for generative react, value of desired avg conviction of generated cases, in the range of (0,infinity] with 1 as standard + * If null, will do a discriminative react. If specified, will do a generative react + * For Generative React, value of desired avg conviction of generated cases, in the range of (0,infinity] with 1 as standard * larger values will increase the variance (or creativity) of the generated case from the existing model * smaller values will decrease the variance (or creativity) of the generated case from the existing model */ @@ -78,182 +91,186 @@ export type ReactRequest = { /** * An assoc of flags for which type of audit data to return, and corresponding values to return (if applicable) in the format of: * (assoc - * "influential_cases" true or false. if true outputs the most influential cases and their influence weights + * "influential_cases" true or false. If true outputs the most influential cases and their influence weights * based on the surprisal of each case relative to the context being predicted among the - * cases. uses only the context features of the reacted case. + * cases. Uses only the context features of the reacted case. * - * "influential_cases_familiarity_convictions" true or false. if true outputs familiarity conviction of + * "influential_cases_familiarity_convictions" true or false. If true outputs familiarity conviction of * addition for each of the influential cases. * - * "influential_cases_raw_weights" true or false. if true outputs the surprisal for each of the influential cases. - * not applicable to generative reacts. + * "influential_cases_raw_weights" true or false. If true outputs the surprisal for each of the influential cases. + * Not applicable to generative reacts. * - * "derivation_parameters" true or false. if true outputs the parameters used during the react. these parameters + * "derivation_parameters" true or false. If true outputs the parameters used during the react. These parameters * include k, p, distance_transform, feature_weights, feature_deviations, nominal_class_counts, and flags to indicate * if deviations or inverse residual weighting were used. * - * "hypothetical_values" assoc context feature -> values. if specified, shows how a prediction could change + * "hypothetical_values" assoc context feature -> values. If specified, shows how a prediction could change * in a what-if scenario where the influential cases' context feature values are replaced with - * the specified values. iterates over all influential cases, predicting the action features - * for each one using the updated hypothetical values. outputs the predicted arithmetic + * the specified values. Iterates over all influential cases, predicting the action features + * for each one using the updated hypothetical values. Outputs the predicted arithmetic * average over the influential cases for each action feature. * - * "most_similar_cases" true or false. if true outputs an automatically determined (when + * "most_similar_cases" true or false. If true outputs an automatically determined (when * 'num_most_similar_cases' is not specified) relevant number of similar cases, which will - * first include the influential cases. uses only the context features of the reacted case. + * first include the influential cases. Uses only the context features of the reacted case. * - * "num_most_similar_cases" integer. outputs this manually specified number of most similar cases, which will + * "num_most_similar_cases" integer. Outputs this manually specified number of most similar cases, which will * first include the influential cases. * - * "num_most_similar_case_indices" integer. outputs the specified number of most similar case indices when + * "num_most_similar_case_indices" integer. Outputs the specified number of most similar case indices when * 'distance_ratio' is also set to true. * - * "boundary_cases" true or false. if true outputs an automatically determined (when 'num_boundary_cases' is - * not specified) relevant number of boundary cases. uses both context and action features + * "boundary_cases" true or false. If true outputs an automatically determined (when 'num_boundary_cases' is + * not specified) relevant number of boundary cases. Uses both context and action features * of the reacted case to determine the counterfactual boundary based on action features, * which maximize the dissimilarity of action features while maximizing the similarity of - * context features. if action features aren't specified, uses familarity conviction to + * context features. If action features aren't specified, uses familarity conviction to * determine the boundary instead. * - * "num_boundary_cases" integer. outputs this manually specified number of boundary cases. + * "num_boundary_cases" integer. Outputs this manually specified number of boundary cases. * - * 'boundary_cases_familiarity_convictions" true or false. if true outputs familiarity conviction of addition for + * 'boundary_cases_familiarity_convictions" true or false. If true outputs familiarity conviction of addition for * each of the boundary cases when 'boundary_cases' is also set to true. * - * "distance_ratio" true or false. if true outputs the ratio of distance (relative surprisal) between this + * "distance_ratio" true or false. If true outputs the ratio of distance (relative surprisal) between this * reacted case and its nearest case to the minimum distance (relative surprisal) in between - * the closest two cases in the local area. all distances are computed using only the + * the closest two cases in the local area. All distances are computed using only the * specified context features. * - * "distance_contribution" true of false. if true outputs the distance contribution (expected total surprisal - * contribution) for the reacted case. uses both context and action feature values. + * "distance_contribution" true of false. If true outputs the distance contribution (expected total surprisal + * contribution) for the reacted case. Uses both context and action feature values. * - * "similarity_conviction" true or false. if true outputs similarity conviction for the reacted case. - * uses both context and action feature values as the case values for all computations. this is + * "similarity_conviction" true or false. If true outputs similarity conviction for the reacted case. + * Uses both context and action feature values as the case values for all computations. This is * defined as expected (weighted-local) distance contribution / reacted case distance contribution. * - * "outlying_feature_values" true or false. if true outputs the reacted case's context feature values that are + * "outlying_feature_values" true or false. If true outputs the reacted case's context feature values that are * outside the min or max of the corresponding feature values of all the cases in the local - * model area. uses only the context features of the reacted case to determine that area. + * model area. Uses only the context features of the reacted case to determine that area. * - * "categorical_action_probabilities" true or false. if true outputs probabilities for each class for the action - * features. applicable only to categorical action features. single_react_series calls additionally - * output "aggregate_categorical_action_probabilities" for each series. + * "categorical_action_probabilities" true or false. If true outputs probabilities for each class for the action + * features. Applicable only to categorical action features. single_react_series calls additionally + * output "aggregated_categorical_action_probabilities" for each series. * - * "observational_errors" true or false. if true outputs observational errors for all features as defined + * "observational_errors" true or false. If true outputs observational errors for all features as defined * in feature attributes. * - * "feature_residuals_robust" true or false. if true outputs feature residuals for all (context and action) features - * locally around the prediction. uses only the context features of the reacted case to - * determine that area. uses robust calculations, which uses uniform sampling from + * "feature_residuals_robust" true or false. If true outputs feature residuals for all (context and action) features + * locally around the prediction. Uses only the context features of the reacted case to + * determine that area. Uses robust calculations, which uses uniform sampling from * the power set of features as the contexts for predictions. * - * "feature_residuals_full" true or false. if true outputs feature residuals for all (context and action) features - * locally around the prediction. uses only the context features of the reacted case to - * determine that area. uses full calculations, which uses leave-one-out context features for computations. + * "feature_residuals_full" true or false. If true outputs feature residuals for all (context and action) features + * locally around the prediction. Uses only the context features of the reacted case to + * determine that area. Uses full calculations, which uses leave-one-out context features for computations. * - * "prediction_stats" true or false. if true outputs full feature prediction stats for all (context and action) - * features locally around the prediction. the stats eligible to be returned are ("r2", "rmse", "spearman_coeff", - * "precision", "recall", "accuracy", "mcc", "confusion_matrix", "missing_value_accuracy"). confusion matrices - * may also be returned by setting 'confusion_matrices' to true. uses only the context features of the - * reacted case to determine that area. uses full calculations, which uses leave-one-out context features for - * computations. + * "prediction_stats" true or false. If true outputs full feature prediction stats for all (context and action) + * features locally around the prediction. The stats eligible to be returned are ("adjusted_smape", "smape", + * "r2", "rmse", "spearman_coeff", "precision", "recall", "accuracy", "mcc", "confusion_matrix", + * "missing_value_accuracy"). Confusion matrices may also be returned by setting 'confusion_matrices' to true. + * Uses only the context features of the reacted case to determine that area. Uses full calculations, which + * uses leave-one-out context features for computations. * - * "feature_mda_robust" true or false. if true outputs each context feature's robust mean decrease in accuracy of predicting - * the action feature given the context. uses only the context features of the reacted - * case to determine that area. uses robust calculations, which uses uniform sampling from + * "selected_prediction_stats" list of strings. Types of stats to output. When unspecified, returns all except the confusion_matrix. + * If "all", then returns all including the confusion_matrix. Valid values are: "mae" "confusion_matrix" "r2" "rmse" + * "adjusted_smape" "smape" "spearman_coeff" "precision" "recall" "accuracy" "mcc" "all" "missing_value_accuracy" + * + * "feature_mda_robust" true or false. If true outputs each context feature's robust mean decrease in accuracy of predicting + * the action feature given the context. Uses only the context features of the reacted + * case to determine that area. Uses robust calculations, which uses uniform sampling from * the power set of features as the contexts for predictions. * - * "feature_mda_full" true or false. if true outputs each context feature's full mean decrease in accuracy of predicting - * the action feature given the context. uses only the context features of the reacted - * case to determine that area. uses full calculations, which uses leave-one-out context features for computations. + * "feature_mda_full" true or false. If true outputs each context feature's full mean decrease in accuracy of predicting + * the action feature given the context. Uses only the context features of the reacted + * case to determine that area. Uses full calculations, which uses leave-one-out context features for computations. * - * "feature_mda_ex_post_robust" true or false. if true outputs each context feature's mean decrease in accuracy of + * "feature_mda_ex_post_robust" true or false. If true outputs each context feature's mean decrease in accuracy of * predicting the action feature as a detail given that the specified prediction was - * already made as specified by the action value. uses both context and action features of - * the reacted case to determine that area. uses robust calculations, which uses uniform sampling from + * already made as specified by the action value. Uses both context and action features of + * the reacted case to determine that area. Uses robust calculations, which uses uniform sampling from * the power set of features as the contexts for predictions. * - * "feature_mda_ex_post_full" true or false. if true outputs each context feature's mean decrease in accuracy of + * "feature_mda_ex_post_full" true or false. If true outputs each context feature's mean decrease in accuracy of * predicting the action feature as a detail given that the specified prediction was - * already made as specified by the action value. uses both context and action features of - * the reacted case to determine that area. uses full calculations, which uses leave-one-out for features for computations. + * already made as specified by the action value. Uses both context and action features of + * the reacted case to determine that area. Uses full calculations, which uses leave-one-out for features for computations. * - * "feature_contributions_robust" true or false. if true outputs each context feature's differences between the + * "feature_contributions_robust" true or false. If true outputs each context feature's differences between the * predicted action feature value and the predicted action feature value if each context - * feature were not in the model for all context features in the local model area. outputs + * feature were not in the model for all context features in the local model area. Outputs * both 'feature_contributions' and non-absolute 'directional_feature_contributions'. - * uses robust calculations, which uses uniform sampling from the power set of features as + * Uses robust calculations, which uses uniform sampling from the power set of features as * the contexts for predictions. * - * "feature_contributions_full" true or false. if true outputs each context feature's differences between the + * "feature_contributions_full" true or false. If true outputs each context feature's differences between the * predicted action feature value and the predicted action feature value if each context - * feature were not in the model for all context features in the local model area. outputs + * feature were not in the model for all context features in the local model area. Outputs * both 'feature_contributions' and non-absolute 'directional_feature_contributions'. - * uses full calculations, which uses leave-one-out context features for computations. + * Uses full calculations, which uses leave-one-out context features for computations. * - * "case_mda_robust" true or false. if true outputs each influential case's mean decrease in accuracy of predicting + * "case_mda_robust" true or false. If true outputs each influential case's mean decrease in accuracy of predicting * the action feature in the local model area, as if each individual case were included - * versus not included. uses only the context features of the reacted case to determine - * that area. uses robust calculations, which uses uniform sampling from the power set of all combinations of cases. + * versus not included. Uses only the context features of the reacted case to determine + * that area. Uses robust calculations, which uses uniform sampling from the power set of all combinations of cases. * - * "case_mda_full" true or false. if true outputs each influential case's mean decrease in accuracy of predicting + * "case_mda_full" true or false. If true outputs each influential case's mean decrease in accuracy of predicting * the action feature in the local model area, as if each individual case were included - * versus not included. uses only the context features of the reacted case to determine - * that area. uses full calculations, which uses leave-one-out for cases for computations. + * versus not included. Uses only the context features of the reacted case to determine + * that area. Uses full calculations, which uses leave-one-out for cases for computations. * - * "case_contributions_robust" true or false. if true outputs each influential case's differences between the + * "case_contributions_robust" true or false. If true outputs each influential case's differences between the * predicted action feature value and the predicted action feature value if each - * individual case were not included. uses only the context features of the reacted case - * to determine that area. uses robust calculations, which uses uniform sampling from the power set of all + * individual case were not included. Uses only the context features of the reacted case + * to determine that area. Uses robust calculations, which uses uniform sampling from the power set of all * combinations of cases. * - * "case_contributions_full" true or false. if true outputs each influential case's differences between the + * "case_contributions_full" true or false. If true outputs each influential case's differences between the * predicted action feature value and the predicted action feature value if each - * individual case were not included. uses only the context features of the reacted case - * to determine that area. uses full calculations, which uses leave-one-out for cases for computations. + * individual case were not included. Uses only the context features of the reacted case + * to determine that area. Uses full calculations, which uses leave-one-out for cases for computations. * - * "case_feature_residuals_robust" true or false. if true outputs feature residuals for all (context and action) - * features for just the specified case. uses leave-one-out for each feature, while + * "case_feature_residuals_robust" true or false. If true outputs feature residuals for all (context and action) + * features for just the specified case. Uses leave-one-out for each feature, while * using the others to predict the left out feature with their corresponding values - * from this case. uses robust calculations, which uses uniform sampling from + * from this case. Uses robust calculations, which uses uniform sampling from * the power set of features as the contexts for predictions. * - * "case_feature_residuals_full" true or false. if true outputs feature residuals for all (context and action) - * features for just the specified case. uses leave-one-out for each feature, while + * "case_feature_residuals_full" true or false. If true outputs feature residuals for all (context and action) + * features for just the specified case. Uses leave-one-out for each feature, while * using the others to predict the left out feature with their corresponding values - * from this case. uses full calculations, which uses leave-one-out context features for computations. + * from this case. Uses full calculations, which uses leave-one-out context features for computations. * - * "case_feature_contributions_robust" true or false. if true outputs each context feature's differences between the + * "case_feature_contributions_robust" true or false. If true outputs each context feature's differences between the * predicted action feature value and the predicted action feature value if each context * feature were not in the model for all context features in this case, using only the - * values from this specific case. uses robust calculations, which uses uniform sampling from + * values from this specific case. Uses robust calculations, which uses uniform sampling from * the power set of features as the contexts for predictions. * - * "case_feature_contributions_full" true or false. if true outputs each context feature's differences between the + * "case_feature_contributions_full" true or false. If true outputs each context feature's differences between the * predicted action feature value and the predicted action feature value if each context * feature were not in the model for all context features in this case, using only the - * values from this specific case. uses full calculations, which uses leave-one-out context features for computations. + * values from this specific case. Uses full calculations, which uses leave-one-out context features for computations. * - * "num_robust_influence_samples_per_case" integer. specifies the number of robust samples to use for each case. - * applicable only for computing robust feature contributions or robust case feature contributions. - * when unspecified, defaults to 2000. higher values will take longer but provide more stable results. + * "num_robust_influence_samples_per_case" integer. Specifies the number of robust samples to use for each case. + * Applicable only for computing robust feature contributions or robust case feature contributions. + * When unspecified, defaults to 2000. Higher values will take longer but provide more stable results. * - * "case_feature_residual_convictions_robust" true or false. if true outputs this case's robust feature residual - * convictions for the region around the prediction. uses only the context features of - * the reacted case to determine that region. computed as: region feature residual / case feature residual. - * uses robust calculations, which uses uniform sampling from the power set of features as the contexts for predictions. + * "case_feature_residual_convictions_robust" true or false. If true outputs this case's robust feature residual + * convictions for the region around the prediction. Uses only the context features of + * the reacted case to determine that region. Computed as: region feature residual / case feature residual. + * Uses robust calculations, which uses uniform sampling from the power set of features as the contexts for predictions. * - * "case_feature_residual_convictions_full" true or false. if true outputs this case's full feature residual - * convictions for the region around the prediction. uses only the context features of - * the reacted case to determine that region. computed as: region feature residual / case feature residual. - * uses full calculations, which uses leave-one-out context features for computations. + * "case_feature_residual_convictions_full" true or false. If true outputs this case's full feature residual + * convictions for the region around the prediction. Uses only the context features of + * the reacted case to determine that region. Computed as: region feature residual / case feature residual. + * Uses full calculations, which uses leave-one-out context features for computations. * * "features" list of features that specifies what features to calculate per-feature details for. (contributions, mda, residuals, etc) - * when robust computations are false. this should generally preserve compute, but will not when computing details robustly. + * when robust computations are False. This should generally preserve compute, but will not when computing details robustly. * - * "generate_attempts" true or false. if true, outputs the total number of attempts to generate the unique case. only applicable for generative - * reacts. when used with reactseries, "series_generate_attempts" is also returned. + * "generate_attempts" true or false. If true, outputs the total number of attempts to generate the unique case. Only applicable for generative + * reacts. When used with ReactSeries, "series_generate_attempts" is also returned. * ) */ details?: ReactDetails; @@ -261,7 +278,7 @@ export type ReactRequest = { /** * If true will exclude sensitive features whose values will be * replaced after synthesis from uniqueness check. - * only applicable when desired_conviction is specified. + * Only applicable when desired_conviction is specified. * @default false */ exclude_novel_nominals_from_uniqueness_check?: boolean; @@ -277,10 +294,10 @@ export type ReactRequest = { * to ensure that specified features' generated values stay in bounds * for nominal features instead of min/max it's a set of allowed values, ie: * allow_null - default is true, if true nulls may be generated per their distribution in the data - * only used when desired_conviction is specified + * Only used when desired_conviction is specified * @default {} */ - feature_bounds_map?: Record; + feature_bounds_map?: Record; /** * Enum, acceptable values are: @@ -308,7 +325,7 @@ export type ReactRequest = { leave_case_out?: boolean; /** - * Distance to determine privacy cutoff. used to query the local minimum distance used in the distance ratio + * Distance to determine privacy cutoff. Used to query the local minimum distance used in the distance ratio * accepted values: * 'max': the maximum local distance * 'min': the minimum local distance @@ -316,7 +333,7 @@ export type ReactRequest = { * null: the minimum local distance * @default "min" */ - new_case_threshold?: "min" | "max" | "most_similar"; + new_case_threshold?: NewCaseThreshold; /** * Total number of cases to generate for generative reacts. @@ -337,13 +354,13 @@ export type ReactRequest = { /** * 2d-list of values corresponding to post_process_features that will be made available during the execution of post_process feature attributes. - * if specified must be either length of 1 or num_reacts. one list is used per individual reaction. + * if specified must be either length of 1 or num_reacts. One list is used per individual reaction. */ post_process_values?: any[][]; /** * List of features that will preserve their values from the case specified by case_indices, appending and - * overwriting the specified context and context features as necessary. for generative reacts, if case_indices isn't specified, + * overwriting the specified context and context features as necessary. For generative reacts, if case_indices isn't specified, * will preserve feature values of a random case. * @default [] */ @@ -355,20 +372,20 @@ export type ReactRequest = { rand_seed?: any[]; /** - * Flag, default is true, only applicable if a substitution value map has been set. if set to false, will not substitute categorical feature values. - * only used when desired_conviction is specified + * Flag, default is true, only applicable if a substitution value map has been set. If set to false, will not substitute categorical feature values. + * Only used when desired_conviction is specified * @default true */ substitute_output?: boolean; /** * Flag, if set to true will scale influence weights by each case's weight_feature weight. - * if a weight is missing, uses 1 as the weight. if unspecified, case weights will be used if the trainee has them. + * If a weight is missing, uses 1 as the weight. If unspecified, case weights will be used if the trainee has them. */ use_case_weights?: UseCaseWeights; /** - * Flag, if false uses model feature residuals, if true recalculates regional model residuals. only used when desired_conviction is specified + * Flag, if false uses model feature residuals, if true recalculates regional model residuals. Only used when desired_conviction is specified * @default true */ use_regional_model_residuals?: boolean; @@ -379,3 +396,159 @@ export type ReactRequest = { */ weight_feature?: string; }; + +/** Response of the Trainee method: react. */ +export type ReactResponse = { + /** + * The list of action features in the order the action values are returned. + */ + action_features: string[]; + /** + * A list of lists of predicted values for each case. + */ + action_values: any[][]; + /** + * A list of lists of boundary cases for each given case. + */ + boundary_cases?: Cases[]; + /** + * A list of lists of maps containing the case index and full contribution to the action feature for each influential case of each given case. + */ + case_contributions_full?: FullCaseContribution[][]; + /** + * A list of lists of maps containing the case index and robust contribution to the action feature for each influential case of each given case. + */ + case_contributions_robust?: RobustCaseContribution[][]; + /** + * A list of lists of maps containing the case index and full directional contribution to the action feature each given case. + */ + case_directional_feature_contributions_full?: FeatureMetricIndex[]; + /** + * A list of lists of maps containing the case index and robust directional contribution to the action feature each given case. + */ + case_directional_feature_contributions_robust?: FeatureMetricIndex[]; + /** + * A list of lists of maps containing the case index and full contribution to the action feature each given case. + */ + case_feature_contributions_full?: FeatureMetricIndex[]; + /** + * A list of lists of maps containing the case index and robust contribution to the action feature each given case. + */ + case_feature_contributions_robust?: FeatureMetricIndex[]; + /** + * A list of maps from feature name to the full prediction residual for each given case. + */ + case_feature_residuals_full?: FeatureMetricIndex[]; + /** + * A list of maps from feature name to the robust prediction residual for each given case. + */ + case_feature_residuals_robust?: FeatureMetricIndex[]; + /** + * A list of maps from feature name to feature full residual conviction for each given case. + */ + case_feature_residual_convictions_full?: FeatureMetricIndex[]; + /** + * A list of maps from feature name to feature robust residual conviction for each given case. + */ + case_feature_residual_convictions_robust?: FeatureMetricIndex[]; + /** + * A list of lists of maps containing the case index and full MDA for each influential case of each given case. + */ + case_mda_full?: CaseMDA[][]; + /** + * A list of lists of maps containing the case index and robust MDA for each influential case of each given case. + */ + case_mda_robust?: CaseMDA[][]; + /** + * A list of maps of feature names to their estimated probabilities of each class for the given cases. + */ + categorical_action_probabilities?: Record[]; + /** + * A list of maps defining the local feature robust directional contributions of the action feature for each feature in the query. + */ + directional_feature_contributions_full?: FeatureMetricIndex[]; + /** + * A list of maps defining the local feature robust directional contributions of the action feature for each feature in the query. + */ + directional_feature_contributions_robust?: FeatureMetricIndex[]; + /** + * The computed distance contribution for each given case. + */ + distance_contribution?: number[]; + /** + * The computed distance ratio for each given case. + */ + distance_ratio?: number[]; + /** + * A list of the parts that are used to compute the distance ratio for each case. + */ + distance_ratio_parts?: DistanceRatioParts[]; + /** + * A list of maps defining the local feature full contributions of the action feature for each feature in the query. + */ + feature_contributions_full?: FeatureMetricIndex[]; + /** + * A list of maps defining the local feature robust contributions of the action feature for each feature in the query. + */ + feature_contributions_robust?: FeatureMetricIndex[]; + /** + * A list of maps defining the local feature full MDA of the action feature for each feature in the query given the prediction was already made as the given action value. + */ + feature_mda_ex_post_full?: FeatureMetricIndex[]; + /** + * A list of maps defining the local feature robust MDA of the action feature for each feature in the query given the prediction was already made as the given action value. + */ + feature_mda_ex_post_robust?: FeatureMetricIndex[]; + /** + * A list of maps defining the local feature full MDA of the action feature for each feature in the query. + */ + feature_mda_full?: FeatureMetricIndex[]; + /** + * A list of maps defining the local feature robust MDA of the action feature for each feature in the query. + */ + feature_mda_robust?: FeatureMetricIndex[]; + /** + * A list of maps defining the local feature full residuals for each feature in the query. + */ + feature_residuals_full?: FeatureMetricIndex[]; + /** + * A list of maps defining the local feature robust residuals for each feature in the query. + */ + feature_residuals_robust?: FeatureMetricIndex[]; + /** + * A list of the amount of generation attempts taken for each synthesized case. Only returned if `generate_new_cases` is 'attempt' or 'always'. + */ + generate_attempts?: number[]; + /** + * A list of maps from feature name to feature values indicating how feature values would be predicted if the given hypothetical values were true. + */ + hypothetical_values?: Record[]; + /** + * A list of lists of influential cases for each given case. + */ + influential_cases?: Cases[]; + /** + * A list of lists of the most similar cases to each given case. + */ + most_similar_cases?: Cases[]; + /** + * A list of lists of maps describing the most similar case indices and their distance from each given case. + */ + most_similar_case_indices?: SimilarCaseIndex[][]; + /** + * A list of maps defining the observational errors for each feature defined in the feature attributes. + */ + observational_errors?: FeatureMetricIndex[]; + /** + * A list of maps from feature name to map describing the outlying values and the extreme observed among similar cases. + */ + outlying_feature_values?: OutlyingFeatureValuesIndex[]; + /** + * A list of maps containing the resulting prediction stats for the region of cases nearest to each given case. + */ + prediction_stats?: ReactionPredictionStats[]; + /** + * The computed similarity conviction for each given case. + */ + similarity_conviction?: number[]; +}; diff --git a/src/types/schemas/ReactAggregate.ts b/src/types/schemas/ReactAggregate.ts index 3d0bf53..25708da 100644 --- a/src/types/schemas/ReactAggregate.ts +++ b/src/types/schemas/ReactAggregate.ts @@ -1,17 +1,20 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * ReactAggregate * - * Computes, caches, and returns specified details and feature prediction statistics such as mean decrease in accuracy (mda), residuals (accuracy, mean absolute error), - * precision, recall, etc. returns details and feature prediction stats for all features in the format of feature -> assoc stat -> value + * Computes, caches, and returns specified details and feature prediction statistics such as Mean Decrease in Accuracy (MDA), residuals (accuracy, Mean Absolute Error), + * precision, recall, etc. Returns details and feature prediction stats for all features in the format of feature -> assoc stat -> value */ +import type { ConfusionMatrix } from "./ConfusionMatrix"; import type { ReactAggregateDetails } from "./ReactAggregateDetails"; import type { UseCaseWeights } from "./UseCaseWeights"; +/** Request parameters of the Trainee method: reactAggregate. */ export type ReactAggregateRequest = { /** - * Target feature for which to do computations. if "prediction_stats_action_feature" and "feature_influences_action_feature" + * Target feature for which to do computations. If "prediction_stats_action_feature" and "feature_influences_action_feature" * are not provided, they will default to this value. */ action_feature?: string; @@ -23,8 +26,8 @@ export type ReactAggregateRequest = { action_features?: string[]; /** - * Number, optional, default is 15. applicable only to confusion matrices when computing residuals, the number of predictions - * a class should have (value of a cell in the matrix) for it to remain in the confusion matrix. if the count is less than this value, it will + * Number, optional, default is 15. Applicable only to confusion matrices when computing residuals, the number of predictions + * a class should have (value of a cell in the matrix) for it to remain in the confusion matrix. If the count is less than this value, it will * be accumulated into a single value of all insignificant predictions for the class and removed from the confusion matrix. * @default 15 */ @@ -39,47 +42,50 @@ export type ReactAggregateRequest = { /** * Assoc, optional. an assoc of flags for which type of audit data to return, and corresponding values to return (if applicable) in the format of: * (assoc - * prediction_stats: optional true/false. if true outputs full feature prediction stats for all (context and action) - * features. the prediction stats returned are set by the "selected_prediction_stats" parameter. uses full calculations, which - * uses leave-one-out for features for computations. uses full computation. - * feature_residuals_full: optional, none/true/false. for each context_feature, use the full set of all other context_features to - * predict the feature. when true, computes, caches, and returns the residuals for all features. uses full computation. - * when "prediction_stats" in the "details" parameter is true, it will also compute and cache the feature residuals. - * feature_residuals_robust: optional, none/true/false. for each context_feature, computes, caches, and returns the same stats as residuals but using the robust - * (power set/permutations) set of all other context_features to predict the feature. uses robust computation. - * feature_contributions_full: optional, none/true/false. for each context_feature, use the full set of all other context_features to compute the - * mean absolute delta between prediction of action_feature with and without the context_feature in the model. uses full computation. - * feature_contributions_robust: optional, none/true/false. for each context_feature, use the robust (power set/permutation) set of all other context_features - * to compute the mean absolute delta between prediction of action_feature with and without the context_feature in the model. uses robust computation. - * uses robust computation. - * feature_mda_full: optional, none/true/false. if true will compute mean decrease in accuracy (feature_mda) for each context feature at predicting mda_action_features. - * drop each feature and use the full set of remaining context features for each prediction. uses full computation. - * feature_mda_permutation_full: optional, none/true/false. compute feature_mda_full by scrambling each feature and using the full set of remaining context features - * for each prediction. uses full computation. - * feature_mda_robust: optional, none/true/false. compute feature_mda by dropping each feature and using the robust (power set/permutations) set of - * remaining context features for each prediction. uses robust computation. - * feature_mda_permutation_robust: optional, none/true/false. compute feature_mda by scrambling each feature and using the robust (power set/permutations) - * set of remaining context features for each prediction. uses robust computation. - * selected_prediction_stats": list of strings, optional. allowed values are: - * "mae" : mean absolute error. for continuous features, this is calculated as the mean of absolute values of the difference - * between the actual and predicted values. for nominal features, this is 1 - the average categorical action probability of each case's - * correct classes. categorical action probabilities are the probabilities for each class for the action feature. + * prediction_stats: optional true/false. If true outputs full feature prediction stats for all (context and action) + * features. The prediction stats returned are set by the "selected_prediction_stats" parameter. Uses full calculations, which + * uses leave-one-out for features for computations. Uses full computation. + * feature_residuals_full: optional, none/true/false. For each context_feature, use the full set of all other context_features to + * predict the feature. When true, computes, caches, and returns the residuals for all features. Uses full computation. + * When "prediction_stats" in the "details" parameter is true, it will also compute and cache the feature residuals. + * feature_residuals_robust: optional, none/true/false. For each context_feature, computes, caches, and returns the same stats as residuals but using the robust + * (power set/permutations) set of all other context_features to predict the feature. Uses robust computation. + * feature_contributions_full: optional, none/true/false. For each context_feature, use the full set of all other context_features to compute the + * mean absolute delta between prediction of action_feature with and without the context_feature in the model. Uses full computation. + * feature_contributions_robust: optional, none/true/false. For each context_feature, use the robust (power set/permutation) set of all other context_features + * to compute the mean absolute delta between prediction of action_feature with and without the context_feature in the model. Uses robust computation. + * Uses robust computation. + * feature_mda_full: optional, none/true/false. if true will compute Mean Decrease in Accuracy (feature_mda) for each context feature at predicting mda_action_features. + * Drop each feature and use the full set of remaining context features for each prediction. Uses full computation. + * feature_mda_permutation_full: optional, none/true/false. Compute feature_mda_full by scrambling each feature and using the full set of remaining context features + * for each prediction. Uses full computation. + * feature_mda_robust: optional, none/true/false. Compute feature_mda by dropping each feature and using the robust (power set/permutations) set of + * remaining context features for each prediction. Uses robust computation. + * feature_mda_permutation_robust: optional, none/true/false. Compute feature_mda by scrambling each feature and using the robust (power set/permutations) + * set of remaining context features for each prediction. Uses robust computation. + * selected_prediction_stats": list of strings, optional. Allowed values are: + * "mae" : Mean absolute error. For continuous features, this is calculated as the mean of absolute values of the difference + * between the actual and predicted values. For nominal features, this is 1 - the average categorical action probability of each case's + * correct classes. Categorical action probabilities are the probabilities for each class for the action feature. * "r2": r-squared coefficient of determination, for continuous features only. * "rmse": root mean squared error, for continuous features only. - * "spearman_coeff": spearman's rank correlation coefficient, for continuous features only. - * "precision": precision (positive predictive) value for nominal features only. aggregated by taking the unweighted means of each classes' precisions. - * "recall": recall (sensitivity) value for nominal features only. aggregated by taking the unweighted means of each classes' recalls. - * "accuracy": the number of correct predictions divided by the total number of predictions. - * "confusion_matrix": a matrix showing the number of predicted values of each class - * for each unique value of the predicted feature. outputs the sparse confusion matrix. - * "missing_value_accuracy" : the number of correct predictions on cases with missing values values divided by the total number of cases with missing + * "smape": Symmetric mean absolute percentage error, for continuous features only. + * "adjusted_smape": Symmetric mean absolute percentage error, for continuous features only. Adds the min gap / 2 to the actual and + * predicted values. + * "spearman_coeff": Spearman's rank correlation coefficient, for continuous features only. + * "precision": precision (positive predictive) value for nominal features only. Aggregated by taking the unweighted means of each classes' precisions. + * "recall": recall (sensitivity) value for nominal features only. Aggregated by taking the unweighted means of each classes' recalls. + * "accuracy": The number of correct predictions divided by the total number of predictions. + * "confusion_matrix": A matrix showing the number of predicted values of each class + * for each unique value of the predicted feature. Outputs the sparse confusion matrix. + * "missing_value_accuracy" : The number of correct predictions on cases with missing values values divided by the total number of cases with missing * values for a specified feature. - * "all": all of the available prediction stats including the confusion_matrix - * if empty, will return all of the available prediction stats not including the confusion matrices. - * action_condition: assoc of feature->value(s), optional. if specified, will condition the action set, which is the dataset for which the prediction stats are for. - * if both 'action_condition' and 'context_condition' are provided, then all of the action cases selected by the 'action_condition' + * "all": All of the available prediction stats including the confusion_matrix + * If empty, will return all of the available prediction stats not including the confusion matrices. + * action_condition: assoc of feature->value(s), optional. If specified, will condition the action set, which is the dataset for which the prediction stats are for. + * If both 'action_condition' and 'context_condition' are provided, then all of the action cases selected by the 'action_condition' * will be excluded from the context set, which is the set being queried to make to make predictions on the action set, effectively holding them out. - * if only 'action_condition' is specified, then only the single predicted case will be left out. + * If only 'action_condition' is specified, then only the single predicted case will be left out. * no value = must have feature * - for continuous or numeric ordinal features: * one value = must equal exactly the value or be close to it for fuzzy match @@ -87,72 +93,67 @@ export type ReactAggregateRequest = { * - for nominal or string ordinal features: * n values = must match any of these values exactly * action_condition_precision: optional string, default is 'exact', used only with 'action_condition' parameter, will find exact matches if 'exact' and similar cases if 'similar'. - * action_num_samples: optional, limit on the number of action cases used in calculating conditional prediction stats. works with or without 'action_condition_filter_query'. - * if 'action_condition' is set: - * if null, will be set to k if precision is "similar" or no limit if precision is "exact". default is null - * if 'action_condition' is not set: - * if null, will be set to the howso default limit of 2000. default is null - * context_condition: assoc of feature->value(s), optional. if specified, will condition the context set, which is the set being queried to make to make predictions on the action set. - * if both 'action_condition' and 'context_condition' are provided, then all of the cases from the action set, which is the dataset for which the prediction stats are for, - * will be excluded from the context set, effectively holding them out. if only 'action_condition' is specified, then only the single predicted case will be left out. + * action_num_samples: optional, limit on the number of action cases used in calculating conditional prediction stats. Works with or without 'action_condition_filter_query'. + * If 'action_condition' is set: + * If null, will be set to k if precision is "similar" or no limit if precision is "exact". default is null + * If 'action_condition' is not set: + * If null, will be set to the Howso default limit of 2000. default is null + * context_condition: assoc of feature->value(s), optional. If specified, will condition the context set, which is the set being queried to make to make predictions on the action set. + * If both 'action_condition' and 'context_condition' are provided, then all of the cases from the action set, which is the dataset for which the prediction stats are for, + * will be excluded from the context set, effectively holding them out. If only 'action_condition' is specified, then only the single predicted case will be left out. * no value = must have feature * - for continuous or numeric ordinal features: * one value = must equal exactly the value or be close to it for fuzzy match * two values = inclusive between * - for nominal or string ordinal features: * n values = must match any of these values exactly - * context_condition_precision: optional string, default is 'exact'. used only with 'context_condition' parameter, will find exact matches if 'exact' and similar cases if 'similar'. + * context_condition_precision: optional string, default is 'exact'. Used only with 'context_condition' parameter, will find exact matches if 'exact' and similar cases if 'similar'. * context_num_samples: optional, limit on the number of context cases when 'context_condition_precision' is set to 'similar'. - * if null, will be set to k. default is null - * prediction_stats_features: list of string, optional. list of features to use when calculating conditional prediction stats. should contain all action and context features desired. if - * 'action_feature' is also provided, that feature will automatically be appended to this list if it is not already in the list - * "feature_residuals_robust" true or false. if true outputs feature residuals for all (context and action) features - * locally around the prediction. uses only the context features of the reacted case to - * determine that area. + * If null, will be set to k. default is null * ) */ details?: ReactAggregateDetails; /** * When feature influences such as contributions and mda, use this feature as the action feature. - * if not provided, will default to the "action_feature" if provided. + * If not provided, will default to the "action_feature" if provided. */ feature_influences_action_feature?: string; /** * Full path for hyperparameters to use for computation. - * if specified for any residual computations, takes precendence over action_feature parameter. + * If specified for any residual computations, takes precendence over action_feature parameter. */ hyperparameter_param_path?: string[]; /** * Total sample size of model to use (using sampling with replacement) for robust contribution computation. - * defaults to 300. + * Defaults to 300. */ num_robust_influence_samples?: number; /** * Specifies the number of robust samples to use for each case for robust contribution computations. - * defaults to 300 + 2 * (number of features). + * Defaults to 300 + 2 * (number of features). */ num_robust_influence_samples_per_case?: number; /** * Total sample size of model to use (using sampling with replacement) for robust feature_mda and residual computation. - * defaults to 1000 * (1 + log(number of features)). note: robust feature_mda will be updated to use num_robust_influence_samples in a future release. + * Defaults to 1000 * (1 + log(number of features)). Note: robust feature_mda will be updated to use num_robust_influence_samples in a future release. */ num_robust_residual_samples?: number; /** * Total sample size of model to use (using sampling with replacement) for all non-robust computation. - * defaults to 1000. if specified overrides sample_model_fraction. + * Defaults to 1000. If specified overrides sample_model_fraction. */ num_samples?: number; /** - * When calculating residuals and prediction stats, uses this target features's hyperparameters. the trainee must - * have been analyzed with this feature as the action feature first. if both "prediction_stats_action_feature" and "action_feature" are not provided, - * by default residuals and prediction stats uses ".targetless" hyperparameters. if "action_feature" is provided, and this value is not provided, will + * When calculating residuals and prediction stats, uses this target features's hyperparameters. The trainee must + * have been analyzed with this feature as the action feature first. If both "prediction_stats_action_feature" and "action_feature" are not provided, + * by default residuals and prediction stats uses ".targetless" hyperparameters. If "action_feature" is provided, and this value is not provided, will * default to the value of "action_feature". */ prediction_stats_action_feature?: string; @@ -165,27 +166,119 @@ export type ReactAggregateRequest = { /** * Value 0.0 - 1.0, percent of model to use in sampling (using sampling without replacement). - * applicable only to non-robust computation. ignored if num_samples is specified. + * Applicable only to non-robust computation. Ignored if num_samples is specified. */ sample_model_fraction?: number; /** * If specified will calculate only on a sub model of the specified size from the full model. - * applicable only to models > 1000 cases. + * Applicable only to models > 1000 cases. */ sub_model_size?: number; /** - * Flag, if set to true will scale influence weights by each case's weight_feature weight. if unspecified, + * Flag, if set to true will scale influence weights by each case's weight_feature weight. If unspecified, * case weights will be used if the trainee has them. */ use_case_weights?: UseCaseWeights; /** * Name of feature whose values to use as case weights - * "generate_attempts" true or false. if true, outputs the total number of attempts to generate the unique case. only applicable for generative - * reacts where generate_new_cases is "always" or "attempt". when used with reactseries, "series_generate_attempts" is also returned. + * "generate_attempts" true or false. If true, outputs the total number of attempts to generate the unique case. Only applicable for generative + * reacts where generate_new_cases is "always" or "attempt". When used with ReactSeries, "series_generate_attempts" is also returned. * @default ".case_weight" */ weight_feature?: string; }; + +/** Response of the Trainee method: reactAggregate. */ +export type ReactAggregateResponse = Record< + string, + { + /** + * The accuracy of predicting the feature. + */ + accuracy?: number | null; + /** + * The symmetric mean absolute percentage error with added the min gap / 2 to the actual and predicted values. + */ + adjusted_smape?: number | null; + confusion_matrix?: ConfusionMatrix; + /** + * The mean difference of predicting the specified action feature with and without this feature while using the full set of remaining context features. + */ + directional_feature_contributions_full?: number | null; + /** + * The mean difference of predicting the specified action feature with and without this feature while using samples from the power-set of remaining context features. + */ + directional_feature_contributions_robust?: number | null; + /** + * The mean absolute difference of predicting the specified action feature with and without this feature while using the full set of remaining context features. + */ + feature_contributions_full?: number | null; + /** + * The mean absolute difference of predicting the specified action feature with and without this feature while using samples from the power-set of remaining context features. + */ + feature_contributions_robust?: number | null; + /** + * The mean decrease in accuracy of predicting the specified action feature without this feature versus with this feature while using full set of remaining context features. + */ + feature_mda_full?: number | null; + /** + * The mean decrease in accuracy of predicting the specified action feature using scrambled values for this feature versus non-scrambled values for this feature while using the full set of remaining context features. + */ + feature_mda_permutation_full?: number | null; + /** + * The mean decrease in accuracy of predicting the specified action feature using scrambled values for this feature versus non-scrambled values for this feature while using samples from the power-set of remaining context features. + */ + feature_mda_permutation_robust?: number | null; + /** + * The mean decrease in accuracy of predicting the specified action feature without this feature versus with this feature while using samples from the power-set of remaining context features. + */ + feature_mda_robust?: number | null; + /** + * The mean absolute error of predicting this feature using the full set of context features. + */ + feature_residuals_full?: number | null; + /** + * The mean absolute error of predicting this feature using samples from the power-set of context features. + */ + feature_residuals_robust?: number | null; + /** + * The mean absolute error of predicting the feature. + */ + mae?: number | null; + /** + * The MCC of predicting the feature. + */ + mcc?: number | null; + /** + * The proportion of missing values that were correctly predicted as missing for the feature. + */ + missing_value_accuracy?: number | null; + /** + * The precision of predicting the feature. + */ + precision?: number | null; + /** + * The R^2 of predicting the feature. + */ + r2?: number | null; + /** + * The recall of predicting the feature. + */ + recall?: number | null; + /** + * The RMSE of predicting the feature. + */ + rmse?: number | null; + /** + * The symmetric mean absolute percentage error of predicting the feature. + */ + smape?: number | null; + /** + * The Spearman's coefficient of predicting the feature. + */ + spearman_coeff?: number | null; + } +>; diff --git a/src/types/schemas/ReactAggregateDetails.ts b/src/types/schemas/ReactAggregateDetails.ts index fdc4c38..d46f4ee 100644 --- a/src/types/schemas/ReactAggregateDetails.ts +++ b/src/types/schemas/ReactAggregateDetails.ts @@ -1,15 +1,17 @@ /** - * WARNING: This file is auto generated, do not modify manually. - * - * ReactAggregateDetails + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. */ import type { Condition } from "./Condition"; import type { Precision } from "./Precision"; -import type { SelectedPredictionStats } from "./SelectedPredictionStats"; +import type { PredictionStat } from "./PredictionStat"; +/** + * ReactAggregateDetails schema. + */ export type ReactAggregateDetails = { /** - * If specified, will condition the action set, which is the dataset for which the prediction stats are for. if both 'action_condition' and 'context_condition' are provided, then all of the action cases selected by the 'action_condition' will be excluded from the context set, which is the set being queried to make to make predictions on the action set, effectively holding them out. if only 'action_condition' is specified, then only the single predicted case will be left out. + * If specified, will condition the action set, which is the dataset for which the prediction stats are for. If both 'action_condition' and 'context_condition' are provided, then all of the action cases selected by the 'action_condition' will be excluded from the context set, which is the set being queried to make to make predictions on the action set, effectively holding them out. If only 'action_condition' is specified, then only the single predicted case will be left out. */ action_condition?: Condition; /** @@ -17,65 +19,64 @@ export type ReactAggregateDetails = { */ action_condition_precision?: Precision; /** - * Limit on the number of action cases used in calculating conditional prediction stats. works with or without 'action_condition_filter_query'. - * if 'action_condition' is set: - * if null, will be set to k if precision is "similar" or no limit if precision is "exact". default is null + * Limit on the number of action cases used in calculating conditional prediction stats. Works with or without 'action_condition_filter_query'. + * If 'action_condition' is set: + * If null, will be set to k if precision is "similar" or no limit if precision is "exact". default is null * - * if 'action_condition' is not set: - * if null, will be set to the howso default limit of 2000. default is null + * If 'action_condition' is not set: + * If null, will be set to the Howso default limit of 2000. default is null */ action_num_samples?: number; /** - * If specified, will condition the context set, which is the set being queried to make to make predictions on the action set. if both 'action_condition' and 'context_condition' are provided, then all of the cases from the action set, which is the dataset for which the prediction stats are for, will be excluded from the context set, effectively holding them out. if only 'action_condition' is specified, then only the single predicted case will be left out. + * If specified, will condition the context set, which is the set being queried to make to make predictions on the action set. If both 'action_condition' and 'context_condition' are provided, then all of the cases from the action set, which is the dataset for which the prediction stats are for, will be excluded from the context set, effectively holding them out. If only 'action_condition' is specified, then only the single predicted case will be left out. */ context_condition?: Condition; /** - * Optional, limit on the number of context cases when 'context_condition_precision' is set to 'similar'. if null, will be set to k. default is null. + * Optional, limit on the number of context cases when 'context_condition_precision' is set to 'similar'. If null, will be set to k. default is null. */ context_condition_num_samples?: number; /** - * Default is 'exact'. used only with 'context_condition' parameter, will find exact matches if 'exact' and similar cases if 'similar'. + * Default is 'exact'. Used only with 'context_condition' parameter, will find exact matches if 'exact' and similar cases if 'similar'. */ context_condition_precision?: Precision; /** - * If true will for each context_feature, use the full set of all other context_features to compute the mean absolute delta between prediction of action_feature with and without the context_feature in the model. uses full computation. + * If true will for each context_feature, use the full set of all other context_features to compute the mean absolute delta between prediction of action_feature with and without the context_feature in the model. Uses full computation. */ feature_contributions_full?: boolean; /** - * For each context_feature, use the robust (power set/permutation) set of all other context_features to compute the mean absolute delta between prediction of action_feature with and without the context_feature in the model. uses robust computation. uses robust computation. + * For each context_feature, use the robust (power set/permutation) set of all other context_features to compute the mean absolute delta between prediction of action_feature with and without the context_feature in the model. Uses robust computation. Uses robust computation. */ feature_contributions_robust?: boolean; /** - * If true will compute mean decrease in accuracy (feature_mda) for each context feature at predicting mda_action_features. drop each feature and use the full set of remaining context features for each prediction. false removes cached values. uses full computation. + * If true will compute Mean Decrease in Accuracy (feature_mda) for each context feature at predicting mda_action_features. Drop each feature and use the full set of remaining context features for each prediction. false removes cached values. Uses full computation. */ feature_mda_full?: boolean; /** - * If true will compute feature_mda_full by scrambling each feature and using the full set of remaining context features for each prediction. false removes cached values. uses full computation. + * If true will compute feature_mda_full by scrambling each feature and using the full set of remaining context features for each prediction. false removes cached values. Uses full computation. */ feature_mda_permutation_full?: boolean; /** - * If true will compute feature_mda by scrambling each feature and using the robust (power set/permutations) set of remaining context features for each prediction. false removes cached values. uses robust computation. + * If true will compute feature_mda by scrambling each feature and using the robust (power set/permutations) set of remaining context features for each prediction. false removes cached values. Uses robust computation. */ feature_mda_permutation_robust?: boolean; /** - * If true will compute feature_mda by dropping each feature and using the robust (power set/permutations) set of remaining context features for each prediction. false removes cached values. uses robust computation. + * If true will compute feature_mda by dropping each feature and using the robust (power set/permutations) set of remaining context features for each prediction. false removes cached values. Uses robust computation. */ feature_mda_robust?: boolean; /** - * If true, will for each context_feature, use the full set of all other context_features to predict the feature. when true, computes, caches, and returns the residuals for all features. uses full computation. when "prediction_stats" in the "details" parameter is true, it will also compute and cache the feature residuals. + * If true, will for each context_feature, use the full set of all other context_features to predict the feature. When true, computes, caches, and returns the residuals for all features. Uses full computation. When "prediction_stats" in the "details" parameter is true, it will also compute and cache the feature residuals. */ feature_residuals_full?: boolean; /** - * If true, will for each context_feature, computes, caches, and returns the same stats as residuals but using the robust (power set/permutations) set of all other context_features to predict the feature. uses robust computation. + * If true, will for each context_feature, computes, caches, and returns the same stats as residuals but using the robust (power set/permutations) set of all other context_features to predict the feature. Uses robust computation. */ feature_residuals_robust?: boolean; /** - * If true outputs full feature prediction stats for all (context and action) features. the prediction stats returned are set by the `"selected_prediction_stats`" parameter. uses full calculations, which uses leave-one-out for features for computations. uses full computation. + * If true outputs full feature prediction stats for all (context and action) features. The prediction stats returned are set by the `"selected_prediction_stats`" parameter. Uses full calculations, which uses leave-one-out for features for computations. Uses full computation. */ prediction_stats?: boolean; /** - * List of features to use when calculating conditional prediction stats. should contain all action and context features desired. if 'action_feature' is also provided, that feature will automatically be appended to this list if it is not already in the list + * Types of stats to output. When unspecified, returns all except the confusion_matrix. If all, then returns all including the confusion_matrix. */ - prediction_stats_features?: string[]; - selected_prediction_stats?: SelectedPredictionStats; + selected_prediction_stats?: PredictionStat[]; }; diff --git a/src/types/schemas/ReactDetails.ts b/src/types/schemas/ReactDetails.ts index a9e749a..9ac3255 100644 --- a/src/types/schemas/ReactDetails.ts +++ b/src/types/schemas/ReactDetails.ts @@ -1,13 +1,15 @@ /** - * WARNING: This file is auto generated, do not modify manually. - * - * ReactDetails + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. */ -import type { SelectedPredictionStats } from "./SelectedPredictionStats"; +import type { PredictionStat } from "./PredictionStat"; +/** + * ReactDetails schema. + */ export type ReactDetails = { /** - * When true, outputs an automatically determined (when 'num_boundary_cases' is not specified) relevant number of boundary cases. uses both context and action features of the reacted case to determine the counterfactual boundary based on action features, which maximize the dissimilarity of action features while maximizing the similarity of context features. if action features aren't specified, uses familiarity conviction to determine the boundary instead. + * When true, outputs an automatically determined (when 'num_boundary_cases' is not specified) relevant number of boundary cases. Uses both context and action features of the reacted case to determine the counterfactual boundary based on action features, which maximize the dissimilarity of action features while maximizing the similarity of context features. If action features aren't specified, uses familiarity conviction to determine the boundary instead. */ boundary_cases?: boolean; /** @@ -15,107 +17,107 @@ export type ReactDetails = { */ boundary_cases_familiarity_convictions?: boolean; /** - * If true outputs each influential case's differences between the + * If true outputs each influential case's differences between the predicted action feature value and the predicted action feature value if each individual case were not included. Uses only the context features of the reacted case to determine that area. Uses full calculations, which uses leave-one-out for cases for computations. */ case_contributions_full?: boolean; /** - * If true outputs each influential case's differences between the predicted action feature value and the predicted action feature value if each individual case were not included. uses only the context features of the reacted case to determine that area. uses robust calculations, which uses uniform sampling from the power set of all combinations of cases. + * If true outputs each influential case's differences between the predicted action feature value and the predicted action feature value if each individual case were not included. Uses only the context features of the reacted case to determine that area. Uses robust calculations, which uses uniform sampling from the power set of all combinations of cases. */ case_contributions_robust?: boolean; /** - * If true outputs each context feature's absolute and directional differences between the predicted action feature value and the predicted action feature value if each context feature were not in the model for all context features in this case, using only the values from this specific case. uses full calculations, which uses leave-one-out for cases for computations. directional case feature contributions are returned under the 'case_directional_feature_contributions_full' key. + * If True outputs each context feature's absolute and directional differences between the predicted action feature value and the predicted action feature value if each context feature were not in the model for all context features in this case, using only the values from this specific case. Uses full calculations, which uses leave-one-out for cases for computations. Directional case feature contributions are returned under the 'case_directional_feature_contributions_full' key. */ case_feature_contributions_full?: boolean; /** - * If true outputs each context feature's absolute and directional differences between the predicted action feature value and the predicted action feature value if each context feature were not in the model for all context features in this case, using only the values from this specific case. uses robust calculations, which uses uniform sampling from the power set of features as the contexts for predictions. directional case feature contributions are returned under the 'case_directional_feature_contributions_robust' key. + * If True outputs each context feature's absolute and directional differences between the predicted action feature value and the predicted action feature value if each context feature were not in the model for all context features in this case, using only the values from this specific case. Uses robust calculations, which uses uniform sampling from the power set of features as the contexts for predictions. Directional case feature contributions are returned under the 'case_directional_feature_contributions_robust' key. */ case_feature_contributions_robust?: boolean; /** - * If true, outputs feature residuals for all (context and action) features for just the specified case. uses leave-one-out for each feature, while using the others to predict the left out feature with their corresponding values from this case. uses full calculations, which uses leave-one-out for cases for computations. + * If True, outputs feature residuals for all (context and action) features for just the specified case. Uses leave-one-out for each feature, while using the others to predict the left out feature with their corresponding values from this case. Uses full calculations, which uses leave-one-out for cases for computations. */ case_feature_residuals_full?: boolean; /** - * If true, outputs feature residuals for all (context and action) features for just the specified case. uses leave-one-out for each feature, while using the others to predict the left out feature with their corresponding values from this case. uses robust calculations, which uses uniform sampling from the power set of features as the contexts for predictions. + * If True, outputs feature residuals for all (context and action) features for just the specified case. Uses leave-one-out for each feature, while using the others to predict the left out feature with their corresponding values from this case. Uses robust calculations, which uses uniform sampling from the power set of features as the contexts for predictions. */ case_feature_residuals_robust?: boolean; /** - * If true, outputs this case's feature residual model. computed as: model feature full residual divided by case feature full residual. + * If True, outputs this case's feature residual model. Computed as: model feature full residual divided by case feature full residual. */ case_feature_residual_convictions_full?: boolean; /** - * If true, outputs this case's feature residual model. computed as: model feature robust residual divided by case feature robust residual. + * If True, outputs this case's feature residual model. Computed as: model feature robust residual divided by case feature robust residual. */ case_feature_residual_convictions_robust?: boolean; /** - * If true, outputs each influential case's mean decrease in accuracy of predicting the action feature in the local model area, as if each individual case were included versus not included. uses only the context features of the reacted case to determine that area. uses full calculations, which uses leave-one-out for cases for computations. + * If True, outputs each influential case's mean decrease in accuracy of predicting the action feature in the local model area, as if each individual case were included versus not included. Uses only the context features of the reacted case to determine that area. Uses full calculations, which uses leave-one-out for cases for computations. */ case_mda_full?: boolean; /** - * If true, outputs each influential case's mean decrease in accuracy of predicting the action feature in the local model area, as if each individual case were included versus not included. uses only the context features of the reacted case to determine that area. uses robust calculations, which uses uniform sampling from the power set of all combinations of cases. + * If True, outputs each influential case's mean decrease in accuracy of predicting the action feature in the local model area, as if each individual case were included versus not included. Uses only the context features of the reacted case to determine that area. Uses robust calculations, which uses uniform sampling from the power set of all combinations of cases. */ case_mda_robust?: boolean; /** - * When true, outputs probabilities for each class for the action. applicable only to categorical action features. + * When true, outputs probabilities for each class for the action. Applicable only to categorical action features. */ categorical_action_probabilities?: boolean; /** - * If true, outputs a dictionary of the parameters used in the react call. these include k, p, distance_transform, feature_weights, feature_deviations, and nominal_class_counts. + * If True, outputs a dictionary of the parameters used in the react call. These include k, p, distance_transform, feature_weights, feature_deviations, and nominal_class_counts. */ derivation_parameters?: boolean; /** - * When true, outputs the distance contribution (expected total surprisal contribution) for the reacted case. uses both context and action feature values. + * When true, outputs the distance contribution (expected total surprisal contribution) for the reacted case. Uses both context and action feature values. */ distance_contribution?: boolean; /** - * When true, outputs the ratio of distance (relative surprisal) between this reacted case and its nearest case to the minimum distance (relative surprisal) in between the closest two cases in the local area. all distances are computed using only the specified context features. + * When true, outputs the ratio of distance (relative surprisal) between this reacted case and its nearest case to the minimum distance (relative surprisal) in between the closest two cases in the local area. All distances are computed using only the specified context features. */ distance_ratio?: boolean; /** - * A list of feature names that specifies for what features will per-feature details be computed (residuals, contributions, mda, etc.). this should generally preserve compute, but will not when computing details robustly. details will be computed for all context and action features if this is not specified. + * A list of feature names that specifies for what features will per-feature details be computed (residuals, contributions, mda, etc.). This should generally preserve compute, but will not when computing details robustly. Details will be computed for all context and action features if this is not specified. */ features?: string[]; /** - * If true outputs each context feature's absolute and directional differences between the predicted action feature value and the predicted action feature value if each context were not in the model for all context features in the local model area. uses full calculations, which uses leave-one-out for cases for computations. directional feature contributions are returned under the key 'directional_feature_contributions_full'. + * If True outputs each context feature's absolute and directional differences between the predicted action feature value and the predicted action feature value if each context were not in the model for all context features in the local model area. Uses full calculations, which uses leave-one-out for cases for computations. Directional feature contributions are returned under the key 'directional_feature_contributions_full'. */ feature_contributions_full?: boolean; /** - * If true outputs each context feature's absolute and directional differences between the predicted action feature value and the predicted action feature value if each context were not in the model for all context features in the local model area uses robust calculations, which uses uniform sampling from the power set of features as the contexts for predictions. directional feature contributions are returned under the key 'directional_feature_contributions_robust'. + * If True outputs each context feature's absolute and directional differences between the predicted action feature value and the predicted action feature value if each context were not in the model for all context features in the local model area Uses robust calculations, which uses uniform sampling from the power set of features as the contexts for predictions. Directional feature contributions are returned under the key 'directional_feature_contributions_robust'. */ feature_contributions_robust?: boolean; /** - * If true, outputs each context feature's mean decrease in accuracy of predicting the action feature as an explanation detail given that the specified prediction was already made as specified by the action value. uses both context and action features of the reacted case to determine that area. uses full calculations, which uses leave-one-out for cases for computations. + * If True, outputs each context feature's mean decrease in accuracy of predicting the action feature as an explanation detail given that the specified prediction was already made as specified by the action value. Uses both context and action features of the reacted case to determine that area. Uses full calculations, which uses leave-one-out for cases for computations. */ feature_mda_ex_post_full?: boolean; /** - * If true, outputs each context feature's mean decrease in accuracy of predicting the action feature as an explanation detail given that the specified prediction was already made as specified by the action value. uses both context and action features of the reacted case to determine that area. uses robust calculations, which uses uniform sampling from the power set of features as the contexts for predictions. + * If True, outputs each context feature's mean decrease in accuracy of predicting the action feature as an explanation detail given that the specified prediction was already made as specified by the action value. Uses both context and action features of the reacted case to determine that area. Uses robust calculations, which uses uniform sampling from the power set of features as the contexts for predictions. */ feature_mda_ex_post_robust?: boolean; /** - * When true will compute mean decrease in accuracy (mda) for each context feature at predicting the action feature. drop each feature and use the full set of remaining context features for each prediction. false removes cached values. + * When True will compute Mean Decrease in Accuracy (MDA) for each context feature at predicting the action feature. Drop each feature and use the full set of remaining context features for each prediction. False removes cached values. */ feature_mda_full?: boolean; /** - * Compute mean decrease in accuracy mda by dropping each feature and using the robust (power set/permutations) set of remaining context features for each prediction. false removes cached values. + * Compute Mean Decrease in Accuracy MDA by dropping each feature and using the robust (power set/permutations) set of remaining context features for each prediction. False removes cached values. */ feature_mda_robust?: boolean; /** - * If true, outputs feature residuals for all (context and action) features locally around the prediction. uses only the context features of the reacted case to determine that area. uses full calculations, which uses leave-one-out for cases for computations. + * If True, outputs feature residuals for all (context and action) features locally around the prediction. Uses only the context features of the reacted case to determine that area. Uses full calculations, which uses leave-one-out for cases for computations. */ feature_residuals_full?: boolean; /** - * If true, outputs feature residuals for all (context and action) features locally around the prediction. uses only the context features of the reacted case to determine that area. uses robust calculations, which uses uniform sampling from the power set of features as the contexts for predictions. 'selected_prediction_stats' controls the returned prediction stats. + * If True, outputs feature residuals for all (context and action) features locally around the prediction. Uses only the context features of the reacted case to determine that area. Uses robust calculations, which uses uniform sampling from the power set of features as the contexts for predictions. 'selected_prediction_stats' controls the returned prediction stats. */ feature_residuals_robust?: boolean; /** - * When true, outputs the number of attempts taken to generate each case. only applicable when 'generate_new_cases' is "always" or "attempt". when used in react_series, "series_generate_attempts" is also returned. + * When true, outputs the number of attempts taken to generate each case. Only applicable when 'generate_new_cases' is "always" or "attempt". When used in react_series, "series_generate_attempts" is also returned. */ generate_attempts?: boolean; /** - * A dictionary of feature name to feature value. if specified, shows how a prediction could change in a what-if scenario where the influential cases' context feature values are replaced with the specified values. iterates over all influential cases, predicting the action features each one using the updated hypothetical values. outputs the predicted arithmetic over the influential cases for each action feature. + * A dictionary of feature name to feature value. If specified, shows how a prediction could change in a what-if scenario where the influential cases' context feature values are replaced with the specified values. Iterates over all influential cases, predicting the action features each one using the updated hypothetical values. Outputs the predicted arithmetic over the influential cases for each action feature. */ hypothetical_values?: Record; /** - * When true, outputs the most influential cases and their influence weights based on the surprisal of each case relative to the context being predicted among the cases. uses only the context features of the reacted case. + * When true, outputs the most influential cases and their influence weights based on the surprisal of each case relative to the context being predicted among the cases. Uses only the context features of the reacted case. */ influential_cases?: boolean; /** @@ -127,15 +129,15 @@ export type ReactDetails = { */ influential_cases_raw_weights?: boolean; /** - * When true, outputs an automatically determined (when 'num_most_similar_cases' is not specified) relevant number of similar cases, which will first include the influential cases. uses only the context features of the reacted case. + * When true, outputs an automatically determined (when 'num_most_similar_cases' is not specified) relevant number of similar cases, which will first include the influential cases. Uses only the context features of the reacted case. */ most_similar_cases?: boolean; /** - * When defined, outputs this manually specified number of boundary cases. takes precedence over 'boundary_cases' parameter. + * When defined, outputs this manually specified number of boundary cases. Takes precedence over 'boundary_cases' parameter. */ num_boundary_cases?: number; /** - * When defined, outputs this manually specified number of most similar cases, which will first include the influential cases. takes precedence over 'most_similar_cases' parameter. + * When defined, outputs this manually specified number of most similar cases, which will first include the influential cases. Takes precedence over 'most_similar_cases' parameter. */ num_most_similar_cases?: number; /** @@ -143,7 +145,7 @@ export type ReactDetails = { */ num_most_similar_case_indices?: number; /** - * Specifies the number of robust samples to use for each case. applicable only for computing robust feature contributions or robust case feature contributions. defaults to 2000 when unspecified. higher values will take longer but provide more stable results. + * Specifies the number of robust samples to use for each case. Applicable only for computing robust feature contributions or robust case feature contributions. Defaults to 2000 when unspecified. Higher values will take longer but provide more stable results. */ num_robust_influence_samples_per_case?: number; /** @@ -151,16 +153,19 @@ export type ReactDetails = { */ observational_errors?: boolean; /** - * When true, outputs the reacted case's context feature values that are outside the min or max of the corresponding feature values of all the cases in the local model area. uses only the context features of the reacted case to determine that area. + * When true, outputs the reacted case's context feature values that are outside the min or max of the corresponding feature values of all the cases in the local model area. Uses only the context features of the reacted case to determine that area. */ outlying_feature_values?: boolean; /** - * When true outputs feature prediction stats for all (context and action) features locally around the prediction. the stats returned are ("r2", "rmse", "spearman_coeff", "precision", "recall", "accuracy", "mcc", "confusion_matrix", "missing_value_accuracy"). uses only the context features of the reacted case to determine that area. uses full calculations, which uses leave-one-out context features for computations. 'selected_prediction_stats' controls the returned prediction stats. + * When true outputs feature prediction stats for all (context and action) features locally around the prediction. The stats returned are ("r2", "rmse", "spearman_coeff", "precision", "recall", "accuracy", "mcc", "confusion_matrix", "missing_value_accuracy"). Uses only the context features of the reacted case to determine that area. Uses full calculations, which uses leave-one-out context features for computations. 'selected_prediction_stats' controls the returned prediction stats. */ prediction_stats?: boolean; - selected_prediction_stats?: SelectedPredictionStats; /** - * When true, outputs similarity conviction for the reacted case. uses both context and action feature values as the case values for all computations. this is defined as expected (local) distance contribution divided by reacted case distance contribution. + * Types of stats to output. When unspecified, returns all except the confusion_matrix. If all, then returns all including the confusion_matrix. + */ + selected_prediction_stats?: PredictionStat[]; + /** + * When true, outputs similarity conviction for the reacted case. Uses both context and action feature values as the case values for all computations. This is defined as expected (local) distance contribution divided by reacted case distance contribution. */ similarity_conviction?: boolean; }; diff --git a/src/types/schemas/ReactGroup.ts b/src/types/schemas/ReactGroup.ts index 4faa9b9..c252d32 100644 --- a/src/types/schemas/ReactGroup.ts +++ b/src/types/schemas/ReactGroup.ts @@ -1,5 +1,6 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * ReactGroup * @@ -14,6 +15,7 @@ */ import type { UseCaseWeights } from "./UseCaseWeights"; +/** Request parameters of the Trainee method: reactGroup. */ export type ReactGroupRequest = { /** * Calculate and output distance contribution ratios in the output assoc @@ -40,13 +42,13 @@ export type ReactGroupRequest = { features?: string[]; /** - * Calculate and output the kl divergence of adding the specified new_cases in the output assoc + * Calculate and output the KL divergence of adding the specified new_cases in the output assoc * @default false */ kl_divergence_addition?: boolean; /** - * Calculate and output the kl divergence of removing the specified new_cases in the output assoc + * Calculate and output the KL divergence of removing the specified new_cases in the output assoc * @default false */ kl_divergence_removal?: boolean; @@ -71,7 +73,7 @@ export type ReactGroupRequest = { /** * Flag, if set to true will scale influence weights by each case's weight_feature weight. - * if a weight is missing, uses 1 as the weight. if unspecified, case weights will be used if the trainee has them. + * If a weight is missing, uses 1 as the weight. If unspecified, case weights will be used if the trainee has them. */ use_case_weights?: UseCaseWeights; @@ -81,3 +83,43 @@ export type ReactGroupRequest = { */ weight_feature?: string; }; + +/** Response of the Trainee method: reactGroup. */ +export type ReactGroupResponse = { + /** + * The average distance contribution of cases in the model. + */ + base_model_average_distance_contribution?: number[]; + /** + * The average distance contribution of cases in the model and the cases of each group. + */ + combined_model_average_distance_contribution?: number[]; + /** + * The average distance contributions of cases in each group. + */ + distance_contribution?: number[]; + /** + * The familiarity conviction of adding each group of cases to the model. + */ + familiarity_conviction_addition?: number[]; + /** + * The familiarity conviction of removing each group of cases to the model. + */ + familiarity_conviction_removal?: number[]; + /** + * The KL divergence of adding each group of cases to the model. + */ + kl_divergence_addition?: number[]; + /** + * The KL divergence of removing each group of cases to the model. + */ + kl_divergence_removal?: number[]; + /** + * The p-value of adding each group of cases to the model. + */ + p_value_of_addition?: number[]; + /** + * The p-value of removing each group of cases to the model. + */ + p_value_of_removal?: number[]; +}; diff --git a/src/types/schemas/ReactIntoFeatures.ts b/src/types/schemas/ReactIntoFeatures.ts index 639f6cb..277fae0 100644 --- a/src/types/schemas/ReactIntoFeatures.ts +++ b/src/types/schemas/ReactIntoFeatures.ts @@ -1,5 +1,6 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * ReactIntoFeatures * @@ -7,6 +8,7 @@ */ import type { UseCaseWeights } from "./UseCaseWeights"; +/** Request parameters of the Trainee method: reactIntoFeatures. */ export type ReactIntoFeaturesRequest = { /** * The list of case ids for the model to calculate conviction for @@ -54,7 +56,7 @@ export type ReactIntoFeaturesRequest = { similarity_conviction?: boolean | string; /** - * Flag, if set to true will scale influence weights by each case's weight_feature weight. if unspecified, + * Flag, if set to true will scale influence weights by each case's weight_feature weight. If unspecified, * case weights will be used if the trainee has them. */ use_case_weights?: UseCaseWeights; diff --git a/src/types/schemas/ReactSeries.ts b/src/types/schemas/ReactSeries.ts index f6aa486..636c157 100644 --- a/src/types/schemas/ReactSeries.ts +++ b/src/types/schemas/ReactSeries.ts @@ -1,20 +1,24 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * ReactSeries * - * React in a series until a series_stop_map condition is met. aggregates rows of data corresponding to the specified context, action, - * derived_context and derived_action features, utilizing previous rows to derive values as necessary. outputs an assoc of "action_features" and + * React in a series until a series_stop_map condition is met. Aggregates rows of data corresponding to the specified context, action, + * derived_context and derived_action features, utilizing previous rows to derive values as necessary. Outputs an assoc of "action_features" and * corresponding "series" where "series" is the completed 'matrix' for the corresponding action_features and derived_action_features. */ import type { CaseIndices } from "./CaseIndices"; +import type { Cases } from "./Cases"; +import type { CategoricalActionProbabilities } from "./CategoricalActionProbabilities"; import type { DesiredConviction } from "./DesiredConviction"; -import type { FeatureBoundsMap } from "./FeatureBoundsMap"; +import type { FeatureBounds } from "./FeatureBounds"; import type { GenerateNewCases } from "./GenerateNewCases"; import type { NewCaseThreshold } from "./NewCaseThreshold"; import type { ReactDetails } from "./ReactDetails"; import type { UseCaseWeights } from "./UseCaseWeights"; +/** Request parameters of the Trainee method: reactSeries. */ export type ReactSeriesRequest = { /** * List of feature names corresponding to values in each row of action_values @@ -30,7 +34,7 @@ export type ReactSeriesRequest = { /** * Pair (list) of session id and index, where index is the original 0-based session_training_index of the case as it was - * trained into the session. if this case does not exist, discriminative react outputs null, generative react ignores it. + * trained into the session. If this case does not exist, discriminative react outputs null, generative react ignores it. */ case_indices?: CaseIndices; @@ -46,16 +50,16 @@ export type ReactSeriesRequest = { context_values?: any[][]; /** - * Flag, default is false. when true will attempt to continue existing series instead of starting new series. - * if initial_values provide series ids, it will continue those explicitly specified ids, otherwise it will randomly select series to continue. - * note: terminated series with terminators cannot be continued and will result in null output. + * Flag, default is false. When true will attempt to continue existing series instead of starting new series. + * If initial_values provide series IDs, it will continue those explicitly specified IDs, otherwise it will randomly select series to continue. + * Note: terminated series with terminators cannot be continued and will result in null output. * @default false */ continue_series?: boolean; /** * List of features corresponding to the values in each row of continue_series_values. - * this value is ignored if continue_series_values is not specified. + * This value is ignored if continue_series_values is not specified. */ continue_series_features?: string[]; @@ -67,23 +71,23 @@ export type ReactSeriesRequest = { /** * List of action features whose values should be computed from the resulting last row in series, in the specified - * order. must be a subset of action_features. - * note: both of these derived feature lists rely on the features' "derived_feature_code" attribute to compute the values. - * if 'derived_feature_code' attribute is undefined or references non-existing feature indices, the derived value will be null. + * order. Must be a subset of action_features. + * Note: both of these derived feature lists rely on the features' "derived_feature_code" attribute to compute the values. + * If 'derived_feature_code' attribute is undefined or references non-existing feature indices, the derived value will be null. * @default [] */ derived_action_features?: string[]; /** * List of context features whose values should be computed from the entire series in the specified order. - * must be different than context_features. + * Must be different than context_features. * @default [] */ derived_context_features?: string[]; /** - * If null, will do a discriminative react. if specified, will do a generative react - * for generative react, value of desired avg conviction of generated cases, in the range of (0,infinity] with 1 as standard + * If null, will do a discriminative react. If specified, will do a generative react + * For Generative React, value of desired avg conviction of generated cases, in the range of (0,infinity] with 1 as standard * larger values will increase the variance (or creativity) of the generated case from the existing model * smaller values will decrease the variance (or creativity) of the generated case from the existing model */ @@ -112,7 +116,7 @@ export type ReactSeriesRequest = { * allow_null - default is true, if true nulls may be generated per their distribution in the data * @default {} */ - feature_bounds_map?: Record; + feature_bounds_map?: Record; /** * Time step values at which to end synthesis for each series, applicable only for time series. @@ -130,14 +134,14 @@ export type ReactSeriesRequest = { /** * List of features to condition just the first case in a series, overwrites context_features and - * derived_context_features for that first case. all specified initial features must be in one of: context_features, action_features, - * derived_context_features or derived_action_features. if provided a value that isn't in one of those lists, it will be ignored. + * derived_context_features for that first case. All specified initial features must be in one of: context_features, action_features, + * derived_context_features or derived_action_features. If provided a value that isn't in one of those lists, it will be ignored. * @default [] */ initial_features?: string[]; /** - * 2d-list of values corresponding to the initial_features, used to condition just the first case in a series. one list is used per series. + * 2d-list of values corresponding to the initial_features, used to condition just the first case in a series. One list is used per series. */ initial_values?: any[][]; @@ -158,13 +162,13 @@ export type ReactSeriesRequest = { leave_case_out?: boolean; /** - * List of maximum sizes each series is allowed to be. default is 3 * model_size, a 0 or less is no limit. - * if forecasting with 'continue_series', this defines the maximum length of the forecast. + * List of maximum sizes each series is allowed to be. Default is 3 * model_size, a 0 or less is no limit. + * If forecasting with 'continue_series', this defines the maximum length of the forecast. */ max_series_lengths?: number[]; /** - * Distance to determine privacy cutoff. used to query the local minimum distance used in the distance ratio + * Distance to determine privacy cutoff. Used to query the local minimum distance used in the distance ratio * accepted values: * 'max': the maximum local distance * 'min': the minimum local distance @@ -177,7 +181,7 @@ export type ReactSeriesRequest = { /** * Total number of series to generate, for generative reacts. * - * all of the following parameters, if specified, must be either length of 1 or equal to the length of + * All of the following parameters, if specified, must be either length of 1 or equal to the length of * context_values/case_indices for discriminative reacts, and num_series_to_generate for generative reacts. */ num_series_to_generate?: number; @@ -195,7 +199,7 @@ export type ReactSeriesRequest = { /** * List of features that will preserve their values from the case specified by case_indices, appending and - * overwriting the specified context and context features as necessary. for generative reacts, if case_indices isn't specified, + * overwriting the specified context and context features as necessary. For generative reacts, if case_indices isn't specified, * will preserve feature values of a random case. * @default [] */ @@ -209,17 +213,17 @@ export type ReactSeriesRequest = { /** * 3d-list of values, context value for each feature for each row of a series. - * if specified max_series_lengths are ignored. + * If specified max_series_lengths are ignored. */ series_context_values?: any[][][]; /** * Controls how closely generated series should follow existing series (plural). - * choices are: "fixed", "dynamic" or "no". if "fixed", tracks the particular relevant series id. if "dynamic", tracks the particular - * relevant series id, but is allowed to change the series id that it tracks based on its current context. if "no", does not track any particular series id. + * Choices are: "fixed", "dynamic" or "no". If "fixed", tracks the particular relevant series ID. If "dynamic", tracks the particular + * relevant series ID, but is allowed to change the series ID that it tracks based on its current context. If "no", does not track any particular series ID. * @default "fixed" */ - series_id_tracking?: "fixed" | "dynamic" | "no"; + series_id_tracking?: "dynamic" | "fixed" | "no"; /** * List of assocs of feature -> stop conditions: @@ -233,13 +237,13 @@ export type ReactSeriesRequest = { series_stop_maps?: Record[]; /** - * Flag, default is true, only applicable if a substitution value map has been set. if set to false, will not substitute categorical feature values. + * Flag, default is true, only applicable if a substitution value map has been set. If set to false, will not substitute categorical feature values. * @default true */ substitute_output?: boolean; /** - * Flag, whether to use case weights or not. if unspecified will automatically select based on cached parameters + * Flag, whether to use case weights or not. If unspecified will automatically select based on cached parameters */ use_case_weights?: UseCaseWeights; @@ -255,3 +259,167 @@ export type ReactSeriesRequest = { */ weight_feature?: string; }; + +/** Response of the Trainee method: reactSeries. */ +export type ReactSeriesResponse = { + /** + * The list of feature names that correspond to the values in each list of values in 'action_values'. + */ + action_features: string[]; + /** + * A list of individual series. + */ + action_values: any[][][]; + /** + * A list of aggregated categorical action probabilities for each nominal features across all the cases of each series. + */ + aggregated_categorical_action_probabilities?: Record[]; + /** + * Experimental. The same detail as in standard #react, but accumulated for each case in each series. + */ + boundary_cases?: any; + /** + * Experimental. The same detail as in standard #react, but accumulated for each case in each series. + */ + case_contributions_full?: any; + /** + * Experimental. The same detail as in standard #react, but accumulated for each case in each series. + */ + case_contributions_robust?: any; + /** + * Experimental. The same detail as in standard #react, but accumulated for each case in each series. + */ + case_directional_feature_contributions_full?: any; + /** + * Experimental. The same detail as in standard #react, but accumulated for each case in each series. + */ + case_directional_feature_contributions_robust?: any; + /** + * Experimental. The same detail as in standard #react, but accumulated for each case in each series. + */ + case_feature_contributions_full?: any; + /** + * Experimental. The same detail as in standard #react, but accumulated for each case in each series. + */ + case_feature_contributions_robust?: any; + /** + * Experimental. The same detail as in standard #react, but accumulated for each case in each series. + */ + case_feature_residuals_full?: any; + /** + * Experimental. The same detail as in standard #react, but accumulated for each case in each series. + */ + case_feature_residuals_robust?: any; + /** + * Experimental. The same detail as in standard #react, but accumulated for each case in each series. + */ + case_feature_residual_convictions_full?: any; + /** + * Experimental. The same detail as in standard #react, but accumulated for each case in each series. + */ + case_feature_residual_convictions_robust?: any; + /** + * Experimental. The same detail as in standard #react, but accumulated for each case in each series. + */ + case_mda_full?: any; + /** + * Experimental. The same detail as in standard #react, but accumulated for each case in each series. + */ + case_mda_robust?: any; + /** + * A list of the detail result lists for each case of each series. + */ + categorical_action_probabilities?: Record[][]; + /** + * Experimental. The same detail as in standard #react, but accumulated for each case in each series. + */ + directional_feature_contributions_full?: any; + /** + * Experimental. The same detail as in standard #react, but accumulated for each case in each series. + */ + directional_feature_contributions_robust?: any; + /** + * Experimental. The same detail as in standard #react, but accumulated for each case in each series. + */ + distance_contribution?: any; + /** + * Experimental. The same detail as in standard #react, but accumulated for each case in each series. + */ + distance_ratio?: any; + /** + * Experimental. The same detail as in standard #react, but accumulated for each case in each series. + */ + distance_ratio_parts?: any; + /** + * Experimental. The same detail as in standard #react, but accumulated for each case in each series. + */ + feature_contributions_full?: any; + /** + * Experimental. The same detail as in standard #react, but accumulated for each case in each series. + */ + feature_contributions_robust?: any; + /** + * Experimental. The same detail as in standard #react, but accumulated for each case in each series. + */ + feature_mda_ex_post_full?: any; + /** + * Experimental. The same detail as in standard #react, but accumulated for each case in each series. + */ + feature_mda_ex_post_robust?: any; + /** + * Experimental. The same detail as in standard #react, but accumulated for each case in each series. + */ + feature_mda_full?: any; + /** + * Experimental. The same detail as in standard #react, but accumulated for each case in each series. + */ + feature_mda_robust?: any; + /** + * Experimental. The same detail as in standard #react, but accumulated for each case in each series. + */ + feature_residuals_full?: any; + /** + * Experimental. The same detail as in standard #react, but accumulated for each case in each series. + */ + feature_residuals_robust?: any; + /** + * A list of the detail result lists for each case of each series. + */ + generate_attempts?: number[][]; + /** + * Experimental. The same detail as in standard #react, but accumulated for each case in each series. + */ + hypothetical_values?: any; + /** + * A list of the detail result lists for each case of each series. + */ + influential_cases?: Cases[][]; + /** + * Experimental. The same detail as in standard #react, but accumulated for each case in each series. + */ + most_similar_cases?: any; + /** + * Experimental. The same detail as in standard #react, but accumulated for each case in each series. + */ + most_similar_case_indices?: any; + /** + * Experimental. The same detail as in standard #react, but accumulated for each case in each series. + */ + observational_errors?: any; + /** + * Experimental. The same detail as in standard #react, but accumulated for each case in each series. + */ + outlying_feature_values?: any; + /** + * Experimental. The same detail as in standard #react, but accumulated for each case in each series. + */ + prediction_stats?: any; + /** + * A list of generation attempts for each series as a whole. + */ + series_generate_attempts?: number[]; + /** + * Experimental. The same detail as in standard #react, but accumulated for each case in each series. + */ + similarity_conviction?: any; +}; diff --git a/src/types/schemas/ReactionPredictionStats.ts b/src/types/schemas/ReactionPredictionStats.ts new file mode 100644 index 0000000..5a354c0 --- /dev/null +++ b/src/types/schemas/ReactionPredictionStats.ts @@ -0,0 +1,24 @@ +/** + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. + */ +import type { ConfusionMatrix } from "./ConfusionMatrix"; +import type { FeatureMetricIndex } from "./FeatureMetricIndex"; + +/** + * A map of prediction statistic names to maps of feature names to the computed values for each statistic. + */ +export type ReactionPredictionStats = { + accuracy?: FeatureMetricIndex; + adjusted_smape?: FeatureMetricIndex; + confusion_matrix?: Record; + mae?: FeatureMetricIndex; + mcc?: FeatureMetricIndex; + missing_value_accuracy?: FeatureMetricIndex; + precision?: FeatureMetricIndex; + r2?: FeatureMetricIndex; + recall?: FeatureMetricIndex; + rmse?: FeatureMetricIndex; + smape?: FeatureMetricIndex; + spearman_coeff?: FeatureMetricIndex; +}; diff --git a/src/types/schemas/ReduceData.ts b/src/types/schemas/ReduceData.ts index e245768..41a3a21 100644 --- a/src/types/schemas/ReduceData.ts +++ b/src/types/schemas/ReduceData.ts @@ -1,5 +1,6 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * ReduceData * @@ -8,11 +9,12 @@ */ import type { AblationThresholdMap } from "./AblationThresholdMap"; +/** Request parameters of the Trainee method: reduceData. */ export type ReduceDataRequest = { /** * A map of measure names (any of the prediction stats) to a map of feature names to threshold value. * absolute thresholds will cause data reduction to stop when any of the measure values for any of - * the features for which a threshold is defined go avove the threshold (in the case of rmse and + * the features for which a threshold is defined go above the threshold (in the case of rmse and * mae) or below the threshold (otherwise). * @default {} */ @@ -27,7 +29,7 @@ export type ReduceDataRequest = { /** * A map of measure names (any of the prediction stats) to a map of feature names to threshold value. * delta thresholds will cause data reduction to stop when the delta between any of the measure values - * for any of the features for which a threshold is defined and its previous value go avove the threshold + * for any of the features for which a threshold is defined and its previous value go above the threshold * (in the case of rmse and mae) or below the threshold (otherwise). * @default {} */ @@ -47,7 +49,7 @@ export type ReduceDataRequest = { /** * Numeric maximum threshold for influence weight entropy of cases to keep, defaults to the value - * influence weight entropy threshold stored within the trainee + * influence weight entropy threshold stored within the Trainee * @default 0.15 */ influence_weight_entropy_threshold?: number; @@ -56,7 +58,7 @@ export type ReduceDataRequest = { * A map of measure names (any of the prediction stats) to a map of feature names to threshold value. * relative thresholds will cause data reduction to stop when the relative change between any of the * measure values for any of the features for which a threshold is defined and its previous value go - * avove the threshold (in the case of rmse and mae) or below the threshold (otherwise). + * above the threshold (in the case of rmse and mae) or below the threshold (otherwise). * @default {} */ rel_threshold_map?: AblationThresholdMap; @@ -67,3 +69,11 @@ export type ReduceDataRequest = { */ skip_auto_analyze?: boolean; }; + +/** Response of the Trainee method: reduceData. */ +export type ReduceDataResponse = { + /** + * A map of threshold-type (abs, relative, or delta) to map of metric to map of feature name to boolean. Indicating what thresholds were met to trigger the end of data reduction. + */ + threshold_info?: Record>>; +}; diff --git a/src/types/schemas/RemoveCases.ts b/src/types/schemas/RemoveCases.ts index 4e7e114..4c0d719 100644 --- a/src/types/schemas/RemoveCases.ts +++ b/src/types/schemas/RemoveCases.ts @@ -1,5 +1,6 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * RemoveCases * @@ -9,6 +10,7 @@ import type { CaseIndices } from "./CaseIndices"; import type { Condition } from "./Condition"; import type { Precision } from "./Precision"; +/** Request parameters of the Trainee method: removeCases. */ export type RemoveCasesRequest = { /** * A list of session id and training index tuples that specify which cases are to be removed @@ -16,13 +18,13 @@ export type RemoveCasesRequest = { case_indices?: CaseIndices; /** - * Assoc of feature->value(s) (no value = must have feature, one value = must equal exactly the value, two values = inclusive between). ignored if case_indices is specified. + * Assoc of feature->value(s) (no value = must have feature, one value = must equal exactly the value, two values = inclusive between). Ignored if case_indices is specified. * @default {} */ condition?: Condition; /** - * If specified, ignores condition and instead operates on all cases that were trained with this session id. ignored if case_indices is specified. + * If specified, ignores condition and instead operates on all cases that were trained with this session id. Ignored if case_indices is specified. */ condition_session?: string; @@ -32,14 +34,19 @@ export type RemoveCasesRequest = { distribute_weight_feature?: string; /** - * Limit on the number of cases to move; if set to zero there will be no limit. ignored if case_indices is specified. - * if null, will be set to k if precision is "similar" or no limit if precision is "exact". default is null + * Limit on the number of cases to move; If set to zero there will be no limit. Ignored if case_indices is specified. + * If null, will be set to k if precision is "similar" or no limit if precision is "exact". default is null */ num_cases?: number; /** - * Flag, whether to query for 'exact' matches; if set to 'similar' will remove num_cases with the most similar values. ignored if case_indices is specified. + * Flag, whether to query for 'exact' matches; if set to 'similar' will remove num_cases with the most similar values. Ignored if case_indices is specified. * @default "exact" */ precision?: Precision; }; + +/** Response of the Trainee method: removeCases. */ +export type RemoveCasesResponse = { + count: number; +}; diff --git a/src/types/schemas/RemoveFeature.ts b/src/types/schemas/RemoveFeature.ts index d84234c..265f33a 100644 --- a/src/types/schemas/RemoveFeature.ts +++ b/src/types/schemas/RemoveFeature.ts @@ -1,14 +1,16 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * RemoveFeature * * Removes the specified feature on all cases for a trainee that match the specified condition * if conditions are not specified, removes feature for all cases and from the model, if condition is an empty assoc, leaves the feature metadata in the model. - * updates the accumulated data mass for the model proportional to the number of cases modified. + * Updates the accumulated data mass for the model proportional to the number of cases modified. */ import type { Condition } from "./Condition"; +/** Request parameters of the Trainee method: removeFeature. */ export type RemoveFeatureRequest = { /** * Assoc of feature->value(s). diff --git a/src/types/schemas/RemoveSeriesStore.ts b/src/types/schemas/RemoveSeriesStore.ts index 633dc76..9d199e2 100644 --- a/src/types/schemas/RemoveSeriesStore.ts +++ b/src/types/schemas/RemoveSeriesStore.ts @@ -1,11 +1,13 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * RemoveSeriesStore * * Clears stored series */ +/** Request parameters of the Trainee method: removeSeriesStore. */ export type RemoveSeriesStoreRequest = { /** * Series id to clear. if not provided, removes entire store diff --git a/src/types/schemas/RenameSubtrainee.ts b/src/types/schemas/RenameSubtrainee.ts index 5b0ac3b..961b3b3 100644 --- a/src/types/schemas/RenameSubtrainee.ts +++ b/src/types/schemas/RenameSubtrainee.ts @@ -1,14 +1,16 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * RenameSubtrainee * * Rename a contained trainee */ +/** Request parameters of the Trainee method: renameSubtrainee. */ export type RenameSubtraineeRequest = { /** - * Id of child trainee to rename. ignored if child_name_path is specified + * Id of child trainee to rename. Ignored if child_name_path is specified */ child_id?: string; diff --git a/src/types/schemas/RobustCaseContribution.ts b/src/types/schemas/RobustCaseContribution.ts new file mode 100644 index 0000000..8e5bfa8 --- /dev/null +++ b/src/types/schemas/RobustCaseContribution.ts @@ -0,0 +1,13 @@ +/** + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. + */ + +/** + * A map for an influential case that describes its training index, session, and the robust contribution to the action feature. + */ +export type RobustCaseContribution = { + ".session"?: string; + ".session_training_index"?: number; + case_contributions_robust?: number; +}; diff --git a/src/types/schemas/SaveSubtrainee.ts b/src/types/schemas/SaveSubtrainee.ts index 10c5632..e44af0c 100644 --- a/src/types/schemas/SaveSubtrainee.ts +++ b/src/types/schemas/SaveSubtrainee.ts @@ -1,11 +1,13 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * SaveSubtrainee * * Saves a subtrainee with the following optional parameters, escapes trainee filenames on save */ +/** Request parameters of the Trainee method: saveSubtrainee. */ export type SaveSubtraineeRequest = { /** * Name to store (without extension) @@ -32,7 +34,7 @@ export type SaveSubtraineeRequest = { trainee?: string | string[]; /** - * Unique id for trainee. must be provided if trainee does not have one already specified. + * Unique id for trainee. Must be provided if trainee does not have one already specified. */ trainee_id?: string; }; diff --git a/src/types/schemas/SelectedPredictionStats.ts b/src/types/schemas/SelectedPredictionStats.ts deleted file mode 100644 index 257627c..0000000 --- a/src/types/schemas/SelectedPredictionStats.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * WARNING: This file is auto generated, do not modify manually. - * - * SelectedPredictionStats - */ -import type { PredictionStat } from "./PredictionStat"; - -/** - * Types of stats to output. when unspecified, returns all except the confusion_matrix. if all, then returns all including the confusion_matrix. - */ -export type SelectedPredictionStats = PredictionStat[]; diff --git a/src/types/schemas/SetAutoAblationParams.ts b/src/types/schemas/SetAutoAblationParams.ts index 2ec4d49..52d6f38 100644 --- a/src/types/schemas/SetAutoAblationParams.ts +++ b/src/types/schemas/SetAutoAblationParams.ts @@ -1,11 +1,14 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * SetAutoAblationParams * * Sets the model to auto-ablate by tracking its size and training certain cases as weights */ +import type { AblationThresholdMap } from "./AblationThresholdMap"; +/** Request parameters of the Trainee method: setAutoAblationParams. */ export type SetAutoAblationParamsRequest = { /** * The number of ablated cases to compute influence weights for distribution at a time @@ -13,6 +16,15 @@ export type SetAutoAblationParamsRequest = { */ ablated_cases_distribution_batch_size?: number; + /** + * A map of measure names (any of the prediction stats) to a map of feature names to threshold value. + * absolute thresholds will cause ablation to stop when any of the measure values for any of + * the features for which a threshold is defined go above the threshold (in the case of rmse and + * mae) or below the threshold (otherwise). + * @default {} + */ + abs_threshold_map?: AblationThresholdMap; + /** * Flag, default is false. when true, any enabled ablation techniques will be run at during training. * @default false @@ -41,6 +53,15 @@ export type SetAutoAblationParamsRequest = { */ conviction_upper_threshold?: number; + /** + * A map of measure names (any of the prediction stats) to a map of feature names to threshold value. + * delta thresholds will cause ablation to stop when the delta between any of the measure values + * for any of the features for which a threshold is defined and its previous value go above the threshold + * (in the case of rmse and mae) or below the threshold (otherwise). + * @default {} + */ + delta_threshold_map?: AblationThresholdMap; + /** * List of features. for each of the features specified, will ablate a case if the prediction * matches exactly. @@ -59,14 +80,23 @@ export type SetAutoAblationParamsRequest = { * default of 1000. * @default 1000 */ - minimum_model_size?: number; + minimum_num_cases?: number; /** - * Assoc of feature -> percent. for each of the features specified, will - * ablate a case if abs(prediction - case value) / prediction <= percent + * Assoc of feature -> PERCENT. for each of the features specified, will + * ablate a case if abs(prediction - case value) / prediction <= PERCENT */ relative_prediction_threshold_map?: Record; + /** + * A map of measure names (any of the prediction stats) to a map of feature names to threshold value. + * relative thresholds will cause ablation to stop when the relative change between any of the + * measure values for any of the features for which a threshold is defined and its previous value go + * above the threshold (in the case of rmse and mae) or below the threshold (otherwise). + * @default {} + */ + rel_threshold_map?: AblationThresholdMap; + /** * List of features. for each of the features specified, will ablate a case if * abs(prediction - case value) <= feature residual @@ -74,8 +104,8 @@ export type SetAutoAblationParamsRequest = { residual_prediction_features?: string[]; /** - * Assoc of feature -> [min, max]. for each of the features specified, will - * ablate a case if the prediction >= (case value - min) and the prediction <= (case value + max) + * Assoc of feature -> [MIN, MAX]. for each of the features specified, will + * ablate a case if the prediction >= (case value - MIN) and the prediction <= (case value + MAX) */ tolerance_prediction_threshold_map?: Record; }; diff --git a/src/types/schemas/SetAutoAnalyzeParams.ts b/src/types/schemas/SetAutoAnalyzeParams.ts index ae54d6e..0047d36 100644 --- a/src/types/schemas/SetAutoAnalyzeParams.ts +++ b/src/types/schemas/SetAutoAnalyzeParams.ts @@ -1,5 +1,6 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * SetAutoAnalyzeParams * @@ -7,6 +8,7 @@ */ import type { UseCaseWeights } from "./UseCaseWeights"; +/** Request parameters of the Trainee method: setAutoAnalyzeParams. */ export type SetAutoAnalyzeParamsRequest = { /** * {type "list" values "string"} @@ -65,10 +67,10 @@ export type SetAutoAnalyzeParamsRequest = { /** * List of values for dt (the distance transform) to grid search during analysis */ - dt_values?: number[]; + dt_values?: (number | string)[]; /** - * Whether to use inverse residuals as feature weights. if unspecified, inverse residuals will be used as weights for + * Whether to use inverse residuals as feature weights. If unspecified, inverse residuals will be used as weights for * targetless params, otherwise this method will not be used. */ inverse_residuals_as_weights?: boolean | null; @@ -95,7 +97,7 @@ export type SetAutoAnalyzeParamsRequest = { num_samples?: number; /** - * List of values for p (the parameter of the lebesgue space) to grid search during analysis + * List of values for p (the parameter of the Lebesgue space) to grid search during analysis */ p_values?: number[]; @@ -105,7 +107,7 @@ export type SetAutoAnalyzeParamsRequest = { * "omni_targeted" = analyze hyperparameters for each action feature, using all other features as context_features. if action_features aren't specified, uses all context_features. * "targetless" = analyze hyperparameters for all context features as possible action features, ignores action_features parameter */ - targeted_model?: "single_targeted" | "omni_targeted" | "targetless"; + targeted_model?: "omni_targeted" | "single_targeted" | "targetless"; /** * When true will scale influence weights by each case's weight_feature weight. if use_case_weights isn't specified, it will @@ -114,8 +116,8 @@ export type SetAutoAnalyzeParamsRequest = { use_case_weights?: UseCaseWeights; /** - * Whether to use deviations for lk metric in queries. when true forces the use - * of deviations, when false will not use deviations. if unspecified, the better performing option will be selected. + * Whether to use deviations for LK metric in queries. When true forces the use + * of deviations, when false will not use deviations. If unspecified, the better performing option will be selected. */ use_deviations?: boolean | null; diff --git a/src/types/schemas/SetFeatureAttributes.ts b/src/types/schemas/SetFeatureAttributes.ts index fea5709..5b4b337 100644 --- a/src/types/schemas/SetFeatureAttributes.ts +++ b/src/types/schemas/SetFeatureAttributes.ts @@ -1,5 +1,6 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * SetFeatureAttributes * @@ -7,6 +8,7 @@ */ import type { FeatureAttributesIndex } from "./FeatureAttributesIndex"; +/** Request parameters of the Trainee method: setFeatureAttributes. */ export type SetFeatureAttributesRequest = { /** * Flag, default to true. create time series feature attributes if necessary @@ -17,149 +19,150 @@ export type SetFeatureAttributesRequest = { /** * Assoc of feature -> attributes, attributes defined below: * - * 'type': string, one of 'continuous', 'ordinal' or 'nominal'. default is 'continuous'. + * 'type': string, one of 'continuous', 'ordinal' or 'nominal'. Default is 'continuous'. * * 'bounds' : assoc of of bounds for feature value generation, keys of assoc defined below as: * 'min': number or date string, the minimum value to be output * 'max': number or date string, the maximum value to be output - * 'allowed': list of explicitly allowed values to be output. example: ["low", "medium", "high"] - * 'allow_null': flag, allow nulls to be output, per their distribution in the data. defaults to true + * 'allowed': list of explicitly allowed values to be output. Example: ["low", "medium", "high"] + * 'allow_null': flag, allow nulls to be output, per their distribution in the data. Defaults to true * 'constraint': code, whose logic has to evaluate to true for value to be considered valid. - * same format as 'derived_feature_code. example: "(> #f1 0 #f2 0)" + * Same format as 'derived_feature_code. Example: "(> #f1 0 #f2 0)" * * 'cycle_length': integer, specifies cycle length of cyclic feature, default is no cycle length * - * 'date_time_format': string datetime format, only applicable to continuous features. if specified, feature values - * should match the date format specified by this string and sets 'data_type' to 'formatted_date_time'. - * example: "%y-%m-%d". if unspecified but 'data_type' is 'formatted_date_time', this will be set to - * iso8601 format of "%y-%m-%dt%h:%m:%s" + * 'date_time_format': string datetime format, only applicable to continuous features. If specified, feature values + * should match the date or time format specified by this string and sets 'data_type' to 'formatted_date_time'. + * Example: "%Y-%m-%d". If unspecified but 'data_type' is 'formatted_date_time', this will be set to + * ISO8601 format of "%Y-%m-%dT%H:%M:%S", if 'data_type' is 'formatted_time', this will be + * ISO8601 format of "%H:%M%S". * - * 'locale': string, the date time format locale. if unspecified, uses platform default locale. example: "en_us" + * 'locale': string, the date time format locale. If unspecified, uses platform default locale. Example: "en_US" * * 'significant_digits': integer, round to the specified significant digits, default is no rounding * - * 'decimal_places': integer, decimal places to round to, default is no rounding. if "significant_digits" + * 'decimal_places': integer, decimal places to round to, default is no rounding. If "significant_digits" * is also specified, the number will be rounded to the specified number of significant * digits first, then rounded to the number of decimal points as specified by this parameter * - * 'observational_error': number, specifies the observational mean absolute error for this feature. use when the error - * value is already known. default is 0 + * 'observational_error': number, specifies the observational mean absolute error for this feature. Use when the error + * value is already known. Default is 0 * * 'data_type': string, specify the data type for features with a type of nominal or continuous - * defaults to 'string' for nominals and 'number' for continuous - * valid values for both are: 'string', 'number', 'json', 'amalgam', 'yaml' - * 'string_mixable' and 'formatted_date_time' are valid only when type is continuous + * Defaults to 'string' for nominals and 'number' for continuous + * Valid values for both are: 'string', 'number', 'json', 'amalgam', 'yaml' + * 'string_mixable', 'formatted_time' and 'formatted_date_time' are valid only when type is continuous * 'boolean' is valid only when type is nominal * - * 'id_feature': boolean, set to true only for nominal features containing nominal ids to specify that this - * feature should be used to compute case weights for id based privacy. for time series, - * this feature will be used as the id for each time series generation. default is false + * 'id_feature': boolean, Set to true only for nominal features containing nominal IDs to specify that this + * feature should be used to compute case weights for id based privacy. For time series, + * this feature will be used as the id for each time series generation. Default is false * - * 'unique': boolean, flag feature as only having unique values. only applicable to nominal features. defaults to false. + * 'unique': boolean, flag feature as only having unique values. Only applicable to nominal features. Defaults to false. * * 'dependent_features': list, a list of other feature(s) that this feature depends on or that are dependent on this - * feature. this restricts the cases that can be selected as neighbors (such as in react) to ones - * that satisfy the dependency, if possible. if this is not possible, either due to insufficient data + * feature. This restricts the cases that can be selected as neighbors (such as in react) to ones + * that satisfy the dependency, if possible. If this is not possible, either due to insufficient data * which satisfy the dependency or because dependencies are probabilistic, the dependency may not be - * maintained. be aware that dependencies introduce further constraints to data and so several + * maintained. Be aware that dependencies introduce further constraints to data and so several * dependencies or dependencies on already constrained datasets may restrict which operations are - * possible while maintaining the dependency. as a rule of thumb, sets of features that have + * possible while maintaining the dependency. As a rule of thumb, sets of features that have * dependency relationships should generally not include more than 1 continuous feature, unless * the continuous features have a small number of values that are commonly used. * * 'null_is_dependent': boolean, modifies how dependent features with nulls are treated during a react, specifically - * when they use null as a context value. only applicable to dependent features. when false, the - * feature will be treated as a non-dependent context feature. when true for nominal types, + * when they use null as a context value. Only applicable to dependent features. When false, the + * feature will be treated as a non-dependent context feature. When true for nominal types, * treats null as an individual dependent class value, only cases that also have nulls as this - * feature's value will be considered. when true for continuous types, only the cases with the + * feature's value will be considered. When true for continuous types, only the cases with the * same dependent feature values as the cases that also have nulls as this feature's value - * will be considered. default is false. + * will be considered. Default is false. * * 'auto_derive_on_train': assoc, defines how to create and derive all the values for this feature from - * the trained dataset. for full list of specific 'auto_derive_on_train' feature + * the trained dataset. For full list of specific 'auto_derive_on_train' feature * attributes refer the comments at the top of the derive.amlg module. * * 'derived_feature_code': string, code defining how the value for this feature could be derived if this feature * is specified as a "derived_context_feature" or a "derived_action_feature" during - * react flows. for react_series, the data referenced is the accumulated series data + * react flows. For react_series, the data referenced is the accumulated series data * (as a list of rows), and for non-series reacts, the data is the one single row. - * each row is comprised of all the combined context and action features. referencing + * Each row is comprised of all the combined context and action features. Referencing * data in these rows uses 0-based indexing, where the current row index is 0, the - * previous row's is 1, etc. specified code may do simple logic and numeric operations + * previous row's is 1, etc. Specified code may do simple logic and numeric operations * on feature values referenced via feature name and row offset. - * examples: - * "#x 1" - use the value for feature 'x' from the previously processed row (offset of 1, one lag value). - * "(- #y 0 #x 1)" - feature 'y' value from current (offset 0) row minus feature 'x' value from previous (offset 1) row. + * Examples: + * "#x 1" - Use the value for feature 'x' from the previously processed row (offset of 1, one lag value). + * "(- #y 0 #x 1)" - Feature 'y' value from current (offset 0) row minus feature 'x' value from previous (offset 1) row. * - * 'post_process': string, custom amalgam code that is called on resulting values of this feature during react operations. - * example: "(set_digits #x 0 3.1 (list 1 0) 2 3 (false))" + * 'post_process': string, custom Amalgam code that is called on resulting values of this feature during react operations. + * Example: "(set_digits #x 0 3.1 (list 1 0) 2 3 (false))" * - * 'non_sensitive': boolean, flag a categorical nominal feature as non-sensitive. it is recommended that + * 'non_sensitive': boolean, flag a categorical nominal feature as non-sensitive. It is recommended that * all nominal features be represented with either an 'int-id' subtype or another - * available nominal subtype using the 'subtype' attribute. however, if the nominal + * available nominal subtype using the 'subtype' attribute. However, if the nominal * feature is non-sensitive, setting this parameter to true will bypass the 'subtype' - * requirement. only applicable to nominal features. default is false + * requirement. Only applicable to nominal features. Default is false * * 'subtype': string, the type used in novel nominal substitution. * - * 'original_type': string, original data type details. used by clients to determine how to serialize and deserialize feature data. + * 'original_type': string, original data type details. Used by clients to determine how to serialize and deserialize feature data. * - * 'original_format': string, original data formats used by clients. automatically populated by clients + * 'original_format': string, original data formats used by clients. Automatically populated by clients * to store client language specific context about features. * * 'time_series': assoc, defining time series options for a feature, keys of assoc defined below as: * - * 'type': string, one of "rate" or "delta". when 'rate' is specified, uses the difference of the current value + * 'type': string, one of "rate" or "delta". When 'rate' is specified, uses the difference of the current value * from its previous value divided by the change in time since the previous value. - * when 'delta' is specified, uses the difference of the current value from its previous value - * regardless of the elapsed time. set to 'delta' if feature has 'time_feature' set to true. + * When 'delta' is specified, uses the difference of the current value from its previous value + * regardless of the elapsed time. Set to 'delta' if feature has 'time_feature' set to true. * - * 'time_feature': boolean, when true, the feature will be treated as the time feature for time - * series modeling. additionally, time features must use type 'delta'. default is false. + * 'time_feature': boolean, When true, the feature will be treated as the time feature for time + * series modeling. Additionally, time features must use type 'delta'. Default is false. * - * 'order': integer, if provided, will generate the specified number of derivatives and boundary values. default is 1 + * 'order': integer, if provided, will generate the specified number of derivatives and boundary values. Default is 1 * - * 'derived_orders': integer, the number of orders of derivatives that should be derived instead of synthesized. - * ignored if order is not provided. default is 0. + * 'derived_orders': integer, The number of orders of derivatives that should be derived instead of synthesized. + * Ignored if order is not provided. Default is 0. * * 'lags': list of number, if specified, generates lag features containing previous values using the enumerated lag offsets. - * takes precedence over 'num_lags'. if neither 'num_lags' nor 'lags' is specified for a feature, then a single - * lag feature is generated. example: [1,2] + * Takes precedence over 'num_lags'. If neither 'num_lags' nor 'lags' is specified for a feature, then a single + * lag feature is generated. Example: [1,2] * * 'num_lags': integer, if specified, generates the specified amount of lag features containing previous values. - * if 'lags' is specified, then this parameter will be ignored. if neither 'num_lags' nor 'lags' is specified - * for a feature, then a single lag feature is generated. default is 1. + * If 'lags' is specified, then this parameter will be ignored. If neither 'num_lags' nor 'lags' is specified + * for a feature, then a single lag feature is generated. Default is 1. * * 'rate_min': list of number, if specified, ensures that the rate (the difference quotient, the discrete version - * of derivative) for this feature won't be less than the value provided. a null value means no min boundary. - * the value must be in epoch format for the time feature. the length of the list must match the number of - * derivatives as specified by 'order'. only applicable when time series type is set to 'rate'. example: [0.1] + * of derivative) for this feature won't be less than the value provided. A null value means no min boundary. + * The value must be in epoch format for the time feature. The length of the list must match the number of + * derivatives as specified by 'order'. Only applicable when time series type is set to 'rate'. Example: [0.1] * * 'rate_max': list of number, if specified, ensures that the rate (the difference quotient, the discrete version - * of derivative) for this feature won't be more than the value provided. a null value means no max boundary. - * the value must be in epoch format for the time feature. the length of the list must match the number of - * derivatives as specified by 'order'. only applicable when time series type is set to 'rate'. example: [0.8] + * of derivative) for this feature won't be more than the value provided. A null value means no max boundary. + * The value must be in epoch format for the time feature. The length of the list must match the number of + * derivatives as specified by 'order'. Only applicable when time series type is set to 'rate'. Example: [0.8] * * 'delta_min': list of number, if specified, ensures that the smallest difference between features values is not smaller - * than this specified value. a null value means no min boundary. the length of the list must match the number of - * derivatives as specified by 'order'. only applicable when time series type is set to 'delta'. example: [0.2] + * than this specified value. A null value means no min boundary. The length of the list must match the number of + * derivatives as specified by 'order'. Only applicable when time series type is set to 'delta'. Example: [0.2] * * 'delta_max': list of number, if specified, ensures that the largest difference between feature values is not larger than - * this specified value. a null value means no max boundary. the length of the list must match the number of - * derivatives as specified by 'order'. only applicable when time series type is set to 'delta'. example: [2.0] + * this specified value. A null value means no max boundary. The length of the list must match the number of + * derivatives as specified by 'order'. Only applicable when time series type is set to 'delta'. Example: [2.0] * * 'series_has_terminators': boolean, when true, requires that the model identify and learn values that explicitly denote - * the end of a series. only applicable to id features for a series. default is false + * the end of a series. Only applicable to id features for a series. Default is false * * 'stop_on_terminator': boolean, when true, requires that a series ends on a terminator value. - * only applicable to id features for a series. default is false + * Only applicable to id features for a series. Default is false * * 'universal': boolean, applicable only to the time_feature, controls whether future values of independent time series are considered. - * when false, time_feature is not universal and allows using future data from other series in decisions; + * When false, time_feature is not universal and allows using future data from other series in decisions; * this is applicable when the time is not globally relevant and is independent for each time series. - * when true, universally excludes using any data with from the future from all series; + * When true, universally excludes using any data with from the future from all series; * this is applicable when time is globally relevant and there are events that may affect all time series. - * if there is any possibility of global relevancy of time, it is generally recommended to set this value to true, which is the default. + * If there is any possibility of global relevancy of time, it is generally recommended to set this value to true, which is the default. */ feature_attributes: FeatureAttributesIndex; }; diff --git a/src/types/schemas/SetInfluenceWeightThreshold.ts b/src/types/schemas/SetInfluenceWeightThreshold.ts index 6f89047..acf4e67 100644 --- a/src/types/schemas/SetInfluenceWeightThreshold.ts +++ b/src/types/schemas/SetInfluenceWeightThreshold.ts @@ -1,12 +1,14 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * SetInfluenceWeightThreshold * - * Set the influence weight threshold for outputting only the k neighbors whose influence weight is <= to this threshold + * Set the influence weight threshold for outputting only the K neighbors whose influence weight is <= to this threshold * default value is 0.99 */ +/** Request parameters of the Trainee method: setInfluenceWeightThreshold. */ export type SetInfluenceWeightThresholdRequest = { /** * Number, amount of total influence weight to accumulate among nearest diff --git a/src/types/schemas/SetMetadata.ts b/src/types/schemas/SetMetadata.ts index 5c4f974..118739a 100644 --- a/src/types/schemas/SetMetadata.ts +++ b/src/types/schemas/SetMetadata.ts @@ -1,11 +1,13 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * SetMetadata * * Set metadata for model */ +/** Request parameters of the Trainee method: setMetadata. */ export type SetMetadataRequest = { /** * Arbitary map of metadata to store in a trainee diff --git a/src/types/schemas/SetParams.ts b/src/types/schemas/SetParams.ts index b9faf42..67190a5 100644 --- a/src/types/schemas/SetParams.ts +++ b/src/types/schemas/SetParams.ts @@ -1,13 +1,15 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * SetParams * * Sets internal hyperparameters */ -import type { FullHyperparameterMap } from "./FullHyperparameterMap"; import type { HyperparameterMap } from "./HyperparameterMap"; +import type { HyperparameterMapTree } from "./HyperparameterMapTree"; +/** Request parameters of the Trainee method: setParams. */ export type SetParamsRequest = { /** * The factor by which to increase the analyze threshold everytime the model grows to the current threshold size @@ -37,10 +39,10 @@ export type SetParamsRequest = { * Must have at least an action feature (e.g., .targetless) -> a contexts key -> robust -> k, p and dt provided. * example: * { - * ".targetless" { "featurea.featureb.": { "robust" : { "k" : number, "p" : number, "dt": number }}}, - * "featurea" : { "featureb.featurec.": { "full" : { "k" : number, "p" : number, "dt": number }}}, + * ".targetless" { "featureA.featureB.": { "robust" : { "k" : number, "p" : number, "dt": number }}}, + * "featureA" : { "featureB.featureC.": { "full" : { "k" : number, "p" : number, "dt": number }}}, * ... * } */ - hyperparameter_map?: FullHyperparameterMap; + hyperparameter_map?: HyperparameterMapTree; }; diff --git a/src/types/schemas/SetParentId.ts b/src/types/schemas/SetParentId.ts index 01c3de8..746117b 100644 --- a/src/types/schemas/SetParentId.ts +++ b/src/types/schemas/SetParentId.ts @@ -1,11 +1,13 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * SetParentId * * Set trainee's unique parent id */ +/** Request parameters of the Trainee method: setParentId. */ export type SetParentIdRequest = { /** * The unique string identifier for the parent of the trainee diff --git a/src/types/schemas/SetRandomSeed.ts b/src/types/schemas/SetRandomSeed.ts index 9bf863a..c081a57 100644 --- a/src/types/schemas/SetRandomSeed.ts +++ b/src/types/schemas/SetRandomSeed.ts @@ -1,11 +1,13 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * SetRandomSeed * * Set the random seed on a trainee */ +/** Request parameters of the Trainee method: setRandomSeed. */ export type SetRandomSeedRequest = { /** * The value of the random seed to set on the trainee, assigns a system-provided 64-bit random number if null is provided diff --git a/src/types/schemas/SetSessionMetadata.ts b/src/types/schemas/SetSessionMetadata.ts index 81dd715..af9477c 100644 --- a/src/types/schemas/SetSessionMetadata.ts +++ b/src/types/schemas/SetSessionMetadata.ts @@ -1,11 +1,13 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * SetSessionMetadata * * Set session metadata for a specified session. */ +/** Request parameters of the Trainee method: setSessionMetadata. */ export type SetSessionMetadataRequest = { /** * Any arbitrary metadata. diff --git a/src/types/schemas/SetSubstituteFeatureValues.ts b/src/types/schemas/SetSubstituteFeatureValues.ts index 3c9fa9f..ac89422 100644 --- a/src/types/schemas/SetSubstituteFeatureValues.ts +++ b/src/types/schemas/SetSubstituteFeatureValues.ts @@ -1,16 +1,18 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * SetSubstituteFeatureValues * * Sets substitution feature values used in case generation */ +/** Request parameters of the Trainee method: setSubstituteFeatureValues. */ export type SetSubstituteFeatureValuesRequest = { /** * Assoc of feature -> assoc of value -> substitution. - * if this map is null, all substitutions will be disabled and cleared - * if any feature in the substitution_value_map has a missing or empty assoc of substitutions, substitution values will immeditally be generated + * If this map is null, all substitutions will be disabled and cleared + * If any feature in the substitution_value_map has a missing or empty assoc of substitutions, substitution values will immeditally be generated */ substitution_value_map: Record; }; diff --git a/src/types/schemas/SetTraineeId.ts b/src/types/schemas/SetTraineeId.ts index 9afc76c..db942d7 100644 --- a/src/types/schemas/SetTraineeId.ts +++ b/src/types/schemas/SetTraineeId.ts @@ -1,11 +1,13 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * SetTraineeId * * Set trainee's unique id */ +/** Request parameters of the Trainee method: setTraineeId. */ export type SetTraineeIdRequest = { /** * A unique string identifier for the trainee diff --git a/src/types/schemas/SimilarCaseIndex.ts b/src/types/schemas/SimilarCaseIndex.ts new file mode 100644 index 0000000..2c6363c --- /dev/null +++ b/src/types/schemas/SimilarCaseIndex.ts @@ -0,0 +1,13 @@ +/** + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. + */ + +/** + * Map describing a case similar to the case being reacted to. Includes the distance from the query case, session, and index. + */ +export type SimilarCaseIndex = { + ".distance"?: number; + ".session"?: string; + ".session_training_index"?: number; +}; diff --git a/src/types/schemas/SingleReact.ts b/src/types/schemas/SingleReact.ts deleted file mode 100644 index c9f3d81..0000000 --- a/src/types/schemas/SingleReact.ts +++ /dev/null @@ -1,206 +0,0 @@ -/** - * WARNING: This file is auto generated, do not modify manually. - * - * SingleReact - * - * React to a provided context. if desired_conviction is provided, it does a generative react. - * - * output: - * default output of this method is a react object in the format of - * , where all_action_values is a list of all action - * values, reacted/generated and derived, in the same order as all_action_features, e.g., [2, "a", .75384] to match ['width','name','height'] - * if details is specified, the react object will contain appropriate additional details properties and values, - * details example: { 'action_values': [2, "a", .75384], 'action_features' : ['width','name','height'], 'residual_conviction': 1.3, - * 'influential_cases' : etc... } - * see api docs for documentation of all output properties - */ -import type { DesiredConviction } from "./DesiredConviction"; -import type { FeatureBoundsMap } from "./FeatureBoundsMap"; -import type { GenerateNewCases } from "./GenerateNewCases"; -import type { NewCaseThreshold } from "./NewCaseThreshold"; -import type { ReactDetails } from "./ReactDetails"; -import type { UseCaseWeights } from "./UseCaseWeights"; - -export type SingleReactRequest = { - /** - * Full list of features to output values for the case - * @default [] - */ - action_features?: string[]; - - /** - * Values of action features. if specified will bypass react and only do the explanation if details is set - * @default [] - */ - action_values?: any[]; - - /** - * Flag, if set to true will allow return of null values if there are nulls in the local model for the action features. applicable - * only to discriminative reacts. - * @default false - */ - allow_nulls?: boolean; - - /** - * Pair (list) of session id and index, where index is the original 0-based session_training_index of the case as it was - * trained into the session. if this case does not exist, discriminative react outputs null, generative react ignores it. - */ - case_indices?: (string | number)[]; - - /** - * List of context features. for generative react, features used to condition the generated case - * @default [] - */ - context_features?: string[]; - - /** - * List of context values, for generative react, values used to condition the generated case - * @default [] - */ - context_values?: any[]; - - /** - * List of action features whose values should be computed from the resulting action prior to output, in the specified - * order. must be a subset of action_features. - * note: both of these derived feature lists rely on the features' "derived_feature_code" attribute to compute the values. - * if 'derived_feature_code' attribute is undefined or references non-0 feature indices, the derived value will be null. - * @default [] - */ - derived_action_features?: string[]; - - /** - * List of context features whose values should be computed from the provided contexts in the specified order. - * must be different than context_features. - * @default [] - */ - derived_context_features?: string[]; - - /** - * If null, will do a discriminative react. if specified, will do a generative react - * for generative react, value of desired avg conviction of generated cases, in the range of (0,infinity] with 1 as standard - * larger values will increase the variance (or creativity) of the generated case from the existing model - * smaller values will decrease the variance (or creativity) of the generated case from the existing model - */ - desired_conviction?: DesiredConviction; - - /** - * See the description of the details parameter of #react - */ - details?: ReactDetails; - - /** - * If true will exclude sensitive features whose values will be - * replaced after synthesis from uniqueness check. - * only applicable when desired_conviction is specified. - * @default false - */ - exclude_novel_nominals_from_uniqueness_check?: boolean; - - /** - * List of additional features to return with audit data - * @default [] - */ - extra_features?: string[]; - - /** - * Assoc of : - * to ensure that specified features' generated values stay in bounds - * for nominal features instead of min/max it's a set of allowed values, ie: - * allow_null - default is true, if true nulls may be generated per their distribution in the data - * only used when desired_conviction is specified - * @default {} - */ - feature_bounds_map?: Record; - - /** - * Enum, acceptable values are: - * null or 'no' : output any generated case - * 'always' : only output original cases, outputs null for all feature values if unable to generate a new case - * 'attempt' : output any generated case only if generation fails all initial attempts to output original cases - * @default "no" - */ - generate_new_cases?: GenerateNewCases; - - /** - * Case_id, if set will query for k+1 cases and ignore the perfect matching case during the reaction - */ - ignore_case?: string; - - /** - * Flag, if set to true assumes provided categorical (nominal or ordinal) feature values already been substituted. - * @default false - */ - input_is_substituted?: boolean; - - /** - * Series id, if specified will store an internal record of all reacts for that series - */ - into_series_store?: string; - - /** - * Flag, if set to true and specified along with case_indices, will set ignore_case to the one specified by case_indices. - */ - leave_case_out?: boolean; - - /** - * Distance to determine privacy cutoff. used to query the local minimum distance used in the distance ratio - * accepted values: - * 'max': the maximum local distance - * 'min': the minimum local distance - * 'most_similar': the closest distance of the most similar case - * null: the minimum local distance - * @default "min" - */ - new_case_threshold?: NewCaseThreshold; - - /** - * Flag, if true order of generated feature values will match the order of features - * @default false - */ - ordered_by_specified_features?: boolean; - - /** - * List of feature names that will be made available during the execution of post_process feature attributes - * @default [] - */ - post_process_features?: string[]; - - /** - * List of values corresponding to post_process_features that will be made available during the execution fo post_process feature attributes - * @default [] - */ - post_process_values?: any[]; - - /** - * List of features that will preserve their values from the case specified by case_indices, appending and - * overwriting the specified context and context features as necessary. for generative reacts, if case_indices isn't specified, - * will preserve feature values of a random case. - * @default [] - */ - preserve_feature_values?: string[]; - - /** - * Flag, default is true, only applicable if a substitution value map has been set. if set to false, will not substitute categorical feature values. - * only used when desired_conviction is specified - * @default true - */ - substitute_output?: boolean; - - /** - * Flag, if set to true will scale influence weights by each case's weight_feature weight. - * if a weight is missing, uses 1 as the weight. if unspecified, case weights will be used if the trainee has them. - */ - use_case_weights?: UseCaseWeights; - - /** - * Flag, if false uses model feature residuals, if true recalculates regional model residuals. only used when desired_conviction is specified - * @default true - */ - use_regional_model_residuals?: boolean; - - /** - * Name of feature whose values to use as case weights - * @default ".case_weight" - */ - weight_feature?: string; -}; diff --git a/src/types/schemas/SingleReactSeries.ts b/src/types/schemas/SingleReactSeries.ts deleted file mode 100644 index 94455ea..0000000 --- a/src/types/schemas/SingleReactSeries.ts +++ /dev/null @@ -1,212 +0,0 @@ -/** - * WARNING: This file is auto generated, do not modify manually. - * - * SingleReactSeries - * - * React in a series until a series_stop_map condition is met. aggregates rows of data corresponding to the specified context, action, - * derived_context and derived_action features, utilizing previous rows to derive values as necessary. outputs an assoc of "action_features" and - * corresponding "series" where "series" is the completed 'matrix' for the corresponding action_features and derived_action_features. - */ -import type { DesiredConviction } from "./DesiredConviction"; -import type { FeatureBoundsMap } from "./FeatureBoundsMap"; -import type { GenerateNewCases } from "./GenerateNewCases"; -import type { UseCaseWeights } from "./UseCaseWeights"; - -export type SingleReactSeriesRequest = { - /** - * List of feature names corresponding to values in each row of action_values - * @default [] - */ - action_features?: string[]; - - /** - * List of predicted feature values for non time-series features - * @default [] - */ - action_values?: any[]; - - /** - * List of feature names corresponding to values in each row of context_values - * @default [] - */ - context_features?: string[]; - - /** - * List of context feature values for non time-series features - * @default [] - */ - context_values?: any[]; - - /** - * Flag, default is false. when true will attempt to continue existing series instead of starting new series. - * if initial_values provide series ids, it will continue those explicitly specified ids, otherwise it will randomly select series to continue. - * note: terminated series with terminators cannot be continued and will result in null output. - * @default false - */ - continue_series?: boolean; - - /** - * List of features corresponding to the values in each row of continue_series_values. - * this value is ignored if continue_series_values is not specified. - */ - continue_series_features?: string[]; - - /** - * List of lists of values, when specified will continue this specific untrained series as defined by these values. - * continue_series flag will be ignored and treated as true if this value is specified. - */ - continue_series_values?: any[][]; - - /** - * List of action features whose values should be computed from the resulting last row in series, in the specified - * order. must be a subset of action_features. - * note: both of these derived feature lists rely on the features' "derived_feature_code" attribute to compute the values. - * if 'derived_feature_code' attribute is undefined or references non-existing feature indices, the derived value will be null. - * @default [] - */ - derived_action_features?: string[]; - - /** - * List of context features whose values should be computed from the entire series in the specified order. - * must be different than context_features. - * @default [] - */ - derived_context_features?: string[]; - - /** - * If null, will do a discriminative react. if specified, will do a generative react - * for generative react, value of desired avg conviction of generated cases, in the range of (0,infinity] with 1 as standard - * larger values will increase the variance (or creativity) of the generated case from the existing model - * smaller values will decrease the variance (or creativity) of the generated case from the existing model - */ - desired_conviction?: DesiredConviction; - - /** - * List of additional features to return with audit data from details - * @default [] - */ - extra_features?: string[]; - - /** - * Assoc of : - * to ensure that specified features' generated values stay in bounds - * for nominal features instead of min/max it's a set of allowed values, ie: - * allow_null - default is true, if true nulls may be generated per their distribution in the data - * @default {} - */ - feature_bounds_map?: Record; - - /** - * Enum, acceptable values are: - * null or 'no' : output any generated case - * 'always' : only output original cases, outputs null for all feature values if unable to generate a new case - * 'attempt' : output any generated case only if generation fails all initial attempts to output original cases - * @default "no" - */ - generate_new_cases?: GenerateNewCases; - - /** - * List of features to condition just the first case in a series, overwrites context_features and - * derived_context_features for that first case. all specified initial features must be in one of: context_features, action_features, - * derived_context_features or derived_action_features. if provided a value that isn't in one of those lists, it will be ignored. - * @default [] - */ - initial_features?: string[]; - - /** - * List of values corresponding to the initial_features, used to condition just the first case in a series. - */ - initial_values?: any[]; - - /** - * Flag, if set to true assumes provided categorical (nominal or ordinal) feature values already been substituted. - * @default false - */ - input_is_substituted?: boolean; - - /** - * Maximum size a series is allowed to be. default is 3 * model_size, a 0 or less is no limit. - * if forecasting with 'continue_series', this defines the maximum length of the forecast. - */ - max_series_length?: number; - - /** - * Distance to determine privacy cutoff. used to query the local minimum distance used in the distance ratio - * accepted values: - * 'max': the maximum local distance - * 'min': the minimum local distance - * 'most_similar': the closest distance of the most similar case - * null: the minimum local distance - * @default "min" - */ - new_case_threshold?: string; - - /** - * Flag, default to true. if true, series ids are replaced with unique values on output. - * if false, will maintain or replace ids with existing trained values, but also allows output of series with duplicate existing ids. - * @default true - */ - output_new_series_ids?: boolean; - - /** - * List of features that will preserve their values from the case specified by case_indices, appending and - * overwriting the specified context and context features as necessary. for generative reacts, if case_indices isn't specified, - * will preserve feature values of a random case. - * @default [] - */ - preserve_feature_values?: string[]; - - /** - * List of features corresponding to series_context_values - * @default [] - */ - series_context_features?: string[]; - - /** - * 2d-list of values, context value for each feature for each row of the series. - * if specified, max_series_length is ignored. - * @default [] - */ - series_context_values?: any[][]; - - /** - * Controls how closely generated series should follow existing series (plural). - * choices are: "fixed", "dynamic" or "no". if "fixed", tracks the particular relevant series id. if "dynamic", tracks the particular - * relevant series id, but is allowed to change the series id that it tracks based on its current context. if "no", does not track any particular series id. - * @default "fixed" - */ - series_id_tracking?: "fixed" | "dynamic" | "no"; - - /** - * Assoc of feature -> stop conditions: - * for continuous features: { feature: { "min" : val, "max": val } } - stops series when feature value exceeds max or is smaller than min - * for nominal features: { feature: { "values" : ['val1', 'val2' ]} } - stops series when feature value matches any of the values listed - * specifying ".series_progress" with a value between 0 and 1.0 corresponding to percent completion e.g., { ".series_progress" : .95 } - - * stops series when it progresses at or beyond 95%. - * @default {} - */ - series_stop_map?: Record; - - /** - * Flag, default is true, only applicable if a substitution value map has been set. if set to false, will not substitute categorical feature values. - * @default true - */ - substitute_output?: boolean; - - /** - * Flag, whether to use case weights or not. if unspecified will automatically select based on cached parameters - */ - use_case_weights?: UseCaseWeights; - - /** - * Flag, if false uses model feature residuals, if true recalculates regional model residuals. - * @default true - */ - use_regional_model_residuals?: boolean; - - /** - * Name of the feature that stores case weights - * @default ".case_weight" - */ - weight_feature?: string; -}; diff --git a/src/types/schemas/Train.ts b/src/types/schemas/Train.ts index 05049f6..97013c9 100644 --- a/src/types/schemas/Train.ts +++ b/src/types/schemas/Train.ts @@ -1,24 +1,16 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * Train * - * Train the passed in cases, filtering out cases that match optionally passed in ablation parameters - * returns a response object in the following format: - * (associate - * "num_trained" num_trained_cases - * "ablated_indices" (list of session training indices for the ablated cases) - * "status" "status output message" - * ) - * list of 'status' values: - * (null) - default output, no status output - * "analyzed" - if auto analysis is enabled and model has grown large enough to be analyzed again and was analyzed - * "analyze" - if auto analysis is enabled and model has grown large enough to be analyzed again but was not analyzed + * Train the provided cases, filtering out cases that match optionally passed in ablation parameters. */ +/** Request parameters of the Trainee method: train. */ export type TrainRequest = { /** - * Name of feature into which to accumulate neighbors' influences as weight for ablated cases. if unspecified, will not accumulate weights. + * Name of feature into which to accumulate neighbors' influences as weight for ablated cases. If unspecified, will not accumulate weights. */ accumulate_weight_feature?: string; @@ -34,9 +26,9 @@ export type TrainRequest = { cases: any[][]; /** - * List of features to derive in the specified order. if this list is not provided, features with - * the 'auto_derive_on_train' feature attribute set to true will be auto-derived. if provided an empty list, will not derive any features. - * any derived_features that are already in the 'features' list will not be derived since their values are being explicitly provided. + * List of features to derive in the specified order. If this list is not provided, features with + * the 'auto_derive_on_train' feature attribute set to True will be auto-derived. If provided an empty list, will not derive any features. + * Any derived_features that are already in the 'features' list will not be derived since their values are being explicitly provided. */ derived_features?: string[]; @@ -52,16 +44,16 @@ export type TrainRequest = { input_is_substituted?: boolean; /** - * Name of series to pull features and case values from internal series storage. if specified, trains on all cases that are - * stored in the internal series store for the specified series and session. the trained feature set is the combined features from storage - * and the passed in features. if input_cases is of length one, the value(s) of this case are appended to all cases in the series. - * if input_cases is the same length as the series, the value of each case in input_cases is applied in order to each of the cases in the + * Name of series to pull features and case values from internal series storage. If specified, trains on all cases that are + * stored in the internal series store for the specified series and session. The trained feature set is the combined features from storage + * and the passed in features. If input_cases is of length one, the value(s) of this case are appended to all cases in the series. + * If input_cases is the same length as the series, the value of each case in input_cases is applied in order to each of the cases in the * series. */ series?: string; /** - * The session label to record these cases to. if not specified, refers to this entity's label of same name. + * The session label to record these cases to. If not specified, refers to this entity's label of same name. */ session?: string; @@ -77,3 +69,23 @@ export type TrainRequest = { */ train_weights_only?: boolean; }; + +/** Response of the Trainee method: train. */ +export type TrainResponse = { + /** + * The session training indices for the ablated cases. + */ + ablated_indices?: number[]; + /** + * The number of trained cases. + */ + num_trained: number; + /** + * The status output. + * + * - (null): No status output. This is the default. + * - analyzed: If auto analysis is enabled and model has grown large enough to be analyzed again and was analyzed. + * - analyze: If auto analysis is enabled and model has grown large enough to be analyzed again but was not analyzed. + */ + status: "analyze" | "analyzed" | null; +}; diff --git a/src/types/schemas/TypeDefinition.ts b/src/types/schemas/TypeDefinition.ts new file mode 100644 index 0000000..c68005f --- /dev/null +++ b/src/types/schemas/TypeDefinition.ts @@ -0,0 +1,132 @@ +/** + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. + */ +import type { TypeSchema } from "./TypeSchema"; +import type { TypeString } from "./TypeString"; + +/** + * A description of a type that the values of the described value should conform to. + */ +export type TypeDefinition = { + /** + * The expected type of values pointed to by any unnamed indices when the structure is an (assoc). + */ + additional_indices?: TypeSchema | boolean; + any_of?: TypeSchema[]; + /** + * The default value. Only used when describing a parameter. + */ + default?: any; + /** + * A description of the type and the meaning of the value. + */ + description?: string; + /** + * A map of patterned keys to their expected types. + */ + dynamic_indices?: Record; + /** + * A list of possible values when the type is a string. + */ + enum?: string[]; + /** + * The exclusive maximum value when the type is a number. + */ + exclusive_max?: number; + /** + * The exclusive minimum value when the type is a number. + */ + exclusive_min?: number; + /** + * A map of named indices to the types expected of their values when the structure is an (assoc). + */ + indices?: Record; + /** + * The inclusive maximum value when the type is a number. + */ + max?: number; + /** + * The inclusive maximum number of indices when the type is a (assoc). + */ + max_indices?: number; + /** + * The exclusive maximum value when the type is a (list). + */ + max_size?: number; + /** + * The inclusive minimum value when the type is a number. + */ + min?: number; + /** + * The inclusive minimum number of indices when the type is a (assoc). + */ + min_indices?: number; + /** + * The inclusive minimum size when the type is a (list). + */ + min_size?: number; + /** + * A reference to a named schema to use the type definition there. + */ + ref?: + | "AblationThresholdMap" + | "BuiltInFeatures" + | "Case" + | "CaseIndices" + | "CaseMDA" + | "Cases" + | "CategoricalActionProbabilities" + | "Condition" + | "ConfusionMatrix" + | "DerivationParameters" + | "DesiredConviction" + | "DistanceRatioParts" + | "EditHistory" + | "EditHistoryRecord" + | "FeatureAttributes" + | "FeatureAttributesIndex" + | "FeatureBounds" + | "FeatureDataType" + | "FeatureMetricIndex" + | "FeatureOriginalType" + | "FeatureOriginalTypeBoolean" + | "FeatureOriginalTypeDate" + | "FeatureOriginalTypeDatetime" + | "FeatureOriginalTypeInteger" + | "FeatureOriginalTypeNumeric" + | "FeatureOriginalTypeObject" + | "FeatureOriginalTypeString" + | "FeatureOriginalTypeTime" + | "FeatureOriginalTypeTimedelta" + | "FeatureType" + | "FullCaseContribution" + | "GenerateNewCases" + | "HyperparameterMap" + | "HyperparameterMapTree" + | "NewCaseThreshold" + | "OutlyingFeatureValuesIndex" + | "Precision" + | "PredictionStat" + | "ReactAggregateDetails" + | "ReactDetails" + | "ReactionPredictionStats" + | "RobustCaseContribution" + | "SimilarCaseIndex" + | "TypeDefinition" + | "TypeSchema" + | "TypeString" + | "UseCaseWeights"; + /** + * Flag indicating if the value is required to be specified as not (null). + */ + required?: boolean; + /** + * The type of data. The string name of the type or a list of possible types. + */ + type?: TypeString | TypeString[]; + /** + * The expected type of the structure's values when the structure is a (list). + */ + values?: TypeSchema; +}; diff --git a/src/types/schemas/TypeSchema.ts b/src/types/schemas/TypeSchema.ts new file mode 100644 index 0000000..d3cd22c --- /dev/null +++ b/src/types/schemas/TypeSchema.ts @@ -0,0 +1,11 @@ +/** + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. + */ +import type { TypeDefinition } from "./TypeDefinition"; +import type { TypeString } from "./TypeString"; + +/** + * TypeSchema schema. + */ +export type TypeSchema = TypeString | TypeString[] | TypeDefinition; diff --git a/src/types/schemas/TypeString.ts b/src/types/schemas/TypeString.ts new file mode 100644 index 0000000..f14fd8e --- /dev/null +++ b/src/types/schemas/TypeString.ts @@ -0,0 +1,9 @@ +/** + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. + */ + +/** + * The string name of the type a value should be. + */ +export type TypeString = "any" | "assoc" | "boolean" | "list" | "null" | "number" | "string"; diff --git a/src/types/schemas/UpgradeTrainee.ts b/src/types/schemas/UpgradeTrainee.ts index e3cbd0c..e25f1e0 100644 --- a/src/types/schemas/UpgradeTrainee.ts +++ b/src/types/schemas/UpgradeTrainee.ts @@ -1,14 +1,16 @@ /** - * WARNING: This file is auto generated, do not modify manually. + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. * * UpgradeTrainee * * Update version to latest, auto importing any exported data. */ +/** Request parameters of the Trainee method: upgradeTrainee. */ export type UpgradeTraineeRequest = { /** - * Base path to howso engine core installation + * Base path to Howso Engine Core installation */ root_filepath?: string; @@ -25,7 +27,7 @@ export type UpgradeTraineeRequest = { /** * Path from which to load previously exported meta.json and exp.json files. - * if unspecified, expects them to be located in the base installation /migrations/ directory. + * If unspecified, expects them to be located in the base installation /migrations/ directory. */ trainee_json_filepath?: string; }; diff --git a/src/types/schemas/UseCaseWeights.ts b/src/types/schemas/UseCaseWeights.ts index 105b4ec..c1d6848 100644 --- a/src/types/schemas/UseCaseWeights.ts +++ b/src/types/schemas/UseCaseWeights.ts @@ -1,10 +1,9 @@ /** - * WARNING: This file is auto generated, do not modify manually. - * - * UseCaseWeights + * 🛑 WARNING: DO NOT EDIT! 🛑 + * This file is auto generated and should not be modified directly. */ /** - * If set to true will scale influence weights by each case's weight_feature weight. if null, case weights will be used if the trainee has them. + * If set to true will scale influence weights by each case's weight_feature weight. If null, case weights will be used if the trainee has them. */ export type UseCaseWeights = boolean | null; diff --git a/src/types/schemas/index.ts b/src/types/schemas/index.ts index d40e9a0..3ea4aa0 100644 --- a/src/types/schemas/index.ts +++ b/src/types/schemas/index.ts @@ -6,14 +6,21 @@ export * from "./AddFeature"; export * from "./Analyze"; export * from "./AppendToSeriesStore"; export * from "./BuiltInFeatures"; +export * from "./Case"; export * from "./CaseIndices"; +export * from "./CaseMDA"; +export * from "./Cases"; +export * from "./CategoricalActionProbabilities"; export * from "./ClearImputedData"; export * from "./Condition"; +export * from "./ConfusionMatrix"; export * from "./CopySubtrainee"; export * from "./CreateSubtrainee"; export * from "./DeleteSession"; export * from "./DeleteSubtrainee"; +export * from "./DerivationParameters"; export * from "./DesiredConviction"; +export * from "./DistanceRatioParts"; export * from "./EditCases"; export * from "./EditHistory"; export * from "./EditHistoryRecord"; @@ -22,26 +29,47 @@ export * from "./ExecuteOnSubtrainee"; export * from "./ExportTrainee"; export * from "./FeatureAttributes"; export * from "./FeatureAttributesIndex"; -export * from "./FeatureBoundsMap"; -export * from "./FullHyperparameterMap"; +export * from "./FeatureBounds"; +export * from "./FeatureDataType"; +export * from "./FeatureMetricIndex"; +export * from "./FeatureOriginalType"; +export * from "./FeatureOriginalTypeBoolean"; +export * from "./FeatureOriginalTypeDate"; +export * from "./FeatureOriginalTypeDatetime"; +export * from "./FeatureOriginalTypeInteger"; +export * from "./FeatureOriginalTypeNumeric"; +export * from "./FeatureOriginalTypeObject"; +export * from "./FeatureOriginalTypeString"; +export * from "./FeatureOriginalTypeTime"; +export * from "./FeatureOriginalTypeTimedelta"; +export * from "./FeatureType"; +export * from "./FullCaseContribution"; export * from "./GenerateNewCases"; +export * from "./GetAutoAblationParams"; export * from "./GetCases"; export * from "./GetDistances"; export * from "./GetEntityPathById"; export * from "./GetExtremeCases"; export * from "./GetFeatureConviction"; +export * from "./GetHierarchy"; export * from "./GetMarginalStats"; +export * from "./GetMetadata"; +export * from "./GetNumTrainingCases"; export * from "./GetPairwiseDistances"; export * from "./GetParams"; +export * from "./GetRevision"; export * from "./GetSessionIndices"; export * from "./GetSessionMetadata"; export * from "./GetSessionTrainingIndices"; export * from "./GetSessions"; +export * from "./GetSubstituteFeatureValues"; export * from "./HyperparameterMap"; +export * from "./HyperparameterMapTree"; export * from "./Impute"; export * from "./LoadSubtrainee"; export * from "./MoveCases"; export * from "./NewCaseThreshold"; +export * from "./OutlyingFeatureValuesIndex"; export * from "./Precision"; export * from "./PredictionStat"; export * from "./React"; @@ -51,13 +79,14 @@ export * from "./ReactDetails"; export * from "./ReactGroup"; export * from "./ReactIntoFeatures"; export * from "./ReactSeries"; +export * from "./ReactionPredictionStats"; export * from "./ReduceData"; export * from "./RemoveCases"; export * from "./RemoveFeature"; export * from "./RemoveSeriesStore"; export * from "./RenameSubtrainee"; +export * from "./RobustCaseContribution"; export * from "./SaveSubtrainee"; -export * from "./SelectedPredictionStats"; export * from "./SetAutoAblationParams"; export * from "./SetAutoAnalyzeParams"; export * from "./SetFeatureAttributes"; @@ -69,8 +98,10 @@ export * from "./SetRandomSeed"; export * from "./SetSessionMetadata"; export * from "./SetSubstituteFeatureValues"; export * from "./SetTraineeId"; -export * from "./SingleReact"; -export * from "./SingleReactSeries"; +export * from "./SimilarCaseIndex"; export * from "./Train"; +export * from "./TypeDefinition"; +export * from "./TypeSchema"; +export * from "./TypeString"; export * from "./UpgradeTrainee"; export * from "./UseCaseWeights"; diff --git a/src/types/shims/FeatureOriginalType.ts b/src/types/shims/FeatureOriginalType.ts deleted file mode 100644 index 88f2fde..0000000 --- a/src/types/shims/FeatureOriginalType.ts +++ /dev/null @@ -1,112 +0,0 @@ -export interface OriginalTypeBoolean { - /** - * The name of the data type. - */ - data_type: "boolean"; -} - -export interface OriginalTypeDatetime { - /** - * The name of the data type. - */ - data_type: "datetime"; - /** - * The standardized timezone name. - */ - timezone?: string | null; -} - -export interface OriginalTypeDate { - /** - * The name of the data type. - */ - data_type: "date"; -} - -export interface OriginalTypeInteger { - /** - * The name of the data type. - */ - data_type: "integer"; - /** - * The size of the integer (in bytes). - */ - size?: number; - /** - * If the integer is unsigned. - */ - unsigned?: boolean; -} - -export interface OriginalTypeNumeric { - /** - * The name of the data type. - */ - data_type: "numeric"; - /** - * The format of the number. - */ - format?: "decimal"; - /** - * The size of the number (in bytes). - */ - size?: number; -} - -export interface OriginalTypeObject { - /** - * The name of the data type. - */ - data_type: "object"; -} - -export interface OriginalTypeString { - /** - * The name of the data type. - */ - data_type: "string"; - /** - * The maximum allowed length of the string. - */ - length?: number | null; - /** - * The string encoding type. - */ - encoding?: string | null; -} - -export interface OriginalTypeTime { - /** - * The name of the data type. - */ - data_type: "time"; - /** - * The standardized timezone name. - */ - timezone?: string | null; -} - -export interface OriginalTypeTimedelta { - /** - * The name of the data type. - */ - data_type: "timedelta"; - /** - * The unit of the time delta. - */ - unit?: "days" | "seconds" | "nanoseconds"; -} - -/** - * Original data type details. Used by clients to determine how to serialize and deserialize feature data. - */ -export type FeatureOriginalType = - | OriginalTypeBoolean - | OriginalTypeDate - | OriginalTypeDatetime - | OriginalTypeInteger - | OriginalTypeNumeric - | OriginalTypeObject - | OriginalTypeString - | OriginalTypeTime - | OriginalTypeTimedelta; diff --git a/src/types/shims/GetMarginalStats.ts b/src/types/shims/GetMarginalStats.ts deleted file mode 100644 index 51dcdfe..0000000 --- a/src/types/shims/GetMarginalStats.ts +++ /dev/null @@ -1,34 +0,0 @@ -export type GetMarginalStatsResponse = { - [key: string]: { - /** Ex: null; */ - skew: number | null; - /** Ex: null; */ - min: number | null; - /** Ex: null; */ - mean: number | null; - /** Ex: null; */ - percentile_75: number | null; - /** Ex: 150; */ - count: number | null; - /** Ex: null; */ - variance: number | null; - /** Ex: null; */ - mean_absdev: number | null; - /** Ex: null; */ - stddev: number | null; - /** Ex: 3; */ - uniques: number | null; - /** Ex: null; */ - median: number | null; - /** Ex: 1.0986122886681096; */ - entropy: number | null; - /** Ex: null; */ - kurtosis: number | null; - /** Ex: "Iris-versicolor"; */ - mode: number | null; - /** Ex: null; */ - max: number | null; - /** Ex: null; */ - percentile_25: number | null; - }; -}; diff --git a/src/types/shims/GetParams.ts b/src/types/shims/GetParams.ts deleted file mode 100644 index 55089f2..0000000 --- a/src/types/shims/GetParams.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { FullHyperparameterMap, HyperparameterMap } from "../schemas"; - -export type GetParamsResponse = { - default_hyperparameter_map?: FullHyperparameterMap; - hyperparameter_map?: HyperparameterMap; - auto_analyze_enabled?: boolean; - auto_analyze_limit_size?: number; - analyze_growth_factor?: number; - analyze_threshold?: number; -}; diff --git a/src/types/shims/React.ts b/src/types/shims/React.ts deleted file mode 100644 index 4b5383b..0000000 --- a/src/types/shims/React.ts +++ /dev/null @@ -1,58 +0,0 @@ -export type ReactResponse = { - boundary_cases?: any[][]; - categorical_action_probabilities?: Array<{ [key: string]: any }>; - derivation_parameters?: Array<{ - k?: number; - p?: number; - distance_transform?: number; - feature_weights?: { [key: string]: number }; - feature_deviations?: { [key: string]: number }; - nominal_class_counts?: { [key: string]: number }; - use_irw?: boolean; - }>; - feature_residuals_full?: Array<{ [key: string]: any }>; - feature_residuals_robust?: Array<{ [key: string]: any }>; - prediction_stats?: Array<{ [key: string]: any }>; - outlying_feature_values?: Array<{ - [key: string]: { - input_case_value?: number; - local_max?: number; - }; - }>; - influential_cases?: any[][]; - most_similar_cases?: any[][]; - observational_errors?: Array<{ [key: string]: number }>; - feature_mda_full?: Array<{ [key: string]: number }>; - feature_mda_robust?: Array<{ [key: string]: number }>; - feature_mda_ex_post_full?: Array<{ [key: string]: number }>; - feature_mda_ex_post_robust?: Array<{ [key: string]: number }>; - directional_feature_contributions_full?: Array<{ [key: string]: number }>; - directional_feature_contributions_robust?: Array<{ [key: string]: number }>; - feature_contributions_full?: Array<{ [key: string]: number }>; - feature_contributions_robust?: Array<{ [key: string]: number }>; - case_directional_feature_contributions_full?: Array<{ [key: string]: number }>; - case_directional_feature_contributions_robust?: Array<{ [key: string]: number }>; - case_feature_contributions_full?: Array<{ [key: string]: number }>; - case_feature_contributions_robust?: Array<{ [key: string]: number }>; - case_mda_full?: Array>; - case_mda_robust?: Array>; - case_contributions_full?: Array>; - case_contributions_robust?: Array>; - case_feature_residuals_full?: Array<{ [key: string]: number }>; - case_feature_residuals_robust?: Array<{ [key: string]: number }>; - case_feature_residual_convictions_full?: Array<{ [key: string]: number }>; - case_feature_residual_convictions_robust?: Array<{ [key: string]: number }>; - hypothetical_values?: Array<{ [key: string]: any }>; - distance_ratio?: Array; - distance_ratio_parts?: Array<{ - local_distance_contribution?: number | null; - nearest_distance?: number | null; - }>; - distance_contribution?: Array; - similarity_conviction?: Array; - most_similar_case_indices?: Array>; - generate_attempts?: Array; - series_generate_attempts?: Array>; - action_features?: Array | null; - action_values?: Array> | null; -}; diff --git a/src/types/shims/ReactAggregate.ts b/src/types/shims/ReactAggregate.ts deleted file mode 100644 index b950909..0000000 --- a/src/types/shims/ReactAggregate.ts +++ /dev/null @@ -1,27 +0,0 @@ -export type ReactAggregateResponse = { - [key: string]: { - accuracy?: number | null; - confusion_matrix?: { - matrix?: { [key: string]: { [key: string]: number } }; - leftover_correct?: number; - leftover_incorrect?: number; - other_counts?: number; - }; - feature_contributions_full?: number | null; - feature_contributions_robust?: number | null; - mae?: number | null; - feature_residuals_full?: number | null; - feature_residuals_robust?: number | null; - feature_mda_full?: number | null; - feature_mda_robust?: number | null; - feature_mda_permutation_full?: number | null; - feature_mda_permutation_robust?: number | null; - precision?: number | null; - r2?: number | null; - recall?: number | null; - missing_value_accuracy?: number | null; - rmse?: number | null; - spearman_coeff?: number | null; - mcc?: number | null; - }; -}; diff --git a/src/types/shims/Train.ts b/src/types/shims/Train.ts deleted file mode 100644 index 238c6f3..0000000 --- a/src/types/shims/Train.ts +++ /dev/null @@ -1,5 +0,0 @@ -export type TrainResponse = { - ablated_indices?: number[]; - num_trained: number; - status?: "analyze" | "analyzed" | null; -}; diff --git a/src/types/shims/index.ts b/src/types/shims/index.ts deleted file mode 100644 index b68bebb..0000000 --- a/src/types/shims/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from "./FeatureOriginalType"; -export * from "./GetMarginalStats"; -export * from "./GetParams"; -export * from "./React"; -export * from "./ReactAggregate"; -export * from "./Train";