Beispiel #1
0
        public List <AnomalyRecord> GetADResults()
        {
            var rowDelim = ";";
            var colDelim = ",";
            var rows     = table.Split(new string[] { rowDelim }, StringSplitOptions.RemoveEmptyEntries);

            List <AnomalyRecord> series = new List <AnomalyRecord>();

            for (int i = 0; i < rows.Length; i++)
            {
                var row = rows[i].Replace("\"", "").Trim();
                if (i == 0 || row.Length == 0)
                {
                    continue; // ignore headers and empty rows
                }

                var cols = row.Split(new string[] { colDelim }, StringSplitOptions.RemoveEmptyEntries);
                series.Add(AnomalyRecord.Parse(cols));
            }
            return(series);
        }
Beispiel #2
0
        private static string OutputResults(string from, SensorDataContract sensorMeta, AnomalyRecord alert)
        {
            return(JsonConvert.SerializeObject(
                       new
            {
                guid = sensorMeta.Guid,
                displayname = sensorMeta.DisplayName,
                measurename = sensorMeta.MeasureName,
                unitofmeasure = sensorMeta.UnitOfMeasure,
                location = sensorMeta.Location,
                organization = sensorMeta.Organization,

                timecreated = alert.Time.ToLocalTime(),
                value = alert.Data,
                alerttype = "MLModelAlert",
                message = "Anomaly detected by Machine Learning model."
            }));
        }