private void NormaliseData() { List <List <Patient> > dataLists = new List <List <Patient> > { dataList, inputList }; List <Patient> dataListCopy = new List <Patient>(); List <Patient> inputListCopy = new List <Patient>(); foreach (var item in dataList) { Patient newPatient = new Patient(); newPatient.SetAttributes(item.GetAllAttributes().Values.ToArray()); dataListCopy.Add(newPatient); } int count = 0; foreach (var data in dataLists) { for (int feature = 0; feature < patientFeatures.Count - 2; feature++) { List <double> featureValues = new List <double>(); foreach (var item in dataListCopy) { featureValues.Add(item.GetSingleAttribute(feature)); } double minValue = featureValues.Min(); double maxValue = featureValues.Max(); for (int patient = 0; patient < data.Count; patient++) { //if value should be normalised and isn't -> normalise double currentValue = data[patient].GetSingleAttribute(feature); if ((maxValue > 1 && count == 0) || (currentValue >= 1 && count == 1)) { double normalisedValue = Math.Round(((currentValue - minValue) / (maxValue - minValue)), 4); data[patient].SetSingleAttribute(feature, normalisedValue); } } } count++; } }
public static void AddPatient(string[] newPatient, string file, string classification) { if (newPatient.Length > 0) { Patient patient = new Patient(); patient.SetAttributes(newPatient.Skip(1).ToArray()); if (file.Contains("Input")) { patient.ID = Convert.ToInt32(newPatient[0]); if (typeof(Patient.Classification).IsEnumDefined(classification)) { patient.GivenDiagnosis = (Patient.Classification)Enum.Parse(typeof(Patient.Classification), classification); } else { patient.GivenDiagnosis = Patient.Classification.Unknown; } inputList.Add(patient); } else if (file.Contains("Attribute")) { AttributeRanking attr = new AttributeRanking(); attr.SetAttributeRanking(newPatient); rankingList.Add(attr); } else { patient.ID = Convert.ToInt32(newPatient[0]); if (typeof(Patient.Classification).IsEnumDefined(classification)) { patient.Diagnosis = (Patient.Classification)Enum.Parse(typeof(Patient.Classification), classification); } dataList.Add(patient); } } }