class_docstr: objective function of logistic regression with prejudice remover
  
  Loss Function type 4: Weights for logistic regression are prepared for each
  value of S. Penalty for enhancing is defined as mutual information between
  Y and S.
class_docstr_tok: ["objective","function","of","logistic","regression","with","prejudice","remover","Loss","Function","type","4",":","Weights","for","logistic","regression","are","prepared","for","each","value","of","S.","Penalty","for","enhancing","is","defined","as","mutual","information","between","Y","and","S","."]
docstr: loss function: negative log - likelihood with l2 regularizer
  To suppress the warnings at np.log, do "np.seterr(all='ignore')"
  
  Parameters
  ----------
  `coef_` : array, shape=(`n_sfv_` * n_features)
      coefficients of model
  X : array, shape=(n_samples, n_features)
      feature vectors of samples
  y : array, shape=(n_samples)
      target class of samples
  s : array, shape=(n_samples)
      values of sensitive features
  
  Returns
  -------
  loss : float
      loss function value
docstr_tok: ["loss","function",":","negative","log","-","likelihood","with","l2","regularizer","To","suppress","the","warnings","at","np.log",",","do","``","np.seterr","(","all='ignore","'",")","''","Parameters","--","--","--","--","--","`","coef_","`",":","array",",","shape=","(","`","n_sfv_","`","*","n_features",")","coefficients","of","model","X",":","array",",","shape=","(","n_samples",",","n_features",")","feature","vectors","of","samples","y",":","array",",","shape=","(","n_samples",")","target","class","of","samples","s",":","array",",","shape=","(","n_samples",")","values","of","sensitive","features","Returns","--","--","--","-","loss",":","float","loss","function","value"]
code: def loss(self, coef_, X, y, s):
      """loss function: negative log - likelihood with l2 regularizer
      To suppress the warnings at np.log, do "np.seterr(all='ignore')"
  
      Parameters
      ----------
      `coef_` : array, shape=(`n_sfv_` * n_features)
          coefficients of model
      X : array, shape=(n_samples, n_features)
          feature vectors of samples
      y : array, shape=(n_samples)
          target class of samples
      s : array, shape=(n_samples)
          values of sensitive features
  
      Returns
      -------
      loss : float
          loss function value
      """
  
      coef = coef_.reshape(self.n_sfv_, self.n_features_)
  
      #        print >> sys.stderr, "loss:", coef[0, :], coef[1, :]
  
      ### constants
  
      # sigma = Pr[y=0|x,s] = sigmoid(w(s)^T x)
      p = np.array(
          [
              sigmoid(X[i, :], coef[s[i], :])
              for i in range(self.n_samples_)
          ]
      )
  
      # rho(s) = Pr[y=0|s] = \sum_{(xi,si)in D st si=s} sigma(xi,si) / #D[s]
      q = (
          np.array([np.sum(p[s == si]) for si in range(self.n_sfv_)])
          / self.c_s_
      )
  
      # pi = Pr[y=0] = \sum_{(xi,si)in D} sigma(xi,si)
      r = np.sum(p) / self.n_samples_
  
      ### loss function
  
      # likelihood
      # \sum_{x,s,y in D} y log(sigma) + (1 - y) log(1 - sigma)
      l = np.sum(y * np.log(p) + (1.0 - y) * np.log(1.0 - p))
  
      # fairness-aware regularizer
      # \sum_{x,s in D} \
      #    sigma(x,x)       [log(rho(s))     - log(pi)    ] + \
      #    (1 - sigma(x,s)) [log(1 - rho(s)) - log(1 - pi)]
      f = np.sum(
          p * (np.log(q[s]) - np.log(r))
          + (1.0 - p) * (np.log(1.0 - q[s]) - np.log(1.0 - r))
      )
  
      # l2 regularizer
      reg = np.sum(coef * coef)
  
      l = -l + self.eta * f + 0.5 * self.C * reg
      #        print >> sys.stderr, l
      return l
  
imports: from __future__ import print_function
  from __future__ import division
  from __future__ import unicode_literals
  import logging
  import numpy
  from scipy.optimize import fmin_cg
  from sklearn.linear_model import LogisticRegression
  from sklearn.base import BaseEstimator, ClassifierMixin
label_desc: Use image node_id 1 for calling the LRwPRObjetiveType4Mixin obj's underlying member method code with example usage: obj.loss(coef_, X, y, s) and returns: l