Skip to content

Commit

Permalink
Update uplift and Qini curve plots with a fixed random line (#799)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeongyoonlee authored Oct 16, 2024
1 parent 8e4a5bf commit aad4041
Show file tree
Hide file tree
Showing 9 changed files with 972 additions and 602 deletions.
11 changes: 0 additions & 11 deletions causalml/dataset/classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,27 @@


# ------ Define a list of functions for feature transformation
# @staticmethod
def _f_linear(x):
"""
Linear transformation (actually identical transformation)
"""
return np.array(x)


# @staticmethod
def _f_quadratic(x):
"""
Quadratic transformation
"""
return np.array(x) * np.array(x)


# @staticmethod
def _f_cubic(x):
"""
Quadratic transformation
"""
return np.array(x) * np.array(x) * np.array(x)


# @staticmethod
def _f_relu(x):
"""
Relu transformation
Expand All @@ -41,15 +37,13 @@ def _f_relu(x):
return np.maximum(x, 0)


# @staticmethod
def _f_sin(x):
"""
Sine transformation
"""
return np.sin(np.array(x) * np.pi)


# @staticmethod
def _f_cos(x):
"""
Cosine transformation
Expand All @@ -58,7 +52,6 @@ def _f_cos(x):


# ------ Generating non-linear splines as feature transformation functions
# @staticmethod
def _generate_splines(
n_functions=10,
n_initial_points=10,
Expand Down Expand Up @@ -107,15 +100,13 @@ def _generate_splines(
return spls


# @staticmethod
def _standardize(x):
"""
Standardize a vector to be mean 0 and std 1.
"""
return (np.array(x) - np.mean(x)) / np.std(x)


# @staticmethod
def _fixed_transformation(fs, x, f_index=0):
"""
Transform and standardize a vector by a transformation function.
Expand All @@ -139,7 +130,6 @@ def _fixed_transformation(fs, x, f_index=0):
return y


# @staticmethod
def _random_transformation(fs, x):
"""
Transform and standardize a vector by a function randomly chosen from
Expand All @@ -158,7 +148,6 @@ def _random_transformation(fs, x):
return y


# @staticmethod
def _softmax(z, p, xb):
"""
Softmax function. This function is used to reversely solve the constant root value in the linear part to make the
Expand Down
Loading

0 comments on commit aad4041

Please sign in to comment.