class_docstr: A highly experimental implementation of the counterfactual unit selection
  model proposed by Li and Pearl (2019).
  
  Parameters
  ----------
  learner : object
      The base learner used to estimate the segment probabilities.
  
  nevertaker_payoff : float
      The payoff from targeting a never-taker
  
  alwaystaker_payoff : float
      The payoff from targeting an always-taker
  
  complier_payoff : float
      The payoff from targeting a complier
  
  defier_payoff : float
      The payoff from targeting a defier
  
  organic_conversion : float, optional (default=None)
      The organic conversion rate in the population without an intervention.
      If None, the organic conversion rate is obtained from tne control group.
  
      NB: The organic conversion in the control group is not always the same
      as the organic conversion rate without treatment.
  
  data : DataFrame
      A pandas DataFrame containing the features, treatment assignment
      indicator and the outcome of interest.
  
  treatment : string
      A string corresponding to the name of the treatment column. The
      assumed coding in the column is 1 for treatment and 0 for control.
  
  outcome : string
      A string corresponding to the name of the outcome column. The assumed
      coding in the column is 1 for conversion and 0 for no conversion.
  
  References
  ----------
  Li, Ang, and Judea Pearl. 2019. “Unit Selection Based on Counterfactual
  Logic.” https://ftp.cs.ucla.edu/pub/stat_ser/r488.pdf.
docstr: Constructs the following segments:
  
  * AC = Pr(Y = 1, W = 1 /mid X)
  * AD = Pr(Y = 1, W = 0 /mid X)
  * ND = Pr(Y = 0, W = 1 /mid X)
  * ND = Pr(Y = 0, W = 0 /mid X)
  
  where the names of the outcomes correspond the combinations of
  the relevant segments, eg AC = Always-taker or Complier.
docstr_tok: ["Constructs","the","following","segments",":","*","AC","=","Pr","(","Y","=","1",",","W","=","1","\/mid","X",")","*","AD","=","Pr","(","Y","=","1",",","W","=","0","\/mid","X",")","*","ND","=","Pr","(","Y","=","0",",","W","=","1","\/mid","X",")","*","ND","=","Pr","(","Y","=","0",",","W","=","0","\/mid","X",")","where","the","names","of","the","outcomes","correspond","the","combinations","of","the","relevant","segments",",","eg","AC","=","Always-taker","or","Complier","."]
code: def _make_segments(data, treatment, outcome):
      """
      Constructs the following segments:
  
      * AC = Pr(Y = 1, W = 1 /mid X)
      * AD = Pr(Y = 1, W = 0 /mid X)
      * ND = Pr(Y = 0, W = 1 /mid X)
      * ND = Pr(Y = 0, W = 0 /mid X)
  
      where the names of the outcomes correspond the combinations of
      the relevant segments, eg AC = Always-taker or Complier.
      """
  
      segments = np.empty(data.shape[0], dtype="object")
  
      segments[(data[treatment] == 1) & (data[outcome] == 1)] = "AC"
      segments[(data[treatment] == 0) & (data[outcome] == 1)] = "AD"
      segments[(data[treatment] == 1) & (data[outcome] == 0)] = "ND"
      segments[(data[treatment] == 0) & (data[outcome] == 0)] = "NC"
  
      return segments
  
file_path: causalml/causalml/optimize/unit_selection.py
imports: import numpy
  import pandas
  from sklearn.base import clone
  import warnings
label_desc: Use image node_id 5 for calling the CounterfactualUnitSelector obj's underlying member method code with example usage: obj._make_segments(data, treatment, outcome) and returns: segments