public CaseItem SaveCaseItem(CaseItem item) { if (item == null) return item; if (item.CaseId <= 0) return item; SetDefaultTime(item); return CasesData.SaveCaseItems(new List<CaseItem>() { item }).First(); }
public List<CaseItem> LoadCaseItemsByCaseId(int caseId) { var items = CasesData.LoadCaseItemsByCaseId(caseId); items.Sort(CaseItemDisplayOrderComparer.Instance); LoadCaseItemAttachment(items); return items; }
public Cases GetCase(int caseId) { Cases cases = CasesData.GetCase(caseId); if (cases != null) { cases.CaseItems = CasesData.LoadCaseItemsByCaseId(caseId); cases.CaseItems = cases.CaseItems ?? new List<CaseItem>(0); LoadCaseItemAttachment(cases.CaseItems); } return cases; }
private IList <RegressionPoint> MakeRegressionPointList(CasesData dataSet) { IList <RegressionPoint> points = new List <RegressionPoint>(); for (int i = 0; i < dataSet.CasesCount; i++) { points.Add(new RegressionPoint(dataSet.GetInput(i).At(0), dataSet.GetIdealOutput(i).At(0))); } return(points); }
public List<Cases> LoadCases(Pagination pagination, CaseType caseType) { var cases = CasesData.LoadCases(pagination, caseType); LoadCaseItems(cases); if (cases != null && cases.Count > 0) { var items = new List<CaseItem>(); cases.ForEach(c => { if (c.CaseItems != null)items.AddRange(c.CaseItems); }); LoadCaseItemAttachment(items); } return cases ?? new List<Cases>(0); }
private IList <ClassificationPoint> MakeClassificationPointList(CasesData dataSet) { IList <ClassificationPoint> points = new List <ClassificationPoint>(); for (int i = 0; i < dataSet.CasesCount; i++) { points.Add(new ClassificationPoint(dataSet.GetInput(i).At(0), dataSet.GetInput(i).At(1), (int)dataSet.GetClasificationOutput(i).At(0))); } return(points); }
public Cases SaveCase(Cases cases) { SetDefaultTime(cases); cases = CasesData.SaveCase(cases); if (cases.CaseItems != null && cases.CaseItems.Count > 0) { cases.CaseItems.ForEach(SetDefaultTime); cases.CaseItems = CasesData.SaveCaseItems(cases.CaseItems); } return cases; }
private void StartButtonClick(object sender, RoutedEventArgs e) { var layers = LayersTextBox.Text.Split(new string[] { ",", " ", "-", "_", "." }, StringSplitOptions.RemoveEmptyEntries); List <int> layersVal = new List <int>(); foreach (var layer in layers) { layersVal.Add(int.Parse(layer)); } YesNo bias = (YesNo)BiasCombobox.SelectedItem; ActivationFunction activation = (ActivationFunction)ActivationCombobox.SelectedItem; int iterations = int.Parse(Iterations.Text); double learningRate = LearningRateSlider.Value; double momentum = MomentumSlider.Value; BackpropagationRunMode runMode = (BackpropagationRunMode)RunCombobox.SelectedItem; ProblemType problem = (ProblemType)ProblemCombobox.SelectedItem; CasesData trainingCases; CasesData testCases; YesNo appendTestFile = (YesNo)AppendTestCombobox.SelectedItem; int input = testData.First().Count(); int output = trainingData.First().Count() - input; CasesData.InitializeAllData(trainingData, testData, problem, out trainingCases, out testCases); layersVal.Insert(0, input); layersVal.Add((problem == ProblemType.Regression) ? output : trainingCases.ClassCount); NeuralNetwork network = new NeuralNetwork( (activation == ActivationFunction.Bipolar) ? (IActivation) new BipolarTanhActivation() : new UnipolarSigmoidActivation(), bias == YesNo.Yes, layersVal.ToArray()); LearningResult learningResult = BackpropagationManager.Run(network, trainingCases, testCases, runMode, iterations, learningRate, momentum); if (appendTestFile == YesNo.Yes) { AppendCSVile(testDataPath, testCases); } ShowNetworkErrorWindow(learningResult); if (problem == ProblemType.Regression) { ShowRegressionWindow(network, trainingCases, testCases); } else if (problem == ProblemType.Classification) { ShowClassificationWindow(network, trainingCases, testCases); } }
private void AppendCSVile(string path, CasesData data) { var output = new List <DenseVector>(); for (int i = 0; i < data.CasesCount; i++) { output.Add( data.ProblemType == ProblemType.Classification ? data.GetClasificationOutput(i) : data.GetIdealOutput(i)); } FileManager.AppendDataToCSV(path, output); }
private void ShowClassificationWindow(NeuralNetwork neuralNetwork, CasesData trainingSet, CasesData testSet) { List <ClassificationPoint> testPoints = new List <ClassificationPoint>(); testPoints.AddRange(MakeClassificationPointList(testSet)); List <ClassificationPoint> idealPoints = new List <ClassificationPoint>(); idealPoints.AddRange(MakeClassificationPointList(trainingSet)); Window classificationWindow = new ClassificationWindow(testPoints, idealPoints, trainingSet.ClassIndexes); classificationWindow.Show(); }
private void ShowRegressionWindow(NeuralNetwork neuralNetwork, CasesData trainingSet, CasesData testSet) { List <RegressionPoint> idealPoints = new List <RegressionPoint>(); idealPoints.AddRange(MakeRegressionPointList(trainingSet)); List <RegressionPoint> testPoints = new List <RegressionPoint>(); testPoints.AddRange(MakeRegressionPointList(testSet)); Window regressionWindow = new RegressionWindow(testPoints, idealPoints); // trainingPoints are "ideal" regressionWindow.Show(); }
private void LoadCaseItems(List<Cases> caseses) { if (caseses == null || caseses.Count == 0) return; List<int> caseIds = caseses.Select(c => c.CaseId).ToList(); if (caseIds.Count == 0) return; List<CaseItem> items = CasesData.LoadCaseItemsByCaseIds(caseIds); var caseIdItems = new Dictionary<int, List<CaseItem>>(caseses.Count); items.ForEach(item => { if (caseIdItems.ContainsKey(item.CaseId)) caseIdItems[item.CaseId].Add(item); else caseIdItems.Add(item.CaseId, new List<CaseItem>() { item }); }); var itemComparer = CaseItemDisplayOrderComparer.Instance; foreach (var c in caseses) { if (caseIdItems.ContainsKey(c.CaseId)) { c.CaseItems = caseIdItems[c.CaseId]; c.CaseItems.Sort(itemComparer); } } }
public bool DeleteCase(int caseId) { return CasesData.DeleteCase(caseId); }
public List<Cases> LoadSimpleCases(Pagination pagination, CaseType caseType) { var cases = CasesData.LoadCases(pagination, caseType); return cases ?? new List<Cases>(0); }
public bool DeleteCaseItem(int caseItemId) { return CasesData.DeleteCaseItem(caseItemId); }