class_docstr: The RidgeReduction class is intended to reduce the feature space of an N by M block matrix X to an N by P<<M block
  matrix.  This is done by fitting K ridge models within each block of X on one or more target labels, such that a
  block with L columns to begin with will be reduced to a block with K columns, where each column is the prediction
  of one ridge model for one target label.
class_docstr_tok: ["The","RidgeReduction","class","is","intended","to","reduce","the","feature","space","of","an","N","by","M","block","matrix","X","to","an","N","by","P","<","<","M","block","matrix",".","This","is","done","by","fitting","K","ridge","models","within","each","block","of","X","on","one","or","more","target","labels",",","such","that","a","block","with","L","columns","to","begin","with","will","be","reduced","to","a","block","with","K","columns",",","where","each","column","is","the","prediction","of","one","ridge","model","for","one","target","label","."]
docstr: Args:
      block_df : Spark DataFrame representing the beginning block matrix X
      label_df : Pandas DataFrame containing the target labels used in fitting the ridge models
      sample_blocks : Dict containing a mapping of sample_block ID to a list of corresponding sample IDs
      cov_df : Pandas DataFrame containing covariates to be included in every model in the stacking
          ensemble (optional).
      add_intercept: If True, an intercept column (all ones) will be added to the covariates
          (as the first column)
      alphas : array_like of alpha values used in the ridge reduction (optional).
      label_type: String to determine type treatment of labels. It can be 'detect' (default), 'binary',
          or 'quantitative'.
docstr_tok: ["Args",":","block_df",":","Spark","DataFrame","representing","the","beginning","block","matrix","X","label_df",":","Pandas","DataFrame","containing","the","target","labels","used","in","fitting","the","ridge","models","sample_blocks",":","Dict","containing","a","mapping","of","sample_block","ID","to","a","list","of","corresponding","sample","IDs","cov_df",":","Pandas","DataFrame","containing","covariates","to","be","included","in","every","model","in","the","stacking","ensemble","(","optional",")",".","add_intercept",":","If","True",",","an","intercept","column","(","all","ones",")","will","be","added","to","the","covariates","(","as","the","first","column",")","alphas",":","array_like","of","alpha","values","used","in","the","ridge","reduction","(","optional",")",".","label_type",":","String","to","determine","type","treatment","of","labels",".","It","can","be","'detect","'","(","default",")",",","'binary","'",",","or","'quantitative","'","."]
code: def __init__(
      self,
      block_df: DataFrame,
      label_df: pd.DataFrame,
      sample_blocks: Dict[str, List[str]],
      cov_df: pd.DataFrame = pd.DataFrame({}),
      add_intercept: bool = True,
      alphas: List[float] = [],
      label_type="detect",
  ) -> None:
      """
      Args:
          block_df : Spark DataFrame representing the beginning block matrix X
          label_df : Pandas DataFrame containing the target labels used in fitting the ridge models
          sample_blocks : Dict containing a mapping of sample_block ID to a list of corresponding sample IDs
          cov_df : Pandas DataFrame containing covariates to be included in every model in the stacking
              ensemble (optional).
          add_intercept: If True, an intercept column (all ones) will be added to the covariates
              (as the first column)
          alphas : array_like of alpha values used in the ridge reduction (optional).
          label_type: String to determine type treatment of labels. It can be 'detect' (default), 'binary',
              or 'quantitative'.
      """
      self.block_df = block_df
      self.sample_blocks = sample_blocks
      self._label_type = label_type
      self.set_label_df(label_df)
      self.set_cov_df(cov_df, add_intercept)
      self.set_alphas(alphas)
      self.model_df = None
      self.reduced_block_df = None
  
imports: from .ridge_udfs import *
  from .model_functions import _is_binary, _prepare_covariates, _prepare_labels_and_warn, _check_model
  from nptyping import Float, NDArray
  import pandas
  from pyspark.sql import DataFrame, Row
  from pyspark.sql.functions import pandas_udf, PandasUDFType
  import pyspark.sql.functions
  from typeguard import typechecked
  from typing import Any, Dict, List, Union
  from glow.logging import record_hls_event
  import warnings
label_desc: Use image node_id 1 to create a new RidgeReduction object  with example: obj = RidgeReduction(block_df, label_df, sample_blocks, cov_df, add_intercept, alphas, label_type)