} /* InitiateClass */ public void Increment(PicesClass mlClass, float areaMM ) { if (mlClass == null) { mlClass = PicesClassList.GetUnKnownClassStatic(); } ClassTotals2 classTotals = totals.LookUp(mlClass.Name); if (classTotals == null) { classTotals = new ClassTotals2(mlClass.Name, sizeInitial, sizeGrowthFactor, sizeEndRange, bucketCount, sizeBucketStart, sizeBucketEnd ); totals.Add(classTotals); } classTotals.Increment(areaMM); } /* Increment */
private void SelectClassButtom_Click(object sender, EventArgs e) { String rootDir = ""; PicesClassList activeClasses = null; if (ActiveTrainingLibraries.Model1() != null) { rootDir = ActiveTrainingLibraries.Model1().RootDir; activeClasses = ActiveTrainingLibraries.Model1().MLClasses(); } if (classes == null) { classes = dbConn.MLClassLoadList(); } SelectAPicesClass sapc = new SelectAPicesClass(classes, rootDir, activeClasses); if (!String.IsNullOrEmpty(ValidatedClassName.Text)) { sapc.SelectedClass = PicesClassList.GetUniqueClass(ValidatedClassName.Text, ""); } sapc.ShowDialog(this); if (sapc.SelectionMade && (sapc.SelectedClass != null)) { PicesClass validatdClass = sapc.SelectedClass; ValidatedClassName.Text = validatdClass.Name; image.ValidatedClass = validatdClass; dbConn.ImagesUpdateValidatedClass(image.ImageFileName, validatdClass); classUserValidatesAs = validatdClass; } }
/// <summary> /// /// </summary> /// <param name="classes"></param> /// <param name="_rootDir">Root directory of training library that contains examples for the classes.</param> /// <param name="_activeClasses">List of classes that current classifier supports; these classes will be highlighted.</param> public SelectAPicesClass(PicesClassList classes, String _rootDir, PicesClassList _activeClasses ) { activeClasses = _activeClasses; rootDir = OSservices.AddSlash(_rootDir); InitializeComponent(); activeClassFont = new Font(MLClassChoices.Font.FontFamily, MLClassChoices.Font.SizeInPoints + 1, FontStyle.Bold); selectedNode = null; PicesClass root = classes.RootNode; bool activeClass = false; AddSubTreeToClassChoser(root, MLClassChoices.Nodes, ref activeClass, 0); if (selectedNode != null) { MLClassChoices.SelectedNode = selectedNode; } MLClassChoices.ExpandAll(); //foreach (PicesClass pc in root.Children) // AddSubTreeToClassChoser (pc, MLClassChoices.Nodes, ref activeClass); }
} /* InitializeTrainAndPredLevelFields */ private void ValidateTrainingModel() { if (string.IsNullOrEmpty(TrainingModelSelected.Text)) { return; } trainingModelName = TrainingModelSelected.Text; curSelModel = new PicesTrainingConfigManaged(trainingModelName, runLog); trainingModelValid = curSelModel.Valid(); if (!trainingModelValid) { String alarmMsg = "Error Loading Configuration File"; alarmMsg += "\n\n"; alarmMsg += curSelModel.LoadLogStream(); MessageBox.Show(this, alarmMsg, "Could not load Config file", MessageBoxButtons.OK); } else { otherClass = curSelModel.OtherClass(); if (crossValidation) { GroundTruth.Text = "F:\\Pices\\SavedImages\\Cruise-WB0812_Station-DWH"; } //GroundTruth.Text = curSelModel.RootDir (); origClassifierClasses = curSelModel.ExtractClassList(); InitializeTrainAndPredLevelFields(); } } /* ValidateTrainingModel */
} /* UpdateDetailProbabilityDisplay */ private void UpdateBinaryClassifierProbabilities(String className) { PicesClass leftClass = PicesClassList.GetUniqueClass(className, ""); BinaryClassName.Text = ""; BinaryProbabilities.Rows.Clear(); Prediction pred = GetPrediction(curSelImageFileName); PicesPredictionList binaryPredictions = pred.trainModel.BinaryProbailitiesForClass(leftClass); if (binaryPredictions == null) { return; } BinaryClassName.Text = leftClass.Name; foreach (PicesPrediction p in binaryPredictions) { if (leftClass == p.MLClass) { continue; } Object[] data = new Object[2]; data[0] = p.ClassName; double probForRightSide = 1.0 - p.Probability; data[1] = probForRightSide; BinaryProbabilities.Rows.Add(data); } } /* UpdateBinaryClassifierProbabilities */
} /* ExploreMatrixCell */ public void MakePrediction(PicesClass knownClass, PicesClass predictedClass, double predProb, PicesFeatureVector fv, TrainingModel2 trainModel ) { bool partOfOriginalClassifier = ClassInClassifierClasses(knownClass); if (!partOfOriginalClassifier) { String notPartClassName = "(V)" + knownClass.Name; knownClass = PicesClassList.GetUniqueClass(notPartClassName, ""); } int x = classes.LookUpIndex(knownClass); if (x < 0) { classes.Add(knownClass); } x = classes.LookUpIndex(predictedClass); if (x < 0) { classes.Add(predictedClass); } Prediction p = new Prediction(knownClass, predictedClass, predProb, fv, trainModel, partOfOriginalClassifier); predictions.Add(p); } /* featureVector */
private List <String> ValidateFields() { List <String> errors = new List <string> (); weightByVolume = WeightByVolume.Checked; includeSubClasses = IncludeSubClasses.Checked; depthIncrement = (int)DepthIncr.Value; if (depthIncrement < 1) { errors.Add("Depth Increment must be greater than zero."); } if (String.IsNullOrEmpty(ClassToPlot.Text)) { errors.Add("You must specify class to plot."); } else { classToPlot = PicesClassList.GetUniqueClass(ClassToPlot.Text, ""); } ValidateDepthAxisSettings(ref errors); if (errors.Count < 1) { return(null); } else { return(errors); } }
public ChartSizeDistribution(String _cruise, String _station, String _deployment, PicesClass _classToPlot, PicesClassList _classes, PicesClassList _activeClasses, String _rootDir ) { cruise = _cruise; station = _station; deployment = _deployment; classToPlot = _classToPlot; classes = _classes; activeClasses = _activeClasses; rootDir = _rootDir; lastSaveDirectory = OSservices.AddSlash(PicesSipperVariables.PicesReportDir()) + "AbundanceReports"; statusMsgs = new PicesMsgQueue("ChartSizeDistribution-StatusMsgs"); msgQueue = new PicesMsgQueue("ChartSizeDistribution-RunLog"); runLog = new PicesRunLog(msgQueue); mainWinConn = PicesDataBase.GetGlobalDatabaseManagerNewInstance(runLog); configFileName = OSservices.AddSlash(PicesSipperVariables.ConfigurationDirectory()) + "ChartSizeDistribution.cfg"; InitializeComponent(); }
private PicesClassList SortIntoDisplayOrder(PicesClassList l) { PicesClassList knownClasses = new PicesClassList(); PicesClassList unKnownClasses = new PicesClassList(); foreach (PicesClass pc in l) { if (ClassInClassifierClasses(pc)) { knownClasses.Add(pc); } else { unKnownClasses.Add(pc); } } knownClasses.SortByName(); unKnownClasses.SortByName(); foreach (PicesClass pc in unKnownClasses) { knownClasses.Add(pc); } return(knownClasses); }
public ConfusionMatrix(PicesTrainingConfigManaged _config, PicesClassList _classifierClasses, /**< List of classes in origianl Classifier before reduction due to training level. */ TrainingModel2 _trainingModel, String _modelName, String _groundTruthRootDir, uint _trainLevel, uint _predLevel ) { config = _config; trainingModel = _trainingModel; groundTruthRootDir = _groundTruthRootDir; trainLevel = _trainLevel; predLevel = _predLevel; classifierClasses = _classifierClasses; if (config != null) { otherClass = config.OtherClass(); } InitializeComponent(); classes = new PicesClassList(); classes.Clear(); ModelName.Text = _modelName; GroundTruth.Text = _groundTruthRootDir; }
} /* UpdateProcessDelete */ private void UpdateProcessMerge(PicesDataBase updDbConn) { RunLogAddMsg("Merging Class [" + selectedClass.Name + "] into [" + mergeClass.Name + "]" + "\n"); // First: Update the Images table. // Second: Update Classes table. String sqlCmd = "Call MLClassMergeComprehensive (" + "\"" + selectedClass.Name + "\"" + ", " + "\"" + mergeClass.Name + "\"" + ")"; updDbConn.QueryStatement(sqlCmd, null); PicesClassList.UpdateParent(mergeClass, selectedClass); if (mergeClass.Parent != null) { if (mergeClass.Parent.Children != null) { mergeClass.Parent.Children.Remove(mergeClass); } } selectedClass.StoredOnDataBase = false; selectedClass = mergeClass; } /* UpdateProcessMerge */
public ChartAbundanceByDeployment(String _cruise, String _station, String _deployment, PicesClass _classToPlot, int _sizeMin, int _sizeMax, float _probMin, float _probMax, float _depthMin, float _depthMax, char _classKeyToUse, PicesClassList _classes, PicesClassList _activeClasses, String _rootDir ) { cruise = _cruise; station = _station; deployment = _deployment; classToPlot = _classToPlot; sizeMin = _sizeMin; sizeMax = _sizeMax; probMin = _probMin; probMax = _probMax; depthMin = _depthMin; depthMax = _depthMax; classKeyToUse = _classKeyToUse; classes = _classes; activeClasses = _activeClasses; rootDir = _rootDir; if ((sizeMin > 0) && (sizeMax <= 0)) { sizeMax = int.MaxValue; } if ((probMin >= 0.0f) && (probMax <= 0.0f)) { probMax = 1.0f; } if ((depthMin > 0.0f) && (depthMax <= 0.0f)) { depthMax = float.MaxValue; } filterSize = (sizeMin > 0) || ((sizeMax > 0) && (sizeMax > sizeMin)); filterProb = ((probMin > 0.0f) || (probMax < 1.0f)) && (probMax > probMin); filterDepth = ((depthMax > 0) && (depthMax > depthMin)); statusMsgs = new PicesMsgQueue("ChartAbundanceByDeployment-StatusMsgs"); msgQueue = new PicesMsgQueue("ChartAbundanceByDeployment-RunLog"); runLog = new PicesRunLog(msgQueue); mainWinConn = PicesDataBase.GetGlobalDatabaseManagerNewInstance(runLog); configFileName = OSservices.AddSlash(PicesSipperVariables.ConfigurationDirectory()) + "ChartAbundanceByDeployment.cfg"; BuildCriteriaString(); InitializeComponent(); }
private void UpdateProcessDelete(PicesDataBase updDbConn) { RunLogAddMsg("Deleting Class[" + selectedClass.Name + "]" + "\n"); // Go through each sipper file and change the class name in there related Images table entries. TimeSpan startProcessTime = System.Diagnostics.Process.GetCurrentProcess().TotalProcessorTime; PicesDataBaseLogEntry logEntry = updDbConn.LogEntriesProcessStart("DL", "ClassMaintenanceDelete", ExecutableDateTimeStamp(), "ClassMaintenance::UpdateProcessDelete " + selectedClass.Name, "" ); String sqlCmd = "Call MLClassDeleteComprehensive (\"" + selectedClass.Name + "\")"; updDbConn.QueryStatement(sqlCmd, null); PicesClassList.UpdateParent(selectedClass, selectedClass.Parent); if (selectedClass.Parent != null) { if (selectedClass.Parent.Children != null) { selectedClass.Parent.Children.Remove(mergeClass); } } TimeSpan endProcessTime = System.Diagnostics.Process.GetCurrentProcess().TotalProcessorTime; updDbConn.LogEntriesProcessEnd(logEntry, (float)((startProcessTime - endProcessTime).TotalSeconds), "Done"); selectedClass.StoredOnDataBase = false; } /* UpdateProcessDelete */
} /* ClassTree_AfterSelect */ private void StartUpdateProcedure() { if (!allowUpdates) { MessageBox.Show(this, "Updates are not allowed.", "Class Maintenance", MessageBoxButtons.OK); return; } if (addingNewClass) { newClassEntry = new PicesClass(ClassName.Text, ParentName.Text); } else { newClassEntry = selectedClass; } newClassEntry.Description = Description.Text; newClassEntry.Parent = PicesClassList.GetUniqueClass(ParentName.Text, null); newClassEntry.Mandatory = MandatoryBox.Checked; newClassEntry.Summarize = SummarizeBox.Checked; DisableAllFields(); updateThread = new Thread(new ThreadStart(UpdateProcess)); updateThread.Start(); Thread.Sleep(50); updateTimer.Enabled = true; UpdatingProgressBar.Value = 0; UpdatingProgressBar.Visible = true; } /* PerformUpdate */
public void SetTrainingModel(TrainingModel2 _trainingModel) { trainingModel = _trainingModel; if (otherClass == null) { otherClass = PicesClassList.GetUniqueClass("Other", ""); } }
private void SelectClassButton_Click(object sender, EventArgs e) { if (MLClassChoices.SelectedNode != null) { selectionMade = true; selectedClass = PicesClassList.GetUniqueClass(MLClassChoices.SelectedNode.Text, ""); Close(); return; } }
private PicesPredictionList PredictClasses(PicesFeatureVector fv, PicesPrediction pred1, PicesPrediction pred2, String imageFileName, String imageFileRootName ) { PicesFeatureVector fvToUse = fv; PicesPredictionList probPredList = null; if (fvToUse.FeatureDataMissing) { fvToUse = null; // Feature data is missing. we need to compute from original image. PicesDataBaseImage pdbi = DbConn().ImageLoad(imageFileRootName); if (pdbi != null) { PicesRaster pr = DbConn().ImageFullSizeFind(imageFileRootName); if (pr == null) { ErrorMsgsAdd("Failed to Load FullSize image [" + imageFileRootName + "]"); } else { fvToUse = new PicesFeatureVector(pr, imageFileName, null, runLog); // Since we had to compute the FeatureDatya from the raster image we now need to // get the instrument data that matches it. PicesInstrumentData id = DbConn().InstrumentDataGetByScanLine(pdbi.SipperFileName, pdbi.TopLeftRow); if (id != null) { fvToUse.AddInstrumentData(id); } DbConn().FeatureDataInsertRow(pdbi.SipperFileName, fvToUse); pr.Dispose(); } pr = null; } } if (fvToUse != null) { classifier.PredictClass(fvToUse, pred1, pred2); probPredList = classifier.PredictProbabilities(fvToUse); } else { pred1.MLClass = PicesClassList.GetUnKnownClassStatic(); pred1.Probability = 1.0f; pred2.MLClass = PicesClassList.GetUnKnownClassStatic(); pred2.Probability = 0.0f; } return(probPredList); } /* PredictClasses */
public static PicesClassList Model1ListOfClasses() { PicesClassList classes = null; BlockStart(); if (model1 != null) { classes = model1.MLClasses(); // Will make a copy of the list of classes in training model1. } BlockEnd(); return(classes); }
} /* BuildThumbnailGridViewConetextMenu */ private PicesClass GetSelectedBottomClass() { if (BinaryProbabilities.SelectedCells.Count != 1) { return(null); } int row = BinaryProbabilities.SelectedCells[0].RowIndex; String className = BinaryProbabilities.Rows[row].Cells[0].Value.ToString(); return(PicesClassList.GetUniqueClass(className, "")); } /* GetSelectedBottomClass */
private void MergeSearchButton_Click(object sender, EventArgs e) { SelectAPicesClass sac = new SelectAPicesClass(classes, "", null); sac.SelectedClass = PicesClassList.GetUniqueClass(MergeClass.Text, ""); sac.ShowDialog(); if (sac.SelectedClass != null) { MergeClass.Text = sac.SelectedClass.Name; ValidateMergeClass(); } }
private void InitilizeDataStructures() { int x, y; classesPredLevel = classes.ExtractListOfClassesForAGivenHierarchialLevel(predLevel); //classesPredLevel.SortByName (); classesPredLevel = SortIntoDisplayOrder(classesPredLevel); numPredClasses = classesPredLevel.Count; totalCount = 0; totalCorrect = 0.0f; totalCorrectNPC = 0; for (x = 0; x < 8; ++x) { totalByCorectLevel[x] = 0; totalPartOfClassifierByCorectLevel[x] = 0; } totalPartOfClassifier = 0; totalPartOfClassifierCorrect = 0.0f; totalPartOfClassifierCorrectNPC = 0; totalNoise = 0; totalNoiseCorrect = 0.0f; totalNoiseCorrectNPC = 0; totalNonNoise = 0; totalNonNoiseCorrect = 0.0f; totalNonNoiseCorrectNPC = 0; totalNotPartOfClassifier = 0; knownClassCounts = new int[numPredClasses]; predictionCounts = new int[numPredClasses][]; predClassCounts = new int[numPredClasses]; imagesByPred = new Dictionary <String, Prediction> [numPredClasses][]; for (x = 0; x < numPredClasses; x++) { knownClassCounts[x] = 0; predClassCounts [x] = 0; predictionCounts[x] = new int[numPredClasses]; imagesByPred[x] = new Dictionary <String, Prediction> [numPredClasses]; for (y = 0; y < numPredClasses; y++) { predictionCounts[x][y] = 0; imagesByPred[x][y] = new Dictionary <String, Prediction> (); } } } /* InitilizeDataStructures */
public GetRunTimeParameters() { msgQueue = new PicesMsgQueue("GradeTrainingModel"); runLog = new PicesRunLog(msgQueue); InitializeComponent(); noAgreementClass = PicesClassList.GetUniqueClass("NoAgreement", ""); configFileName = OSservices.AddSlash(PicesSipperVariables.ConfigurationDirectory()) + "GradeTrainingModel.txt"; LoadTrainingModelComboBox(); InitializeTrainAndPredLevelFields(); EnableComponentsForParameterEntry(); }
} /* SizeDistribution */ /// <summary> /// Method used to guarantee that the specified class is included; even if none occur. /// </summary> /// <param name="mlClass">Class to add </param> public void InitiateClass(PicesClass mlClass) { if (mlClass == null) { mlClass = PicesClassList.GetUnKnownClassStatic(); } ClassTotals classTotals = totals.LookUp(mlClass.Name); if (classTotals == null) { classTotals = new ClassTotals(mlClass.Name, bucketCount, bucketSize); totals.Add(classTotals); } return; } /* InitiateClass */
} /* LoadConfigurationFile */ private List <String> ValidateFields() { List <String> errors = new List <string> (); switch (SizeStatisticField.Text) { case "Pixel Area": statistic = '0'; break; case "Diameter": statistic = '1'; break; case "Volume (SBv)": statistic = '2'; break; case "Volume (EBv)": statistic = '3'; break; } cast = CastField.Text; growthRate = (float)GrowthRateField.Value; initialSizeValue = (float)InitialSizeField.Value; // KKKK Did this soi that we are the same as the volume report I sent to kendra a couple weeks ago. if (statistic == '2') { growthRate = 1.331f; initialSizeValue = 0.000523599f; } includeSubClasses = IncludeSubClasses.Checked; if (String.IsNullOrEmpty(ClassToPlot.Text)) { errors.Add("You must specify class to plot."); } else { classToPlot = PicesClassList.GetUniqueClass(ClassToPlot.Text, ""); } if (errors.Count < 1) { return(null); } else { return(errors); } }
} /* ReportByClassCollumns */ private PicesClassList BuildMLClassList() { PicesClassList mlClasses = new PicesClassList(); int cIDX; //for (cIDX = 0; cIDX < totals->end (); cIDX++) for (cIDX = 0; cIDX < totals.Count; cIDX++) { ClassTotals ct = totals[cIDX]; mlClasses.Add(PicesClassList.GetUniqueClass(ct.Name, "")); } mlClasses.SortByName(); return(mlClasses); } /* BuildMLClassList */
public ClassSelect(PicesClass _selectedClass, PicesClassList _classes, String _rootDir, PicesClassList _activeClasses ) { heightLast = Height; widthLast = Width; this.SizeChanged += new System.EventHandler(this.OnSizeChanged); selectedClass = _selectedClass; origSelectedClass = _selectedClass; classes = _classes; rootDir = _rootDir; activeClasses = _activeClasses; InitializeComponent(); }
private void SelectClassButton_Click(object sender, EventArgs e) { SelectAPicesClass sapc = new SelectAPicesClass(classes, rootDir, activeClasses); if (!String.IsNullOrEmpty(ClassToPlot.Text)) { sapc.SelectedClass = PicesClassList.GetUniqueClass(ClassToPlot.Text, ""); } sapc.ShowDialog(this); if (sapc.SelectionMade) { PicesClass pc = sapc.SelectedClass; if (pc != null) { ClassToPlot.Text = pc.Name; } } }
} /* AddDeploymentToSeries */ /// <summary> /// This method will be ran as a separate thread; it is responsible for collecting all the data needed to generate the plot. /// </summary> private void BuildPlotData() { if (buildPlotDataRunning) { return; } PicesDataBase.ThreadInit(); threadConn = PicesDataBase.GetGlobalDatabaseManagerNewInstance(runLog); buildPlotDataRunning = true; depthIncrement = (int)DepthIncr.Value; classToPlot = PicesClassList.GetUniqueClass(ClassToPlot.Text, ""); series = new List <DataSeriesToPlot> (); foreach (PlotRequest pr in plotRequests) { if (cancelRequested) { break; } AddDeploymentToSeries(pr.deployment); } threadConn.Close(); threadConn = null; GC.Collect(); PicesDataBase.ThreadEnd(); if (cancelRequested) { statusMsgs.AddMsg("Plotting of data CANCELLED!!!"); } else { statusMsgs.AddMsg("Building of plot data completed !!!"); } buildPlotDataRunning = false; buildPlotDataDone = true; } /* BuildPlotData */
private void ClassInitialization() { sizeDistributionDown = new SizeDistribution2(0.1f, 1.2f, 10.0f); sizeDistributionUp = new SizeDistribution2(0.1f, 1.2f, 10.0f); depthDistribution_1 = new SizeDistribution(500, 1); depthDistribution_1Down = new SizeDistribution(500, 1); depthDistribution_1Up = new SizeDistribution(500, 1); depthDistribution_10 = new SizeDistribution(50, 10); classCounts = new ClassStatSortedList(); numImagesClassified = 0; pred1 = new PicesPrediction(null, 0, 0.0f); pred2 = new PicesPrediction(null, 0, 0.0f); if (classifier != null) { classesInClassifier = classifier.MLClasses(); } }
} /* InitiateClass */ public void Increment(PicesClass mlClass, int size ) { if (mlClass == null) { mlClass = PicesClassList.GetUnKnownClassStatic(); } ClassTotals classTotals = totals.LookUp(mlClass.Name); if (classTotals == null) { classTotals = new ClassTotals(mlClass.Name, bucketCount, bucketSize); totals.Add(classTotals); } classTotals.Increment(size); } /* Increment */