private RecordInstrument NewRecord() { var valueInstrument = new RecordInstrument() { Values = new Dictionary <string, string>() }; foreach (var instrument in this.instruments) { valueInstrument.Values.Add(instrument.Key, null); if (instrument.Key == "completed") { valueInstrument.Values["completed"] = CompletedDefaultValue; } } return(valueInstrument); }
static public string GetDatasetRecord(RecordInstrument record, List <SchemaInstrument> instruments, bool includeAllColumns, bool includePrediction) { var message = string.Empty; var predictValues = new Dictionary <string, string>(); message += $"{record.Time},{record.TimeDiff}"; foreach (var value in record.Values) { var instrument = instruments.Find(x => x.Key.Equals(value.Key)); if (instrument != null && (((instrument.IsColumn || includeAllColumns) && !includePrediction) || (!instrument.IsSignal && includePrediction && instrument.IsColumn))) { message += (string.IsNullOrEmpty(message) ? "" : ","); if (value.Value == null && !instrument.IsFuture) { message += string.Empty; } if (value.Value == null && instrument.IsFuture) { message += "-1"; } else if (instrument.DataType == enmDataType.@double) { message += (IsNumeric(value.Value) ? $"{string.Format("{0:0.00}", double.Parse(value.Value))}" : "0.00"); } else if (instrument.DataType == enmDataType.@double6) { message += (IsNumeric(value.Value) ? $"{string.Format("{0:0.000000}", double.Parse(value.Value))}" : "0.000000"); } else if (instrument.DataType == enmDataType.@int) { message += (IsNumeric(value.Value) ? $"{string.Format("{0:0}", int.Parse(value.Value))}" : "0"); } else if (instrument.DataType == enmDataType.@long) { message += (IsNumeric(value.Value) ? $"{string.Format("{0:0}", long.Parse(value.Value))}" : "0"); } else if (instrument.DataType == enmDataType.@string) { message += $"\"{value.Value}\""; } if (IGClient.ML.CurrentMetric != null && includePrediction && IGClient.ML.CurrentMetric.Columns.Where(x => x.EndsWith(value.Key)).Count() > 0) { predictValues.Add(value.Key, value.Value); } } } if (includePrediction && predictValues.Count > 0 && !record.Values["completed"].Contains("X")) { var tempRecord = new RecordInstrument() { Time = record.Time, Values = predictValues }; //var prediction = IGClient.ML.Predict(tempRecord); //if (prediction != null) message += (string.IsNullOrEmpty(message) ? "" : ", ") + $"p={string.Format("{0:0.000}", prediction.Label)}"; } return(message); }