class_docstr: Risk Model
  
  A risk model is used to estimate the covariance matrix of stock returns.
class_docstr_tok: ["Risk","Model","A","risk","model","is","used","to","estimate","the","covariance","matrix","of","stock","returns","."]
docstr: handle nan and centerize data
  
  Note:
      if `nan_option='mask'` then the returned array will be `np.ma.MaskedArray`.
docstr_tok: ["handle","nan","and","centerize","data","Note",":","if","`","nan_option='mask","'","`","then","the","returned","array","will","be","`","np.ma.MaskedArray","`","."]
code: def _preprocess(
      self, X: np.ndarray
  ) -> Union[np.ndarray, np.ma.MaskedArray]:
      """handle nan and centerize data
  
      Note:
          if `nan_option='mask'` then the returned array will be `np.ma.MaskedArray`.
      """
      # handle nan
      if self.nan_option == self.FILL_NAN:
          X = np.nan_to_num(X)
      elif self.nan_option == self.MASK_NAN:
          X = np.ma.masked_invalid(X)
      # centralize
      if not self.assume_centered:
          X = X - np.nanmean(X, axis=0)
      return X
  
file_path: qlib/qlib/model/riskmodel/base.py
imports: import inspect
  import numpy
  import pandas
  from typing import Union
  from qlib.model.base import BaseModel
label_desc: Use image node_id 4 for calling the RiskModel obj's underlying member method code with example usage: obj._preprocess(X) and returns: X