Skip to content

Commit 7ba4cf7

Browse files
authored
lazzy evaluation
1 parent a2c99b6 commit 7ba4cf7

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

CompStats/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
__version__ = '0.1.11'
14+
__version__ = '0.1.12'
1515
from CompStats.bootstrap import StatisticSamples
1616
from CompStats.measurements import CI, SE, difference_p_value
1717
from CompStats.performance import performance, difference, all_differences, plot_performance, plot_difference

CompStats/interface.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ def __call__(self, y_pred, name=None):
186186
k = 1
187187
name = f'alg-{k}'
188188
self.best = None
189+
self.statistic = None
189190
self.predictions[name] = np.asanyarray(y_pred)
190191
samples = self._statistic_samples
191192
calls = samples.calls
@@ -296,14 +297,23 @@ def statistic(self):
296297
>>> perf.statistic
297298
{'alg-1': 1.0, 'forest': 0.9500891265597148}
298299
"""
299-
300+
if hasattr(self, '_statistic') and self._statistic is not None:
301+
return self._statistic
302+
BiB = True if self.score_func is not None else False
300303
data = sorted([(k, self.statistic_func(self.y_true, v))
301304
for k, v in self.predictions.items()],
302-
key=lambda x: self.sorting_func(x[1]),
303-
reverse=self.statistic_samples.BiB)
305+
key=lambda x: self.sorting_func(x[1]),
306+
reverse=BiB)
304307
if len(data) == 1:
305-
return data[0][1]
306-
return dict(data)
308+
self._statistic = data[0][1]
309+
else:
310+
self._statistic = dict(data)
311+
return self._statistic
312+
313+
@statistic.setter
314+
def statistic(self, value):
315+
"""statistic setter"""
316+
self._statistic = value
307317

308318
@property
309319
def se(self):

0 commit comments

Comments
 (0)