< Summary

Information
Class: Intentum.AI.Ensemble.EnsembleIntentModel
Assembly: Intentum.AI
File(s): /home/runner/work/Intentum/Intentum/src/Intentum.AI/Ensemble/EnsembleIntentModel.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 17
Coverable lines: 17
Total lines: 33
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)0%220%
Infer(...)100%110%

File(s)

/home/runner/work/Intentum/Intentum/src/Intentum.AI/Ensemble/EnsembleIntentModel.cs

#LineLine coverage
 1using Intentum.Core.Behavior;
 2using Intentum.Core.Contracts;
 3using Intentum.Core.Intents;
 4
 5namespace Intentum.AI.Ensemble;
 6
 7public sealed class EnsembleIntentModel : IIntentModel
 8{
 9    private readonly IReadOnlyList<IIntentModel> _models;
 10    private readonly IEnsembleStrategy _strategy;
 11    private readonly IReadOnlyList<double> _weights;
 12
 013    public EnsembleIntentModel(
 014        IReadOnlyList<IIntentModel> models,
 015        IEnsembleStrategy strategy,
 016        IReadOnlyList<double>? weights = null)
 017    {
 018        _models = models;
 019        _strategy = strategy;
 020        _weights = weights ?? models.Select(_ => 1.0).ToList();
 021    }
 22
 23    public Intent Infer(BehaviorSpace behaviorSpace, BehaviorVector? precomputedVector = null)
 024    {
 025        var results = _models.Select((model, i) =>
 026        {
 027            var intent = model.Infer(behaviorSpace, precomputedVector);
 028            return new ModelResult(intent.Name, intent.Confidence.Score, _weights[i]);
 029        }).ToList();
 30
 031        return _strategy.Combine(results);
 032    }
 33}