public void Train(ILabeledExampleCollection <LblT, ExT> dataset) { foreach (ModelLabel modelLabel in ModelLabels.Take(ModelLabels.Count() - 1)) { modelLabel.Model.Train(dataset); ModelLabel modelLabel_ = modelLabel; dataset = new LabeledDataset <LblT, ExT>(dataset.Where(le => !le.Label.Equals(modelLabel_.Label))); } ModelLabels.Last().Model.Train(dataset); IsTrained = true; }
public Prediction <LblT> Predict(ExT example) { foreach (ModelLabel modelLabel in ModelLabels.Take(ModelLabels.Count() - 1)) { Prediction <LblT> prediction = modelLabel.Model.Predict(example); if (prediction.BestClassLabel.Equals(modelLabel.Label)) { return(prediction); } } return(ModelLabels.Last().Model.Predict(example)); }