Example #1
0
            public Mapper(IHostEnvironment env, SequentialAnomalyDetectionTransformBase <TInput, TState> parent, Schema inputSchema)
            {
                Contracts.CheckValue(env, nameof(env));
                _host = env.Register(nameof(Mapper));
                _host.CheckValue(inputSchema, nameof(inputSchema));
                _host.CheckValue(parent, nameof(parent));

                if (!inputSchema.TryGetColumnIndex(parent.InputColumnName, out _inputColumnIndex))
                {
                    throw _host.ExceptSchemaMismatch(nameof(inputSchema), "input", parent.InputColumnName);
                }

                var colType = inputSchema[_inputColumnIndex].Type;

                if (colType != NumberType.R4)
                {
                    throw _host.ExceptSchemaMismatch(nameof(inputSchema), "input", parent.InputColumnName, NumberType.R4.ToString(), colType.ToString());
                }

                _parent       = parent;
                _parentSchema = inputSchema;
                _slotNames    = new VBuffer <ReadOnlyMemory <char> >(4, new[] { "Alert".AsMemory(), "Raw Score".AsMemory(),
                                                                                "P-Value Score".AsMemory(), "Martingale Score".AsMemory() });

                State = _parent.StateRef;
            }
Example #2
0
            private protected override sealed void InitializeStateCore(bool disk = false)
            {
                Parent = (SequentialAnomalyDetectionTransformBase <TInput, TState>)ParentTransform;
                Host.Assert(WindowSize >= 0);

                if (disk == false)
                {
                    if (Parent.Martingale != MartingaleType.None)
                    {
                        LogMartingaleUpdateBuffer = new FixedSizeQueue <Double>(WindowSize == 0 ? 1 : WindowSize);
                    }
                    else
                    {
                        LogMartingaleUpdateBuffer = new FixedSizeQueue <Double>(1);
                    }

                    RawScoreBuffer = new FixedSizeQueue <float>(WindowSize == 0 ? 1 : WindowSize);

                    _logMartingaleValue = 0;
                }

                InitializeAnomalyDetector();
            }