<commit_before>import logging
import numpy as np
from basenode import BaseNode
from ..dataset import DataSet

class PCA(BaseNode):
  def __init__(self, retain=.95, ndims=None):
    BaseNode.__init__(self)
    self.retain = retain
    self.ndims = ndims

  def train_(self, d):
    self.mean = np.mean(d.xs, axis=0)
    cov = np.cov(d.xs, rowvar=False) 
    U, s, V = np.linalg.svd(cov)
    self.eigen_cols = U
    self.eigen_vals = s
<commit_msg>Example doc pca.<commit_after>import logging
import numpy as np
from basenode import BaseNode
from ..dataset import DataSet

class PCA(BaseNode):
  ''' 
  PCA node
  '''
  def __init__(self, retain=.95, ndims=None):
    BaseNode.__init__(self)
    self.retain = retain
    self.ndims = ndims

  def train_(self, d):
    self.mean = np.mean(d.xs, axis=0)
    cov = np.cov(d.xs, rowvar=False) 
    U, s, V = np.linalg.svd(cov)
    self.eigen_cols = U
    self.eigen_vals = s

{'fraction_non_alphanumeric': 0.12295973884657237, 'fraction_numerical': 0.006528835690968444, 'mean_word_length': 3.16289592760181, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '721658', 'n_tokens_mistral': 356, 'n_tokens_neox': 348, 'n_words': 88}