void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) { writer.WriteStartObject(); if (Patterns.Any()) { writer.WritePropertyName("patterns"); writer.WriteStartArray(); foreach (var item in Patterns) { writer.WriteStringValue(item); } writer.WriteEndArray(); } else { writer.WriteNull("patterns"); } if (PreserveOriginal != null) { writer.WritePropertyName("preserveOriginal"); writer.WriteBooleanValue(PreserveOriginal.Value); } writer.WritePropertyName("@odata.type"); writer.WriteStringValue(ODataType); writer.WritePropertyName("name"); writer.WriteStringValue(Name); writer.WriteEndObject(); }
public double[] Classify(Instance instance) { if (Patterns == null || !Patterns.Any()) { return(null); } if (!_isInitialized) { Initialize(); } var matchedPattern = _filteredPatterns.Where(p => p.IsMatch(instance)); if (!matchedPattern.Any()) { return(null); } var selectedPatterns = SelectionPolicy.SelectPatterns(instance, matchedPattern); if (!selectedPatterns.Any()) { return(null); } var votes = VotesAggregator.Aggregate(selectedPatterns); if (VotesNormalizer != null) { votes = VotesNormalizer.Normalize(votes); } return(votes); }
public void Save() { var dir = "Materials".GetMyDocs(); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } string folder = dir + "\\" + this.Category; if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } XDocument doc = new XDocument(new XElement(this.Category.ToString())) { Declaration = new XDeclaration("1.0", "utf-8", "yes") }; doc.Root.Add(new XAttribute("Model", this.Model)); doc.Root.Add(new XAttribute("Manufacturer", this.Manufacturer)); doc.Root.Add(new XAttribute("Color", this.Color)); doc.Root.Add(new XAttribute("Description", this.Description)); if (Patterns.Any()) { foreach (var pat in this.Patterns) { XElement ele = new XElement("Pattern"); ele.Add(new XAttribute("Description", pat)); doc.Root.Add(ele); } } if (Projects.Any()) { foreach (var prj in this.Projects) { XElement ele = new XElement("Project"); ele.Add(new XAttribute("Description", prj)); doc.Root.Add(ele); } } string fn = folder + "\\" + this.Model + ".xml"; doc.Save(fn); }
private void GoBack() { bool hasChanges = Patterns.Any(x => x.HasChanges); if (hasChanges) { bool result = _dialogService.ShowConfirmationDialog("При переходе все изменения будут потеряны. Продолжить?"); if (!result) { return; } } _navigator.NavigateBack(this); }
/// <summary> /// Generate decision tree via ID3 algorithm /// </summary> protected override void DoTrain() { base.DoTrain(); if (Patterns == null || !Patterns.Any()) { throw new MLException("Patterns are empty or null"); } if (Informativity == null) { throw new MLException("Informativity index is null"); } var root = trainID3Core(Patterns, TrainingSample, Informativity); m_Result = new DecisionTree <TObj>(root); }