protected void GenerateModuleType(IndentedTextWriter w, ComponentCatalog.LoadableClassInfo component) { string cat; if (component.IsOfType(typeof(SignatureBinaryClassifierTrainer))) { cat = "BinaryClassifier"; } else if (component.IsOfType(typeof(SignatureMultiClassClassifierTrainer))) { cat = "MultiClassClassifier"; } else if (component.IsOfType(typeof(SignatureRegressorTrainer))) { cat = "Regression"; } else if (component.IsOfType(typeof(SignatureAnomalyDetectorTrainer))) { cat = "AnomalyDetector"; } else { cat = "None"; } w.WriteLine("[DataLabModuleType(Type = ModuleType.{0})]", cat); }
protected override void GenerateModuleAttribute(IndentingTextWriter w, string prefix, ComponentCatalog.LoadableClassInfo component, string moduleId) { if (!string.IsNullOrEmpty(prefix)) { prefix += " "; } w.WriteLine("[DataLabModule(FriendlyName = \"{0}{1}\",", prefix, component.UserName); using (w.Nest()) { var desc = component.Summary ?? component.LoadNames[0]; w.WriteLine("Description = \"{0}\",", desc.Replace("\n", "\\n").Replace("\r", "\\r")); string cat; if (component.IsOfType(typeof(SignatureBinaryClassifierTrainer)) || component.IsOfType(typeof(SignatureMultiClassClassifierTrainer))) { cat = @"Machine Learning\Initialize Model\Classification"; } else if (component.IsOfType(typeof(SignatureRegressorTrainer))) { cat = @"Machine Learning\Initialize Model\Regression"; } else if (component.IsOfType(typeof(SignatureAnomalyDetectorTrainer))) { cat = @"Machine Learning\Initialize Model\Anomaly Detection"; } else { cat = @"Machine Learning\Initialize Model"; } w.WriteLine("Category = @\"{0}\",", cat); w.WriteLine("IsBlocking = true,"); w.WriteLine("IsDeterministic = true,"); w.WriteLine("Version = \"2.0\","); w.WriteLine("Owner = \"Microsoft Corporation\","); w.WriteLine("FamilyId = \"{{{0}}}\",", Guid.NewGuid().ToString().ToUpperInvariant()); w.WriteLine("ReleaseState = States.Alpha)]"); } }
private void GenerateFile(IChannel ch, ComponentCatalog.LoadableClassInfo info) { _host.AssertValue(ch); ch.AssertValue(info); string name = info.LoadNames[0]; if (!info.IsOfType(typeof(SignatureTrainer)) && !info.IsOfType(typeof(SignatureDataTransform))) { ch.Warning("No generator available for {0}.", name); return; } if (info.Constructor == null && info.CreateMethod == null) { ch.Warning("No construction method available for {0}.", name); return; } if (_generateModule) { var entryPointFile = _modulePrefix + name + "EntryPoint.cs"; if (_generateModuleInstance) { GenerateFile(info, entryPointFile, ModuleInstanceEntryPointGeneratorMapping); } else { GenerateFile(info, entryPointFile, EntryPointGeneratorMapping); } } var implFile = _modulePrefix + name + ".cs"; GenerateFile(info, implFile, ImplGeneratorMapping); }
private void GenerateFile(ComponentCatalog.LoadableClassInfo info, string filename, Dictionary <Type, GeneratorBase> mapping, bool generateEnums) { using (var sw = new StreamWriter(filename)) { var writer = IndentingTextWriter.Wrap(sw, " "); foreach (var kvp in mapping) { if (info.IsOfType(kvp.Key)) { kvp.Value.Generate(writer, _modulePrefix, _regenerate, info, generateEnums, _moduleId ?? Guid.NewGuid().ToString(), _moduleName, _moduleOwner, _moduleVersion, _moduleState, _moduleType, _moduleDeterminism, _moduleCategory, _exclude, _namespaces); break; } } } }