MCPcopy
hub / github.com/hyperopt/hyperopt / computePartialResultStatistics

Method computePartialResultStatistics

hyperopt/atpe.py:1262–1416  ·  view source on GitHub ↗
(self, hyperparameterSpace, results)

Source from the content-addressed store, hash-verified

1260 return value
1261
1262 def computePartialResultStatistics(self, hyperparameterSpace, results):
1263 losses = numpy.array(
1264 sorted([result["loss"] for result in results if result["loss"] is not None])
1265 )
1266
1267 bestLoss = 0
1268 percentile5Loss = 0
1269 percentile25Loss = 0
1270 percentile50Loss = 0
1271 percentile75Loss = 0
1272 statistics = {}
1273
1274 numpy.warnings.filterwarnings("ignore")
1275
1276 if len(set(losses)) > 1:
1277 bestLoss = numpy.percentile(losses, 0)
1278 percentile5Loss = numpy.percentile(losses, 5)
1279 percentile25Loss = numpy.percentile(losses, 25)
1280 percentile50Loss = numpy.percentile(losses, 50)
1281 percentile75Loss = numpy.percentile(losses, 75)
1282
1283 statistics["loss_skew"] = scipy.stats.skew(losses)
1284 statistics["loss_kurtosis"] = scipy.stats.kurtosis(losses)
1285 else:
1286 statistics["loss_skew"] = 0
1287 statistics["loss_kurtosis"] = 0
1288
1289 if percentile50Loss == 0:
1290 statistics["loss_stddev_median_ratio"] = 0
1291 statistics["loss_best_percentile50_ratio"] = 0
1292 else:
1293 statistics["loss_stddev_median_ratio"] = (
1294 numpy.std(losses) / percentile50Loss
1295 )
1296 statistics["loss_best_percentile50_ratio"] = bestLoss / percentile50Loss
1297
1298 if bestLoss == 0:
1299 statistics["loss_stddev_best_ratio"] = 0
1300 else:
1301 statistics["loss_stddev_best_ratio"] = numpy.std(losses) / bestLoss
1302
1303 if percentile25Loss == 0:
1304 statistics["loss_best_percentile25_ratio"] = 0
1305 statistics["loss_percentile5_percentile25_ratio"] = 0
1306 else:
1307 statistics["loss_best_percentile25_ratio"] = bestLoss / percentile25Loss
1308 statistics["loss_percentile5_percentile25_ratio"] = (
1309 percentile5Loss / percentile25Loss
1310 )
1311
1312 if percentile75Loss == 0:
1313 statistics["loss_best_percentile75_ratio"] = 0
1314 else:
1315 statistics["loss_best_percentile75_ratio"] = bestLoss / percentile75Loss
1316
1317 def getValue(result, parameter):
1318 return result[parameter.name]
1319

Callers 1

Calls 2

HyperparameterClass · 0.85
getFlatParametersMethod · 0.80

Tested by

no test coverage detected