public void Setup() { _kernel = new StandardKernel(new EngineModule(), new TestComponentModule()); _componentFactory = new ComponentFactory(_kernel); _componentFactory.ShouldNotBeNull(); }
private void AddComponent(IComponentFactory factory) { try { var componentFactory = ComponentManager.ComponentFactories.FirstOrDefault(x => x.Value.ComponentName == factory.ComponentName); var component = componentFactory.Value == null ? new LayoutComponent("", new SeparatorComponent()) : new LayoutComponent(componentFactory.Key, componentFactory.Value.Create(CurrentState)); Form.InvokeIfRequired(() => { try { BindingList.Add(component); } catch (Exception ex) { Log.Error(ex); } }); Layout.HasChanged = true; if (LayoutResized != null) LayoutResized(this, null); } catch (Exception e) { Log.Error(e); MessageBox.Show(this, "The Component could not be loaded.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public HandlerPageViewModel(DiteService diteService, NavigationService navigationService, IComponentFactory factory, IMessengerService messengerService) :base(factory, messengerService) { this._diteService = diteService; _navigationService = navigationService; //_moduleFactory = moduleFactory; }
public ConnectionStringEditViewModel(IComponentFactory factory) : base(factory) { Confirm = new RelayCommand(ConfirmExecute); Cancel = new RelayCommand(CancelExecute); CheckConnect = new RelayCommand(CheckConnectExecute); }
public ConnectionStringsViewModel(IComponentFactory factory) : base(factory) { AddNewConnectionString = new RelayCommand(AddNewConnectionStringExecute); Edit = new RelayCommand(EditExecute); Remove = new RelayCommand(RemoveExecute); }
private Dictionary<Fact, IProposition> _propositions; // An archive of Propositions, indexed by name #endregion Fields #region Constructors public PropNetConverter(IComponentFactory componentFactory) { _componentFactory = componentFactory; _doesProcessor = new RelationNameProcessor("does", GameContainer.SymbolTable); _trueProcessor = new RelationNameProcessor("true", GameContainer.SymbolTable); _anonFact = new GroundFact(GameContainer.SymbolTable, "anon"); }
public MainWindow(IComponentFactory factory) { Factory = factory; InitContext(); InitializeComponent(); mainContent.Content = new SingleDataBaseView(); }
public DD4TContentResolver(ILinkFactory componentLinkProvider, IComponentFactory componentFactory) { _componentLinkProvider = componentLinkProvider; _componentFactory = componentFactory; DefaultExtension = ".html"; DefaultExtensionLessPageName = "index"; DefaultPageName = DefaultExtensionLessPageName + DefaultExtension; }
public SentenceFormAdder(IComponentFactory componentFactory, RelationNameProcessor doesProcessor, RelationNameProcessor trueProcessor, GroundFact tempFact) { _componentFactory = componentFactory; _doesProcessor = doesProcessor; _trueProcessor = trueProcessor; _tempFact = tempFact; }
public TimersHistoryViewModel(DiteService diteService, INavigationService navigationService, IComponentFactory factory, IMessengerService messengerService) :base(factory, messengerService) { _diteService = diteService; _navigationService = navigationService; AddMessageListener<ObjectUpdated<TimerCounterDto>>(e => TimerCounterUpdated(e.Data)); ItemsCollection = new ObservableCollection<TimerCounterDto>(); }
public IdentityViewModel(DiteService diteService, INavigationService navigationService, IComponentFactory factory, IMessengerService messengerService, IIdentityService identityService) : base(factory, messengerService) { _diteService = diteService; _navigationService = navigationService; _identityService = identityService; }
public Player(IComponentFactory factory, IDataManager dataManager, ContentManager contentManager) { _componentFactory = factory; _contentManager = contentManager; _dataManager = dataManager; }
public Level(IComponentFactory componentFactory, IDataManager dataManager, ContentManager contentManager) { _componentFactory = componentFactory; _dataManager = dataManager; _contentManager = contentManager; }
public void Given_a_text_area_contains_multiple_lines_of_content() { _textArea = Substitute.For<TextArea>(); _componentFactory = SubstituteFor<IComponentFactory>(); _componentFactory .HtmlControlFor<TextArea>(_propertySelector) .Returns(_textArea); }
public void Given_a_web_element_has_an_attribute_data_value() { _componentFactory = SubstituteFor<IComponentFactory>(); _textBox = Substitute.For<TextBox>(); _componentFactory .HtmlControlFor<TextBox>(_textBoxPropertySelector) .Returns(_textBox); }
public void Given_a_drop_down_has_a_selected_option() { _componentFactory = SubstituteFor<IComponentFactory>(); _checkBox = Substitute.For<CheckBox>(); _componentFactory .HtmlControlFor<CheckBox>(_propertySelector) .Returns(_checkBox); }
public void Given_a_drop_down_exists() { _componentFactory = SubstituteFor<IComponentFactory>(); _dropDown = Substitute.For<DropDown>(); _componentFactory .HtmlControlFor<DropDown>(_dropDownPropertySelector) .Returns(_dropDown); }
public void Given_a_drop_down_exists() { _componentFactory = SubstituteFor<IComponentFactory>(); _radioButtonGroup = Substitute.For<RadioButtonGroup>(); _componentFactory .HtmlControlFor<RadioButtonGroup>(_radioButtonGroupPropertySelector) .Returns(_radioButtonGroup); }
public void Given_the_element_exists() { _componentFactory = SubstituteFor<IComponentFactory>(); _control = SubstituteFor<IHtmlControl>(); _componentFactory .HtmlControlFor<IHtmlControl>(_propertySelector) .Returns(_control); }
public void Given_a_drop_down_has_a_selected_option() { _componentFactory = SubstituteFor<IComponentFactory>(); _dropDown = Substitute.For<DropDown>(); _componentFactory .HtmlControlFor<DropDown>(_dropDownPropertySelector) .Returns(_dropDown); _dropDown.SelectedElementText.Returns("Selected option...."); }
public MainWindowViewModel(IComponentFactory factory) : base(factory) { ConnectionSettingsOpen = new RelayCommand(ConnectionSettingsOpenExecute); ConnectToDataBase = new RelayCommand(ConnectToDataBaseExecute, CanExecuteConnectToDataBase); DisconnectDataBase = new RelayCommand(DisconnectDataBaseExecute, CanExecuteDisconnectDataBase); LoadDataBaseFromFile = new RelayCommand(LoadDataBaseFromFileExecute, CanExecuteLoadDataBaseFromFile); SaveDataBaseToFile = new RelayCommand(SaveDataBaseToFileExecute, CanExecuteSaveDataBaseToFile); SaveDataBase = new RelayCommand(SaveDataBaseExecute, CanExecuteSaveDataBase); Exit = new RelayCommand(ExitExecute); }
public BaseNotifyAsync(IComponentFactory factory) : base(factory) { _worker = new System.ComponentModel.BackgroundWorker() { WorkerReportsProgress = true, WorkerSupportsCancellation = true }; _worker.DoWork += _worker_DoWork; _worker.ProgressChanged += _worker_ProgressChanged; _worker.RunWorkerCompleted += _worker_RunWorkerCompleted; }
/// <summary> /// Each subdir of <paramref name="rootDirectory"/> is considered a project. /// </summary> /// <param name="rootDirectory">the root path to start scanning from</param> /// <param name="scanner">the scanner to use</param> /// <returns></returns> public IEnumerable<ProjectBuilder> CreateProjectBuilders(string rootDirectory, IResourceIdFactory resourceIdFactory, IComponentFactory componentFactory) { foreach (var dir in GetProjectDirectories(rootDirectory)) { if (IsExcluded(dir)) continue; var filter = new MultiFilter<string>(Configuration.FileFilters); ProjectBuilder builder = new ProjectBuilder(dir, filter, resourceIdFactory, componentFactory); yield return builder; } }
public void Given_a_radio_group_has_a_selected_radio_button() { _componentFactory = SubstituteFor<IComponentFactory>(); _radioButtonGroup = Substitute.For<RadioButtonGroup>(); _componentFactory .HtmlControlFor<RadioButtonGroup>(_radioGroupPropertySelector) .Returns(_radioButtonGroup); _radioButtonGroup.SelectedElementAs<ChoiceType>().Returns(ChoiceType.Another); }
/// <summary> /// Creates a PropNet from a game description using the following process: /// <ol> /// <li>Flattens the game description to remove variables.</li> /// <li>Converts the flattened description into an equivalent PropNet.</li> /// </ol> /// </summary> /// <param name="description">A game description.</param> /// <param name="componentFactory"></param> /// <returns>An equivalent PropNet.</returns> public static PropNet Create(List<Expression> description, IComponentFactory componentFactory) { try { List<Implication> flatDescription = new PropNetFlattener(description).Flatten(); Logger.Info("Converting..."); return new PropNetConverter(componentFactory).Convert(GameContainer.GameInformation.GetRoles(), flatDescription); } catch (Exception e) { Logger.LogException(LogLevel.Error, "Error in propnet.factory", e); return null; } }
public ProjectBuilder(string projectPath, IFilter<string> fileFilter, IResourceIdFactory resourceIdFactory, IComponentFactory componentFactory) { if (string.IsNullOrEmpty(projectPath) || !Directory.Exists(projectPath)) throw new ArgumentException(string.Format("the projectPath supplied was null, empty, or a non existant path : '{0}'", projectPath ?? "[null]")); if (fileFilter == null) throw new ArgumentNullException("fileFilter"); _path = projectPath; _fileFilter = fileFilter; _resourceIdFactory = resourceIdFactory; _componentFactory = componentFactory; }
//private readonly ModuleFactory _moduleFactory; public TimersPageViewModel(DiteService diteService, INavigationService navigationService, IComponentFactory factory, IMessengerService messengerService) :base(factory, messengerService) { _diteService = diteService; _navigationService = navigationService; //_moduleFactory = moduleFactory; ItemsCollection = new ObservableCollection<TimerHandlerDto>(); AddMessageListener<ObjectUpdated<TimerHandlerDto>>(e => TimerHandlerUpdated(e.Data)); AddMessageListener<ObjectInserted<TimerHandlerDto>>(e => TimerHandlerInserted(e.Data)); AddMessageListener<ObjectDeleted<TimerHandlerDto>>(e => TimerHandlerDeleted(e.Data)); AddMessageListener<TimerStarted<TimerHandlerDto>>(e => TimerStarted(e.Data)); }
public ConcernChainComponentFactory( IConcern commissionChain, IConcern decomissionChain, IComponentModel model, IComponentFactory delegateFactory) { AssertUtil.ArgumentNotNull( commissionChain, "commissionChain" ); AssertUtil.ArgumentNotNull( decomissionChain, "decomissionChain" ); AssertUtil.ArgumentNotNull( model, "model" ); AssertUtil.ArgumentNotNull( delegateFactory, "delegateFactory" ); m_commissionChain = commissionChain; m_decomissionChain = decomissionChain; m_model = model; m_delegateFactory = delegateFactory; }
public static void Initialize() { var kernel = new StandardKernel(new RegistrationModule()); kernel.Load("DD4T.ContentModel.Contracts"); kernel.Load("DD4T.Factories"); kernel.Load("DD4T.Providers.Test"); PageFactory = kernel.Get<IPageFactory>(); ComponentPresentationFactory = kernel.Get<IComponentPresentationFactory>(); ComponentFactory = kernel.Get<IComponentFactory>(); PageFactory.CacheAgent = kernel.Get<ICacheAgent>(); PageFactory.PageProvider = kernel.Get<IPageProvider>(); ComponentPresentationFactory.CacheAgent = kernel.Get<ICacheAgent>(); ComponentPresentationFactory.ComponentPresentationProvider = kernel.Get<IComponentPresentationProvider>(); ((ComponentFactory)ComponentFactory).ComponentPresentationFactory = ComponentPresentationFactory; ((TridionPageProvider)PageFactory.PageProvider).SerializerService = kernel.Get<ISerializerService>(); ((TridionComponentPresentationProvider)ComponentPresentationFactory.ComponentPresentationProvider).SerializerService = kernel.Get<ISerializerService>(); ((TridionPageProvider)PageFactory.PageProvider).ComponentPresentationProvider = ComponentPresentationFactory.ComponentPresentationProvider; }
private void AddComponent(IComponentFactory factory) { //if (!CurrentState.DrawLock.TryEnterWriteLock(500)) //return; try { float previousHeight = OverallHeight; try { var componentFactory = ComponentManager.ComponentFactories.FirstOrDefault(x => x.Value.ComponentName == factory.ComponentName); var component = componentFactory.Value == null ? new LayoutComponent("", new SeparatorComponent()) : new LayoutComponent(componentFactory.Key, componentFactory.Value.Create(CurrentState)); Action y = () => { try { BindingList.Add(component); } catch (Exception ex) { Log.Error(ex); } }; if (Form.InvokeRequired) Form.Invoke(y); else y(); Layout.HasChanged = true; if (LayoutResized != null) LayoutResized(this, null); } catch (Exception e) { Log.Error(e); MessageBox.Show(this, "The Component could not be loaded.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } finally { //CurrentState.DrawLock.ExitWriteLock(); } }
public virtual void Register(IComponentFactory componentFactory) { Register((string)null, componentFactory); }
public EntityParser() { _componentFactory = IocContainer.Resolve <IComponentFactory>(); }
public AzureServiceBusQueue(IComponentFactory factory, IConfiguration configuration, IChannelPathBuilder builder, int maxconcurrentcalls = 0, TimeSpan?autorenewtimeout = null) : base(factory, configuration, builder) { _maxconcurrentcalls = maxconcurrentcalls; _autorenewtimeout = autorenewtimeout; }
public async Task TestNelderMeadSweeperAsync() { var random = new Random(42); using (var env = new ConsoleEnvironment(42)) { int batchSize = 5; int sweeps = 40; var paramSets = new List <ParameterSet>(); var args = new DeterministicSweeperAsync.Arguments(); args.BatchSize = batchSize; args.Relaxation = 0; args.Sweeper = ComponentFactoryUtils.CreateFromFunction( environ => { var param = new IComponentFactory <INumericValueGenerator>[] { ComponentFactoryUtils.CreateFromFunction( innerEnviron => new FloatValueGenerator(new FloatParamArguments() { Name = "foo", Min = 1, Max = 5 })), ComponentFactoryUtils.CreateFromFunction( innerEnviron => new LongValueGenerator(new LongParamArguments() { Name = "bar", Min = 1, Max = 1000, LogBase = true })) }; var nelderMeadSweeperArgs = new NelderMeadSweeper.Arguments() { SweptParameters = param, FirstBatchSweeper = ComponentFactoryUtils.CreateFromFunction <IValueGenerator[], ISweeper>( (firstBatchSweeperEnviron, firstBatchSweeperArgs) => new RandomGridSweeper(environ, new RandomGridSweeper.Arguments() { SweptParameters = param })) }; return(new NelderMeadSweeper(environ, nelderMeadSweeperArgs)); } ); var sweeper = new DeterministicSweeperAsync(env, args); var mlock = new object(); double[] metrics = new double[sweeps]; for (int i = 0; i < metrics.Length; i++) { metrics[i] = random.NextDouble(); } for (int i = 0; i < sweeps; i++) { var paramWithId = await sweeper.Propose(); if (paramWithId == null) { return; } var result = new RunResult(paramWithId.ParameterSet, metrics[i], true); sweeper.Update(paramWithId.Id, result); lock (mlock) paramSets.Add(paramWithId.ParameterSet); } Assert.True(paramSets.Count <= sweeps); CheckAsyncSweeperResult(paramSets); } }
public PointToPointHandler(IComponentFactory factory, IConfiguration configuration) { _factory = factory; _configuration = configuration; }
public static IPredictor Train(IHostEnvironment env, IChannel ch, RoleMappedData data, ITrainer trainer, IComponentFactory <ICalibratorTrainer> calibrator, int maxCalibrationExamples) { return(TrainCore(env, ch, data, trainer, null, calibrator, maxCalibrationExamples, false)); }
public PointToPointChannelMonitor(IRouterConfigurationSource[] sources, IComponentFactory factory, IConfiguration configuration) { _sources = sources; _factory = factory; _configuration = configuration; }
public GameObjectFactory(IComponentFactory componentFactory) { _componentFactory = componentFactory; }
/// <summary> /// Creates an entity from this template /// </summary> /// <returns></returns> public IEntity CreateEntity(IEntityManager manager, IEntityNetworkManager networkManager, IComponentFactory componentFactory) { var entity = (IEntity)Activator.CreateInstance(ClassType, manager, networkManager, componentFactory); entity.Name = Name; entity.Prototype = this; foreach (KeyValuePair <string, YamlMappingNode> componentData in Components) { IComponent component = componentFactory.GetComponent(componentData.Key); component.LoadParameters(componentData.Value); entity.AddComponent(component); } entity.LoadData(DataNode); return(entity); }
/// <summary> /// Initializes a new instance of the <see cref="HealthcheckService"/> class. /// </summary> /// <param name="componentFactory">The component factory.</param> public HealthcheckService(IComponentFactory componentFactory) { this.componentFactory = componentFactory; }
protected AbstractPointToPointChannel(IComponentFactory factory, IConfiguration configuration, ILogger logger) : base("point to point", factory, configuration, logger) { }
/// <summary> /// Initializes a new instance of DefaultClientConnection /// </summary> public DefaultClientConnection() { this.ComponentFactory = new DefaultComponentFactory(); this.AcceptConnections = true; this.timeoutTimer.Elapsed += timeoutTimer_Elapsed; }
/// <summary> /// Describes how the transformer handles one column pair. /// </summary> /// <param name="name">Name of the column resulting from the transformation of <paramref name="inputColumnName"/>.</param> /// <param name="newDim">The number of random Fourier features to create.</param> /// <param name="useSin">Create two features for every random Fourier frequency? (one for cos and one for sin).</param> /// <param name="inputColumnName">Name of column to transform. </param> /// <param name="generator">Which fourier generator to use.</param> /// <param name="seed">The seed of the random number generator for generating the new features (if unspecified, the global random is used.</param> public ColumnInfo(string name, int newDim, bool useSin, string inputColumnName = null, IComponentFactory <float, IFourierDistributionSampler> generator = null, int?seed = null) { Contracts.CheckUserArg(newDim > 0, nameof(newDim), "must be positive."); InputColumnName = inputColumnName ?? name; Name = name; Generator = generator ?? new GaussianFourierSampler.Arguments(); NewDim = newDim; UseSin = useSin; Seed = seed; }
public static IPredictor Train(IHostEnvironment env, IChannel ch, RoleMappedData data, ITrainer trainer, RoleMappedData validData, IComponentFactory <ICalibratorTrainer> calibrator, int maxCalibrationExamples, bool?cacheData, IPredictor inputPredictor = null) { return(TrainCore(env, ch, data, trainer, validData, calibrator, maxCalibrationExamples, cacheData, inputPredictor)); }
public WorkOrderViewPage(IWebDriver searchContext, By @by, IComponentFactory componentFactory) : base(searchContext, @by, componentFactory) { }
public AzureServiceBusTopic(IComponentFactory factory, IConfiguration configuration, ILogger logger, int maxconcurrentcalls = 0, TimeSpan?autorenewtimeout = null) : base(factory, configuration, logger) { _maxconcurrentcalls = maxconcurrentcalls; _autorenewtimeout = autorenewtimeout; }
public void OnComponentRetrieved(ContractIdentity identity, IComponentFactory componentFactory, Type componentTargetType, ref object componentInstance, object originalInstance) { }
public StartupTask(IComponentFactory factory, IConfiguration configuration) { _factory = factory; _configuration = configuration; }
public void TestNelderMeadSweeper() { var random = new Random(42); using (var env = new ConsoleEnvironment(42)) { var param = new IComponentFactory <INumericValueGenerator>[] { ComponentFactoryUtils.CreateFromFunction( environ => new FloatValueGenerator(new FloatParamArguments() { Name = "foo", Min = 1, Max = 5 })), ComponentFactoryUtils.CreateFromFunction( environ => new LongValueGenerator(new LongParamArguments() { Name = "bar", Min = 1, Max = 1000, LogBase = true })) }; var args = new NelderMeadSweeper.Arguments() { SweptParameters = param, FirstBatchSweeper = ComponentFactoryUtils.CreateFromFunction <IValueGenerator[], ISweeper>( (environ, firstBatchArgs) => { return(new RandomGridSweeper(environ, new RandomGridSweeper.Arguments() { SweptParameters = param })); } ) }; var sweeper = new NelderMeadSweeper(env, args); var sweeps = sweeper.ProposeSweeps(5, new List <RunResult>()); Assert.Equal(3, sweeps.Length); var results = new List <IRunResult>(); for (int i = 1; i < 10; i++) { foreach (var parameterSet in sweeps) { foreach (var parameterValue in parameterSet) { if (parameterValue.Name == "foo") { var val = float.Parse(parameterValue.ValueText, CultureInfo.InvariantCulture); Assert.InRange(val, 1, 5); } else if (parameterValue.Name == "bar") { var val = long.Parse(parameterValue.ValueText); Assert.InRange(val, 1, 1000); } else { Assert.True(false, "Wrong parameter"); } } results.Add(new RunResult(parameterSet, random.NextDouble(), true)); } sweeps = sweeper.ProposeSweeps(5, results); } Assert.True(sweeps.Length <= 5); } }
public ShutdownTask(IComponentFactory factory, IConfiguration configuration) { _factory = factory; _configuration = configuration; }
public PageReader(IExecutor executor, IElementFinder elementFinder, IComponentFactory componentFactory) { _executor = executor; _elementFinder = elementFinder; _componentFactory = componentFactory; }
public BrokeredMessageAdapter(IComponentFactory factory, IConfiguration configuration, IBus bus) : base(factory, configuration, bus) { }
public SagaStorageSearcher(IComponentFactory factory, IConfiguration configuration) { _factory = factory; _configuration = configuration; }
public SpecPrinter(IComponentFactory componentFactory, ListBox displayBox) { this.componentFactory = componentFactory; this.displayBox = displayBox; }
/// <summary> /// Method to convert set of sweepable hyperparameters into <see cref="IComponentFactory"/> instances used /// by the current smart hyperparameter sweepers. /// </summary> public static IComponentFactory <IValueGenerator>[] ConvertToComponentFactories(TlcModule.SweepableParamAttribute[] hps) { var results = new IComponentFactory <IValueGenerator> [hps.Length]; for (int i = 0; i < hps.Length; i++) { switch (hps[i]) { case TlcModule.SweepableDiscreteParamAttribute dp: results[i] = ComponentFactoryUtils.CreateFromFunction(env => { var dpArgs = new DiscreteParamArguments() { Name = dp.Name, Values = dp.Options.Select(o => o.ToString()).ToArray() }; return(new DiscreteValueGenerator(dpArgs)); }); break; case TlcModule.SweepableFloatParamAttribute fp: results[i] = ComponentFactoryUtils.CreateFromFunction(env => { var fpArgs = new FloatParamArguments() { Name = fp.Name, Min = fp.Min, Max = fp.Max, LogBase = fp.IsLogScale, }; if (fp.NumSteps.HasValue) { fpArgs.NumSteps = fp.NumSteps.Value; } if (fp.StepSize.HasValue) { fpArgs.StepSize = fp.StepSize.Value; } return(new FloatValueGenerator(fpArgs)); }); break; case TlcModule.SweepableLongParamAttribute lp: results[i] = ComponentFactoryUtils.CreateFromFunction(env => { var lpArgs = new LongParamArguments() { Name = lp.Name, Min = lp.Min, Max = lp.Max, LogBase = lp.IsLogScale }; if (lp.NumSteps.HasValue) { lpArgs.NumSteps = lp.NumSteps.Value; } if (lp.StepSize.HasValue) { lpArgs.StepSize = lp.StepSize.Value; } return(new LongValueGenerator(lpArgs)); }); break; } } return(results); }
public OneHotEncodingEstimator(IHostEnvironment env, ColumnInfo[] columns, string file = null, string termsColumn = null, IComponentFactory <IMultiStreamSource, IDataLoader> loaderFactory = null) { Contracts.CheckValue(env, nameof(env)); _host = env.Register(nameof(OneHotEncodingEstimator)); _term = new ValueToKeyMappingEstimator(_host, columns, file, termsColumn, loaderFactory); var binaryCols = new List <(string input, string output)>(); var cols = new List <(string input, string output, bool bag)>(); for (int i = 0; i < columns.Length; i++) { var column = columns[i]; OneHotEncodingTransformer.OutputKind kind = columns[i].OutputKind; switch (kind) { default: throw _host.ExceptUserArg(nameof(column.OutputKind)); case OneHotEncodingTransformer.OutputKind.Key: continue; case OneHotEncodingTransformer.OutputKind.Bin: binaryCols.Add((column.Output, column.Output)); break; case OneHotEncodingTransformer.OutputKind.Ind: cols.Add((column.Output, column.Output, false)); break; case OneHotEncodingTransformer.OutputKind.Bag: cols.Add((column.Output, column.Output, true)); break; } } IEstimator <ITransformer> toBinVector = null; IEstimator <ITransformer> toVector = null; if (binaryCols.Count > 0) { toBinVector = new KeyToBinaryVectorMappingEstimator(_host, binaryCols.Select(x => new KeyToBinaryVectorMappingTransformer.ColumnInfo(x.input, x.output)).ToArray()); } if (cols.Count > 0) { toVector = new KeyToVectorMappingEstimator(_host, cols.Select(x => new KeyToVectorMappingTransformer.ColumnInfo(x.input, x.output, x.bag)).ToArray()); } if (toBinVector != null && toVector != null) { _toSomething = toVector.Append(toBinVector); } else { if (toBinVector != null) { _toSomething = toBinVector; } else { _toSomething = toVector; } } }
public static IDataTransform Create(IHostEnvironment env, Arguments args, IDataView input, IComponentFactory <IPredictor, ISchemaBindableMapper> mapperFactory) { Contracts.CheckValue(env, nameof(env)); env.CheckValue(args, nameof(args)); env.CheckValue(args.Trainer, nameof(args.Trainer), "Trainer cannot be null. If your model is already trained, please use ScoreTransform instead."); env.CheckValue(input, nameof(input)); env.CheckValueOrNull(mapperFactory); return(Create(env, args, args.Trainer.CreateComponent(env), input, mapperFactory)); }
public virtual void Register(Type contract, IComponentFactory factory) { Register(contract, null, factory); }
public Background(IComponentFactory componentFactory, IContentManager content) { _componentFactory = componentFactory; _content = content; }
private static IDataTransform Create(IHostEnvironment env, Arguments args, ITrainer trainer, IDataView input, IComponentFactory <IPredictor, ISchemaBindableMapper> mapperFactory) { Contracts.AssertValue(env, nameof(env)); env.AssertValue(args, nameof(args)); env.AssertValue(trainer, nameof(trainer)); env.AssertValue(input, nameof(input)); var host = env.Register("TrainAndScoreTransform"); using (var ch = host.Start("Train")) { ch.Trace("Constructing trainer"); var customCols = TrainUtils.CheckAndGenerateCustomColumns(env, args.CustomColumn); string feat; string group; var data = CreateDataFromArgs(ch, input, args, out feat, out group); var predictor = TrainUtils.Train(host, ch, data, trainer, null, args.Calibrator, args.MaxCalibrationExamples, null); return(ScoreUtils.GetScorer(args.Scorer, predictor, input, feat, group, customCols, env, data.Schema, mapperFactory)); } }