public DocumentAnomalyData Resolve(string name, Document[] documents) { IModelStorage model = modelStorageFactory.Construct(name); if (model.Current == null) { throw new ArgumentOutOfRangeException(nameof(name), "Unknown model"); } bool[] result = model.Current.Predict(new DocumentBlock(documents).Pages); List <Document> positive = new List <Document>(); List <Document> negative = new List <Document>(); for (int i = 0; i < result.Length; i++) { List <Document> list = result[i] ? positive : negative; list.Add(documents[i]); } return(new DocumentAnomalyData { Name = name, Negative = negative.ToArray(), Positive = positive.ToArray() }); }
public SentenceAnomalyData Resolve(string name, Document document) { IModelStorage model = modelStorageFactory.Construct(name); if (model.Current == null) { throw new ArgumentOutOfRangeException(nameof(name), "Unknown model"); } bool[] result = model.Current.Predict(document.Sentences.Select(item => new ProcessingTextBlock(item)).ToArray()); List <SentenceItem> positive = new List <SentenceItem>(); List <SentenceItem> negative = new List <SentenceItem>(); for (int i = 0; i < result.Length; i++) { List <SentenceItem> list = result[i] ? positive : negative; list.Add(document.Sentences[i]); } return(new SentenceAnomalyData { Name = name, Negative = negative.ToArray(), Positive = positive.ToArray() }); }
public void Reset(string name) { if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentException("Value cannot be null or whitespace.", nameof(name)); } IModelStorage model = modelStorageFactory.Construct(name); model.Reset(); modelStorageFactory.Save(name, model); }
public async Task Train(string name) { if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentException("Value cannot be null or whitespace.", nameof(name)); } IModelStorage model = modelStorageFactory.Construct(name); await model.Train(CancellationToken.None).ConfigureAwait(false); modelStorageFactory.Save(name, model); }
private void CheckStorage(IModelStorage storage) { if (storage.State != LoadingState.Loaded) return; storage.StateChanged -= CheckStorage; foreach (var mod in storage.GetMods()) { AddStorageMod(mod); } storage.AddedMod += AddStorageMod; OnAnyChange(); }
public MemoryRepository(IModelStorage modelStore) { storage = modelStore; new List <Product> { new Product { Name = "Kayak", Price = 275M }, new Product { Name = "Lifejacket", Price = 48.95M }, new Product { Name = "Soccer ball", Price = 19.50M } }.ForEach(p => AddProduct(p)); }
public ProductRepositoryImpl(IModelStorage modelStorage) { _storage = modelStorage; new List <Product> { new Product { Name = "Kajak", Price = 275M }, new Product { Name = "Kamizelka", Price = 48.95M }, new Product { Name = "Pilka nozna", Price = 19.50M } }.ForEach(AddProduct); }
public MemoryRepository(IModelStorage modelStore) { storage = modelStore; new List <Product> { new Product { Name = "Kajak", Price = 275M }, new Product { Name = "Kamizelka ratunkowa", Price = 48.95M }, new Product { Name = "Piłka nożna", Price = 19.50M } }.ForEach(p => AddProduct(p)); }
//private Dictionary<string, Product> products; public MemoryRepository(IModelStorage modelStore) { storage = modelStore; new List <Product> { new Product { Name = "Bate", Price = 15.50M }, new Product { Name = "Helmet", Price = 22.15M }, new Product { Name = "Soccer ball", Price = 16.50M } }.ForEach(p => AddProduct(p)); }
public void Save(string name, IModelStorage storage) { if (storage == null) { throw new ArgumentNullException(nameof(storage)); } if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentException("Value cannot be null or whitespace.", nameof(name)); } var location = Path.Combine(config.Location, name); storage.Save(location); }
public MemoryRepository(IModelStorage modelStorage) { this.modelStorage = modelStorage; products = new Dictionary <string, Product>(); new List <Product> { new Product { Name = "Kayak", Price = 275m }, new Product { Name = "Lifejacket", Price = 48.95m }, new Product { Name = "Soccer ball", Price = 19.50m } }.ForEach(p => AddProduct(p)); }
public MemoryRepository(IModelStorage storage) { //products = new Dictionary<string, Product>(); this.storage = storage; new List <Product> { new Product { Name = "Kayak", Price = 275M }, new Product { Name = "Life Jacket", Price = 48.95M }, new Product { Name = "Soccer Ball", Price = 19.50M } }.ForEach(p => AddProduct(p)); }
public void Add(DocumentAnomalyData anomalyData) { if (anomalyData == null) { throw new ArgumentNullException(nameof(anomalyData)); } IModelStorage model = modelStorageFactory.Construct(anomalyData.Name); if (anomalyData.Positive?.Length > 0) { model.Add(DataType.Positive, anomalyData.Positive.Select(item => new ProcessingTextBlock(item.Sentences.ToArray())).ToArray()); } if (anomalyData.Negative?.Length > 0) { model.Add(DataType.Negative, anomalyData.Negative.Select(item => new ProcessingTextBlock(item.Sentences.ToArray())).ToArray()); } modelStorageFactory.Save(anomalyData.Name, model); }
public static string GetAvailableDownloadIdentifier(IModelStorage storage, string baseIdentifier) { bool Exists(string name) { return(storage.GetMods().Any( m => string.Equals(m.Identifier, name, StringComparison.InvariantCultureIgnoreCase))); } if (!Exists(baseIdentifier)) { return(baseIdentifier); } var i = 1; while (true) { var name = $"{baseIdentifier}_{i}"; if (!Exists(name)) { return(name); } i++; } }
private void AddedStorage(IModelStorage storage) { _logger.Trace($"Added storage {storage.Name}"); storage.StateChanged += CheckStorage; CheckStorage(storage); }
protected override void ProcessModel(IModelStorage model) { NNModelStorage nn_model = (NNModelStorage)model; this.txtReinitializations.Text = nn_model.Reinitializations.ToString(); this.Reinitializations = nn_model.Reinitializations; this.txtEpochs.Text = nn_model.Epochs.ToString(); mSelectedActivationNetwork = nn_model.SelectedNetwork; mBestActivationNetwork = nn_model.BestNetwork; mBestTestActivationNetwork = nn_model.BestTestNetwork; this.mEpochs = nn_model.Epochs; foreach (int var_id in nn_model.IndepVariables) { AddVarToInDep(var_id); } foreach (int var_id in nn_model.DepVariables) { AddVarToDep(var_id); } SetTestSamples(nn_model.TestSamples); CalculateExtractInformation(); FillAutomatedFields(); }
public MatcherModel(IModelSelector selector, IModelStorage storage) { Folder = storage.Open(selector.Path); }
internal StorageSelection(IModelStorage storage) { Storage = storage; }
internal SelectStorage(IModelStorage downloadStorage) { DownloadStorage = downloadStorage; }
public ClassifierModel(IModelSelector selector, IModelStorage storage) { Folder = storage.Open(selector.Path); }
protected virtual void ProcessModel(IModelStorage model) { throw new NotImplementedException(); }
public ModSelectionDownload(IModelStorage storage) { DownloadStorage = storage; }