class_docstr: Classification module for KDE-based anomaly detection.
  
  Args:
      n_pca_components (int, optional): Number of PCA components. Defaults to 16.
      feature_scaling_method (FeatureScalingMethod, optional): Scaling method applied to features before passing to
          KDE. Options are `norm` (normalize to unit vector length) and `scale` (scale to max length observed in
          training).
      max_training_points (int, optional): Maximum number of training points to fit the KDE model. Defaults to 40000.
class_docstr_tok: ["Classification","module","for","KDE-based","anomaly","detection",".","Args",":","n_pca_components","(","int",",","optional",")",":","Number","of","PCA","components",".","Defaults","to","16.","feature_scaling_method","(","FeatureScalingMethod",",","optional",")",":","Scaling","method","applied","to","features","before","passing","to","KDE",".","Options","are","`","norm","`","(","normalize","to","unit","vector","length",")","and","`","scale","`","(","scale","to","max","length","observed","in","training",")",".","max_training_points","(","int",",","optional",")",":","Maximum","number","of","training","points","to","fit","the","KDE","model",".","Defaults","to","40000","."]
docstr: Fit a kde model to embeddings.
  
  Args:
      embeddings (Tensor): Input embeddings to fit the model.
  
  Returns:
      Boolean confirming whether the training is successful.
docstr_tok: ["Fit","a","kde","model","to","embeddings",".","Args",":","embeddings","(","Tensor",")",":","Input","embeddings","to","fit","the","model",".","Returns",":","Boolean","confirming","whether","the","training","is","successful","."]
code: def fit(self, embeddings: Tensor) -> bool:
      """Fit a kde model to embeddings.
  
      Args:
          embeddings (Tensor): Input embeddings to fit the model.
  
      Returns:
          Boolean confirming whether the training is successful.
      """
  
      if embeddings.shape[0] < self.n_pca_components:
          logger.info(
              "Not enough features to commit. Not making a model."
          )
          return False
  
      # if max training points is non-zero and smaller than number of staged features, select random subset
      if embeddings.shape[0] > self.max_training_points:
          selected_idx = torch.tensor(
              random.sample(
                  range(embeddings.shape[0]), self.max_training_points
              )
          )
          selected_features = embeddings[selected_idx]
      else:
          selected_features = embeddings
  
      feature_stack = self.pca_model.fit_transform(selected_features)
      feature_stack, max_length = self.pre_process(feature_stack)
      self.max_length = max_length
      self.kde_model.fit(feature_stack)
  
      return True
  
file_path: anomalib/src/anomalib/models/components/classification/kde_classifier.py
imports: from __future__ import annotations
  import logging
  import random
  from enum import Enum
  import torch
  from torch import Tensor, nn
  from anomalib.models.components import PCA, GaussianKDE
label_desc: Use image node_id 3 for calling the KDEClassifier obj's underlying member method code with example usage: obj.fit(embeddings) and returns: True, False