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: Fits a ridge reducer model, represented by a Spark DataFrame containing coefficients for each of the ridge
  alpha parameters, for each block in the starting matrix, for each label in the target labels.
  
  Returns:
      Spark DataFrame containing the model resulting from the fitting routine.
docstr_tok: ["Fits","a","ridge","reducer","model",",","represented","by","a","Spark","DataFrame","containing","coefficients","for","each","of","the","ridge","alpha","parameters",",","for","each","block","in","the","starting","matrix",",","for","each","label","in","the","target","labels",".","Returns",":","Spark","DataFrame","containing","the","model","resulting","from","the","fitting","routine","."]
code: def fit(self) -> DataFrame:
      """
      Fits a ridge reducer model, represented by a Spark DataFrame containing coefficients for each of the ridge
      alpha parameters, for each block in the starting matrix, for each label in the target labels.
  
      Returns:
          Spark DataFrame containing the model resulting from the fitting routine.
      """
  
      map_key_pattern = ["header_block", "sample_block"]
      reduce_key_pattern = ["header_block", "header"]
  
      if "label" in self.block_df.columns:
          map_key_pattern.append("label")
          reduce_key_pattern.append("label")
  
      map_udf = pandas_udf(
          lambda key, pdf: map_normal_eqn(
              key,
              map_key_pattern,
              pdf,
              self._std_label_df,
              self.sample_blocks,
              self._std_cov_df,
          ),
          normal_eqn_struct,
          PandasUDFType.GROUPED_MAP,
      )
      reduce_udf = pandas_udf(
          lambda key, pdf: reduce_normal_eqn(
              key, reduce_key_pattern, pdf
          ),
          normal_eqn_struct,
          PandasUDFType.GROUPED_MAP,
      )
      model_udf = pandas_udf(
          lambda key, pdf: solve_normal_eqn(
              key,
              map_key_pattern,
              pdf,
              self._std_label_df,
              self._alphas,
              self._std_cov_df,
          ),
          model_struct,
          PandasUDFType.GROUPED_MAP,
      )
  
      record_hls_event("wgrRidgeReduceFit")
  
      self.model_df = (
          self.block_df.groupBy(map_key_pattern)
          .apply(map_udf)
          .groupBy(reduce_key_pattern)
          .apply(reduce_udf)
          .groupBy(map_key_pattern)
          .apply(model_udf)
      )
  
      return self.model_df
  
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 12 for calling the RidgeReduction obj's underlying member method code with example usage: obj.fit() and returns: self