简体   繁体   English

评估多个机器学习模型的正确方法

[英]Correct way of evaluating multiple machine learning models

I am writing a QARegression module in Python for my machine learning project where I want to evaluate multiple models.我正在为我想要评估多个模型的机器学习项目在 Python 中编写一个 QARegression 模块。 Suppose, this is a image recognition model running on multiple images located in multiple folders.假设,这是一个图像识别 model 在位于多个文件夹中的多个图像上运行。

 - folder-1
   - img-1
   - img-2
   - img-3
 - folder-2
   - img-1
   ......

Does it matter if I write like this我这样写有关系吗

for eachFolder in FolderList:
    for eachImage in ImageList:
        for eachModel in ModelList:
            evaluate(predicted, GroundTruth)

Or或者

for eachModel in ModelList:
    for eachFolder in FolderList:
        for eachImage in ImageList:
            evaluate(predicted, GroundTruth)

Where in the end I would want output like this我到底想要像这样的 output

model_1 : score1
model_2 : score2
.
.
.

which will be better in terms of这在以下方面会更好

  1. runtime complexity运行时复杂度

  2. correctness正确性

OR it does not matter at all, we can write in anyway?或者根本不重要,我们可以写吗?

It presumably depends on the externals.这大概取决于外部因素。 If each model takes a long time to load, you want to do it as infrequently as possible, so want the model loop outside.如果每个 model 需要很长时间才能加载,您希望尽可能不频繁地加载,因此希望将 model 循环放在外面。 If each image is very large, you want to load those as infrequently as possible, so want the image loop to be outside the model loop.如果每个图像都非常大,您希望尽可能不频繁地加载它们,因此希望图像循环位于 model 循环之外。

Both of them will evaluate each models.他们俩都会评估每个模型。 But you should go for the second one.但是第二个应该是 go。 The second one will take one model and evaluate that model with all images in all folders.第二个将采用 model 并评估 model 与所有文件夹中的所有图像。 It is better than loading the models again and again for different images.这比为不同的图像一次又一次地加载模型要好。 Also it will be harder to evaluate all models with first code snippet.此外,使用第一个代码片段评估所有模型也将更加困难。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM