Exemple #1
0
 public void SetUp()
 {
     GlobalSettings.Random = new Random(48);
     vectorSource          = new EmbeddingVectorSource(WordModel.Load(Path.Combine(TestContext.CurrentContext.TestDirectory, @"Data\model.bin")));
     pageDetector          = new SvmAnomalyDetector(vectorSource, new NullLoggerFactory(), null);
     document = new DocumentBlock(JsonConvert.DeserializeObject <Document[]>(File.ReadAllText(Path.Combine(TestContext.CurrentContext.TestDirectory, "Data", "docs.json"))));
 }
Exemple #2
0
 public SvmModelStorage(ILoggerFactory factory, IDocumentVectorSource vectorSource, IDocumentReconstructor reconstructor)
 {
     this.vectorSource  = vectorSource ?? throw new ArgumentNullException(nameof(vectorSource));
     this.factory       = factory ?? throw new ArgumentNullException(nameof(factory));
     this.reconstructor = reconstructor ?? throw new ArgumentNullException(nameof(reconstructor));
     logger             = factory.CreateLogger <SvmModelStorage>();
 }
Exemple #3
0
 public void SetUp()
 {
     loggerFactory         = new NullLoggerFactory();
     vectorSource          = new EmbeddingVectorSource(WordModel.Load(Path.Combine(TestContext.CurrentContext.TestDirectory, @"Data\model.bin")));
     documentReconstructor = new DocumentReconstructor();
     documents             = JsonConvert.DeserializeObject <Document[]>(File.ReadAllText(Path.Combine(TestContext.CurrentContext.TestDirectory, "Data", "docs.json")));
     instance = CreateModelStorage();
 }
Exemple #4
0
 public SvmModelStorageFactory(ILoggerFactory factory, IDocumentVectorSource vectorSource, IDocumentReconstructor reconstructor, StorageConfig config)
 {
     this.factory       = factory ?? throw new ArgumentNullException(nameof(factory));
     this.vectorSource  = vectorSource ?? throw new ArgumentNullException(nameof(vectorSource));
     this.reconstructor = reconstructor ?? throw new ArgumentNullException(nameof(reconstructor));
     this.config        = config ?? throw new ArgumentNullException(nameof(config));
     if (config.Location == null)
     {
         throw new ArgumentNullException(nameof(config.Location));
     }
 }
        public SvmAnomalyDetector(IDocumentVectorSource vectorSource, ILoggerFactory factory, SupportVectorMachine <Linear> model)
        {
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }

            this.vectorSource = vectorSource ?? throw new ArgumentNullException(nameof(vectorSource));
            logger            = factory.CreateLogger(GetType());
            Model             = model;
        }
        public static double[][] GetVectors(this IDocumentVectorSource source, IProcessingTextBlock[] blocks, NormalizationType normalization)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }
            if (blocks == null)
            {
                throw new ArgumentNullException(nameof(blocks));
            }

            double[][] observations = new double[blocks.Length][];

            Parallel.For(0,
                         blocks.Length,
                         i =>
            {
                var result      = source.GetVector(blocks[i], normalization).FullValues;
                observations[i] = result;
            });

            return(observations);
        }
Exemple #7
0
 public AnomalyFilterFactory(IDocumentVectorSource vectorSource)
 {
     this.vectorSource = vectorSource ?? throw new ArgumentNullException(nameof(vectorSource));
 }
 public AnomalyFactory(IDocumentVectorSource documentVector)
 {
     this.documentVector = documentVector ?? throw new ArgumentNullException(nameof(documentVector));
 }