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

# Tree-Based Regression (Decision Tree, Gradient Boosting)

> Fits tree-based regression models. Decision trees for interpretability and non-linear relationships, gradient boosting for maximum predictive power. Returns predictions and optional feature importances. [Tier: ENTERPRISE, Credits: 10]



## OpenAPI

````yaml api-specs/ml.json post /quantlib/ml/regression/tree
openapi: 3.1.0
info:
  title: FinceptQuantLib API - ML
  description: >-
    Machine Learning and Credit Risk module endpoints for FinceptQuantLib API.
    Pro Tier access required (5 credits per request). Covers credit scoring,
    model validation, regression models, clustering, anomaly detection, feature
    engineering, and preprocessing.
  version: 3.0.0
  contact:
    name: Fincept API Support
    url: https://fincept.in
servers:
  - url: https://api.fincept.in
    description: Fincept API Production Server
security:
  - APIKeyHeader: []
tags:
  - name: quantlib-ml
    description: Machine Learning and Credit Risk Analytics
    x-displayName: ML
paths:
  /quantlib/ml/regression/tree:
    post:
      tags:
        - quantlib-ml
      summary: Tree-Based Regression (Decision Tree, Gradient Boosting)
      description: >-
        Fits tree-based regression models. Decision trees for interpretability
        and non-linear relationships, gradient boosting for maximum predictive
        power. Returns predictions and optional feature importances. [Tier:
        ENTERPRISE, Credits: 10]
      operationId: tree_regression
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - X
                - 'y'
              properties:
                X:
                  type: array
                  description: Feature matrix
                  items:
                    type: array
                    items:
                      type: number
                  example:
                    - - 1.2
                      - 0.5
                      - 3.1
                    - - 2.1
                      - 1.3
                      - 2.5
                    - - 0.8
                      - 0.9
                      - 4.2
                'y':
                  type: array
                  description: Continuous target values
                  items:
                    type: number
                  example:
                    - 0.35
                    - 0.42
                    - 0.28
                method:
                  type: string
                  description: Tree method
                  enum:
                    - tree
                    - gradient_boosting
                  default: tree
                  example: gradient_boosting
                max_depth:
                  type: integer
                  description: Maximum tree depth
                  default: 5
                  example: 3
                n_estimators:
                  type: integer
                  description: Number of trees (for gradient boosting)
                  default: 100
                  example: 50
                learning_rate:
                  type: number
                  description: Learning rate (for gradient boosting)
                  default: 0.1
                  example: 0.05
                predict_X:
                  type: array
                  description: Optional feature matrix for prediction
                  items:
                    type: array
                    items:
                      type: number
                  example:
                    - - 1.5
                      - 0.7
                      - 3.3
      responses:
        '200':
          description: Tree regression results
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    properties:
                      predictions:
                        type: array
                        items:
                          type: number
                        example:
                          - 0.38
                      feature_importances:
                        type: array
                        items:
                          type: number
                        description: Feature importance scores (for gradient boosting)
                        example:
                          - 0.45
                          - 0.32
                          - 0.23
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '402':
          $ref: '#/components/responses/InsufficientCreditsError'
        '422':
          $ref: '#/components/responses/ValidationError'
components:
  responses:
    UnauthorizedError:
      description: Authentication information is missing or invalid
      content:
        application/json:
          schema:
            type: object
            properties:
              detail:
                type: string
                example: Invalid API key
    InsufficientCreditsError:
      description: Insufficient credits for this operation
      content:
        application/json:
          schema:
            type: object
            properties:
              detail:
                type: string
                example: Insufficient credits. This endpoint requires 5 credits.
    ValidationError:
      description: Request validation error
      content:
        application/json:
          schema:
            type: object
            properties:
              detail:
                type: array
                items:
                  type: object
                  properties:
                    loc:
                      type: array
                      items:
                        type: string
                    msg:
                      type: string
                    type:
                      type: string
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: X-API-Key
      description: >-
        API key for authentication. Get your key at
        https://api.fincept.in/auth/register

````