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

# Predict an answer per entity and date, from labelled examples



## OpenAPI

````yaml /api-reference/openapi.json post /v1/databases/{database_id}/predict
openapi: 3.1.0
info:
  title: tabSutra API
  version: '1.0'
  description: >-
    One pretrained model for forecasting, classification, regression and
    recommendation on tables and databases.
servers:
  - url: https://api.tabsutra.com
security:
  - bearerAuth: []
paths:
  /v1/databases/{database_id}/predict:
    post:
      summary: Predict an answer per entity and date, from labelled examples
      operationId: predict_database_v1_databases__database_id__predict_post
      parameters:
        - name: database_id
          in: path
          required: true
          schema:
            type: string
            title: Database Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DbPredictRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PredictResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    DbPredictRequest:
      properties:
        outputs:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Outputs
          description: >-
            classification: label, probabilities. regression: mean, median,
            quantiles, interval. Default: all of them.
        quantiles:
          items:
            type: number
          type: array
          title: Quantiles
          description: 'Regression: the levels (between 0 and 1) of the quantiles returned.'
          default:
            - 0.1
            - 0.5
            - 0.9
        coverage:
          type: number
          exclusiveMaximum: 1
          exclusiveMinimum: 0
          title: Coverage
          description: >-
            Regression: the share of the predicted distribution the interval
            holds.
          default: 0.8
        entity_table:
          type: string
          title: Entity Table
          description: The table whose rows get an answer (customers, drivers, posts).
          examples:
            - customers
        entity_column:
          type: string
          title: Entity Column
          description: >-
            The column of the examples and of the rows to predict that holds the
            entity table's primary key.
          examples:
            - customer_id
        time_column:
          type: string
          title: Time Column
          description: >-
            The column of the examples and of the rows to predict that holds the
            date.
          examples:
            - date
        target:
          type: string
          title: Target
          description: The column of the examples that holds the answer.
          examples:
            - spend_next_30_days
        task:
          type: string
          enum:
            - classification
            - regression
          title: Task
          description: >-
            'classification' (a category: will the customer buy) or 'regression'
            (a number: how much).
        window_days:
          type: number
          exclusiveMinimum: 0
          title: Window Days
          description: >-
            The answer is about the window_days days after the date; an
            example's answer is known that long after its date.
          examples:
            - 30
        exclude_columns:
          items:
            type: string
          type: array
          title: Exclude Columns
          description: >-
            'table.column' entries the model must not read (a column that holds
            the answer itself).
          examples:
            - - customers.lifetime_value
        examples:
          items:
            additionalProperties: true
            type: object
          type: array
          title: Examples
          description: >-
            Labelled examples: entity, date, answer. Only those dated before the
            first row to predict are used, and a row reads those whose answer
            was known before that.
        rows:
          items:
            additionalProperties: true
            type: object
          type: array
          title: Rows
          description: 'The rows to predict: entity and date.'
        id_column:
          anyOf:
            - type: string
            - type: 'null'
          title: Id Column
          description: >-
            A column of the rows that keys the predictions (default: the row's
            position).
        target_range:
          anyOf:
            - prefixItems:
                - anyOf:
                    - type: number
                    - type: 'null'
                - anyOf:
                    - type: number
                    - type: 'null'
              type: array
              maxItems: 2
              minItems: 2
            - type: 'null'
          title: Target Range
          description: 'Regression: outputs are clipped to [low, high].'
        explain:
          type: boolean
          default: false
          title: Explain
          description: >-
            Add to each prediction the contribution of each input to it. See
            Explanations.
        explain_top:
          type: integer
          default: 10
          minimum: 1
          maximum: 100
          title: Explain Top
          description: The number of largest contributions returned per prediction.
        explain_class:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Explain Class
          description: >-
            Classification: the class whose probability is explained. Default:
            the predicted label.
      type: object
      required:
        - entity_table
        - entity_column
        - time_column
        - target
        - task
        - window_days
        - examples
        - rows
      title: DbPredictRequest
    PredictResponse:
      properties:
        predictions:
          items:
            additionalProperties: true
            type: object
          type: array
          title: Predictions
          description: >-
            One object per row, keyed by 'id' (the id column, or the row's
            position).
        report:
          additionalProperties: true
          type: object
          title: Report
      type: object
      required:
        - predictions
        - report
      title: PredictResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 'Your API key, sent as ''Authorization: Bearer <key>''.'

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.