> ## 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.

# Principal Component Analysis (PCA)

> Reduces dimensionality while preserving variance. Transforms data into orthogonal components ordered by explained variance. Essential for feature reduction, visualization, and multicollinearity removal. [Tier: ENTERPRISE, Credits: 10]



## OpenAPI

````yaml api-specs/ml.json post /quantlib/ml/clustering/pca
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/clustering/pca:
    post:
      tags:
        - quantlib-ml
      summary: Principal Component Analysis (PCA)
      description: >-
        Reduces dimensionality while preserving variance. Transforms data into
        orthogonal components ordered by explained variance. Essential for
        feature reduction, visualization, and multicollinearity removal. [Tier:
        ENTERPRISE, Credits: 10]
      operationId: pca_transform
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - X
              properties:
                X:
                  type: array
                  description: Feature matrix (high-dimensional data)
                  items:
                    type: array
                    items:
                      type: number
                  example:
                    - - 1.2
                      - 0.5
                      - 3.1
                      - 2.3
                    - - 2.1
                      - 1.3
                      - 2.5
                      - 1.8
                    - - 0.8
                      - 0.9
                      - 4.2
                      - 3.1
                n_components:
                  type: integer
                  description: Number of principal components
                  default: 2
                  example: 2
      responses:
        '200':
          description: PCA transformation results
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    properties:
                      transformed:
                        type: array
                        items:
                          type: array
                          items:
                            type: number
                        description: Transformed data in principal component space
                        example:
                          - - 2.34
                            - -0.56
                          - - 1.87
                            - 0.23
                          - - 3.12
                            - -0.89
                      n_components:
                        type: integer
                        example: 2
                      explained_variance_ratio:
                        type: array
                        items:
                          type: number
                        description: Proportion of variance explained by each component
                        example:
                          - 0.734
                          - 0.189
        '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

````