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();
        }
示例#6
0
 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));
        }
示例#10
0
        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);
        }
示例#11
0
 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));
 }
示例#12
0
 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);
        }
示例#14
0
        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);
 }
示例#16
0
        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();
        }
示例#17
0
 public MatcherModel(IModelSelector selector, IModelStorage storage)
 {
     Folder = storage.Open(selector.Path);
 }
示例#18
0
 internal StorageSelection(IModelStorage storage)
 {
     Storage = storage;
 }
示例#19
0
 internal SelectStorage(IModelStorage downloadStorage)
 {
     DownloadStorage = downloadStorage;
 }
示例#20
0
 public ClassifierModel(IModelSelector selector, IModelStorage storage)
 {
     Folder = storage.Open(selector.Path);
 }
示例#21
0
 protected virtual void ProcessModel(IModelStorage model)
 {
     throw new NotImplementedException();
 }
示例#22
0
 public ModSelectionDownload(IModelStorage storage)
 {
     DownloadStorage = storage;
 }