original_docstring: Returns regularization term for cost and gradient depending on
          choice passed by the 'what' parameter. Ridge type.
  
          :param theta: ndarray; weights.
          :param Lambda: int or float; lambda hyperparameter.
          :param m: int; total number of training examples.
          :param what: str; default 'cost'. Any other value returns
          regularization part for a gradient.
          :return: int for cost, ndarray for gradient.
          
docstring: Returns regularization term for cost and gradient depending on
  choice passed by the 'what' parameter. Ridge type.
docstring_tokens: Returns regularization term for cost and gradient depending on choice passed by the ' what ' parameter . Ridge type .
code: def regularize(theta, Lambda, m, what='cost'):
          """Returns regularization term for cost and gradient depending on
          choice passed by the 'what' parameter. Ridge type.
  
          :param theta: ndarray; weights.
          :param Lambda: int or float; lambda hyperparameter.
          :param m: int; total number of training examples.
          :param what: str; default 'cost'. Any other value returns
          regularization part for a gradient.
          :return: int for cost, ndarray for gradient.
          """
          theta_bias_excluded = theta[:, 1:]
          if what == 'cost':
              return Lambda * np.sum([theta_bias_excluded ** 2]) / (2 * m)
  
          # Intercept term is not regularized, that's why it's not a part of equation.
          # It's however needed to preserve correct dimension for upcoming addition of
          # the regularization term, thus 0 for theta0 is prepended.
          return np.c_[0, Lambda * theta_bias_excluded / m]
code_tokens: def regularize ( theta , Lambda , m , what = 'cost' ) : theta_bias_excluded = theta [ : , 1 : ] if what == 'cost' : return Lambda * np . sum ( [ theta_bias_excluded ** 2 ] ) / ( 2 * m ) return np . c_ [ 0 , Lambda * theta_bias_excluded / m ]
short_docstring: Returns regularization term for cost and gradient depending on
  choice passed by the 'what' parameter.
short_docstring_tokens: Returns regularization term for cost and gradient depending on choice passed by the ' what ' parameter .
comment: """Returns regularization term for cost and gradient depending on
          choice passed by the 'what' parameter. Ridge type.
  
          :param theta: ndarray; weights.
          :param Lambda: int or float; lambda hyperparameter.
          :param m: int; total number of training examples.
          :param what: str; default 'cost'. Any other value returns
          regularization part for a gradient.
          :return: int for cost, ndarray for gradient.
          """$SEP$# Intercept term is not regularized, that's why it's not a part of equation.$SEP$# It's however needed to preserve correct dimension for upcoming addition of$SEP$# the regularization term, thus 0 for theta0 is prepended.