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

# Compute model-agnostic feature importance weights

> Compute model-agnostic feature importance weights for the provided exogenous features. It takes a JSON as an input containing the historical data with exogenous features and the attribution method to use. No foundation model is involved. The response contains one normalized weight per feature.



## OpenAPI

````yaml /openapi.json post /v2/explain
openapi: 3.1.0
info:
  title: Nixtla Forecast API
  description: >-
    API for TimeGPT forecast. Just send your data as json and get results. We do
    the heavy lifting.
  version: 0.4.0
servers:
  - url: https://api.nixtla.io
security: []
paths:
  /v2/explain:
    post:
      summary: Compute model-agnostic feature importance weights
      description: >-
        Compute model-agnostic feature importance weights for the provided
        exogenous features. It takes a JSON as an input containing the
        historical data with exogenous features and the attribution method to
        use. No foundation model is involved. The response contains one
        normalized weight per feature.
      operationId: v2_explain_v2_explain_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ExplainInput'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExplainOutput'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    ExplainInput:
      properties:
        series:
          $ref: '#/components/schemas/SeriesWithExogenous'
        method:
          type: string
          enum:
            - granger
            - transfer_entropy
          title: Method
          description: >-
            Model-agnostic causal analysis method used by the /v2/explain
            endpoint. Options are: 'granger' (default) and 'transfer_entropy'.
          default: granger
      type: object
      required:
        - series
      title: ExplainInput
    ExplainOutput:
      properties:
        weights:
          items:
            type: number
          type: array
          title: Weights
        feature_names:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Feature Names
        method:
          type: string
          title: Method
      type: object
      required:
        - weights
        - method
      title: ExplainOutput
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    SeriesWithExogenous:
      properties:
        X:
          anyOf:
            - items:
                items:
                  anyOf:
                    - type: number
                    - type: string
                type: array
              type: array
            - type: 'null'
          title: X
          description: >-
            Historic values of the exogenous features. Each feature must be a
            list of the same size as the target (y).
        categorical_exog:
          anyOf:
            - items:
                type: integer
                minimum: 0
              type: array
            - type: 'null'
          title: Categorical Exog
          description: >-
            Zero-based indices of the columns in X that are categorical
            features.
        'y':
          items:
            type: number
          type: array
          title: 'Y'
          description: Historic values of the target.
        sizes:
          items:
            type: integer
          type: array
          title: Sizes
          description: Sizes of the individual series.
        start_datetime:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Start Datetime
          description: >-
            Starting timestamp of each individual series, as ISO 8601 strings
            (for example '2021-01-01' or '2021-01-01T09:30:00'). One entry per
            series, so it must have the same length as `sizes`. Together with
            `sizes` and `freq` this recovers the timestamps of every series.
      type: object
      required:
        - 'y'
        - sizes
      title: SeriesWithExogenous
    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:
    HTTPBearer:
      type: http
      description: HTTPBearer
      scheme: bearer

````