小编Arc*_*Arc的帖子

如何使用 EF Core 3.0 提高多个包含的效率

我有一个多级查询,包括:

var itemsToday = DatabaseContext.Items
                .Where(f => f.StartTime > DateTime.Today && f.StartTime < DateTime.Today.AddDays(1))
                .Include(x => x.LocalStats).ThenInclude(x=>x.StatType1)
                .Include(x => x.LocalStats).ThenInclude(x=>x.StatType2)
                .Include(x => x.LocalStats).ThenInclude(x=>x.StatType3)
                .Include(x => x.LocalStats).ThenInclude(x=>x.StatType4)
                .Include(x => x.LocalStats).ThenInclude(x=>x.StatType5)
                .Include(x => x.LocalStats).ThenInclude(x=>x.StatType6)
                .Include(x => x.LocalStats).ThenInclude(x=>x.StatType7)
                .Include(x => x.LocalStats).ThenInclude(x=>x.StatType8)
                .Include(x => x.LocalStats).ThenInclude(x=>x.StatType9)
                .Include(x => x.LocalDetails)
...
                .OrderBy(f=>f.SomeOrderingCriterion);
Run Code Online (Sandbox Code Playgroud)

还有比这更多的包含。当然,这会导致 EF Core 3.0在 SQL 查询中生成许多连接,这意味着执行需要很长时间(25 秒以上才能检索 200 条记录)。

我曾尝试使用格式.Include(x => x.LocalStats.StatType1)而不是 Include 和 ThenInclude,但结果是一样的。

有什么方法可以使这更有效吗?文档建议:

具有大量Include运算符的LINQ 查询可能需要分解为多个单独的 LINQ 查询,以避免笛卡尔爆炸问题。

但是我没有看到有关如何实际完成此操作的任何解释。

c# linq asp.net-core ef-core-3.0

6
推荐指数
1
解决办法
1336
查看次数

当数据中没有正类别时,AUC 未定义[原文如此]

我在尝试训练模型时遇到以下问题:

Inferring Columns ...
Creating Data loader ...
Loading data ...
Exploring multiple ML algorithms and settings to find you the best model for ML task: binary-classification
For further learning check: https://aka.ms/mlnet-cli
|     Trainer                              Accuracy      AUC    AUPRC  F1-score  Duration #Iteration             |
[Source=AutoML, Kind=Trace] Channel started
[Source=AutoML, Kind=Trace] Evaluating pipeline xf=ColumnConcatenating{ col=Features:V1,V2,V3,V4,V5,V6} xf=Normalizing{ col=Features:Features} tr=AveragedPerceptronBinary{}  cache=+
[Source=AutoML, Kind=Error] Pipeline crashed: xf=ColumnConcatenating{ col=Features:V1,V2,V3,V4,V5,V6} xf=Normalizing{ col=Features:Features} tr=AveragedPerceptronBinary{}  cache=+ . Exception: System.ArgumentOutOfRangeException: AUC is not definied when there is no positive class in the …
Run Code Online (Sandbox Code Playgroud)

c# ml.net

1
推荐指数
1
解决办法
1716
查看次数

标签 统计

c# ×2

asp.net-core ×1

ef-core-3.0 ×1

linq ×1

ml.net ×1