File tree Expand file tree Collapse file tree 1 file changed +0
-35
lines changed Expand file tree Collapse file tree 1 file changed +0
-35
lines changed Original file line number Diff line number Diff line change 1313 "sort_values_array" ,
1414 "sort_values_history" ,
1515 "compute_removal_score" ,
16- "compute_random_removal_score" ,
1716]
1817
1918KT = TypeVar ("KT" )
@@ -77,37 +76,3 @@ def compute_removal_score(
7776 score = u (indices )
7877 scores [pct ] = score
7978 return scores
80-
81-
82- def compute_random_removal_score (
83- u : Utility ,
84- percentages : Union ["NDArray" , Iterable [float ]],
85- * ,
86- progress : bool = False ,
87- ) -> Dict [float , float ]:
88- r"""Fits model and computes score on the test set after incrementally removing
89- a percentage of random data points from the training set.
90-
91- :param u: Utility object with model, data, and scoring function.
92- :param percentages: Sequence of removal percentages.
93- :param progress: If True, display a progress bar.
94- :return: Dictionary that maps the percentages to their respective scores.
95- """
96- # Sanity checks
97- if np .any ([x >= 1.0 or x < 0.0 for x in percentages ]):
98- raise ValueError ("All percentages should be in the range [0.0, 1.0)" )
99-
100- scores = {}
101-
102- for pct in maybe_progress (
103- percentages ,
104- display = progress ,
105- desc = "Random Removal Scores" ,
106- ):
107- n_removal = int (pct * len (u .data ))
108- indices = np .random .choice (
109- u .data .indices , size = len (u .data ) - n_removal , replace = False
110- )
111- score = u (indices )
112- scores [pct ] = score
113- return scores
You can’t perform that action at this time.
0 commit comments