本文整理汇总了C#中weka.core.Instances.get方法的典型用法代码示例。如果您正苦于以下问题:C# Instances.get方法的具体用法?C# Instances.get怎么用?C# Instances.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类weka.core.Instances
的用法示例。
在下文中一共展示了Instances.get方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PerformTraining
/// <summary>
/// Build the learning model for classification
/// </summary>
/// <param name="InstancesList">list of instances </param>
/// <param name="NumberofClusters">Number of Clusters</param>
/// <param name="TextBoxForFeedback">Text box for the results (can be NULL)</param>
/// <param name="PanelForVisualFeedback">Panel to display visual results if avalaible (can be NULL)</param>
public Classifier PerformTraining(FormForClassificationInfo WindowForClassificationParam, Instances InstancesList, /*int NumberofClusters,*/ RichTextBox TextBoxForFeedback,
Panel PanelForVisualFeedback, out weka.classifiers.Evaluation ModelEvaluation, bool IsCellular)
{
// weka.classifiers.Evaluation ModelEvaluation = null;
// FormForClassificationInfo WindowForClassificationParam = new FormForClassificationInfo(GlobalInfo);
ModelEvaluation = null;
// if (WindowForClassificationParam.ShowDialog() != System.Windows.Forms.DialogResult.OK) return null;
// weka.classifiers.Evaluation ModelEvaluation = new Evaluation(
cParamAlgo ClassifAlgoParams = WindowForClassificationParam.GetSelectedAlgoAndParameters();
if (ClassifAlgoParams == null) return null;
//this.Cursor = Cursors.WaitCursor;
// cParamAlgo ClassificationAlgo = WindowForClassificationParam.GetSelectedAlgoAndParameters();
cListValuesParam Parameters = ClassifAlgoParams.GetListValuesParam();
//Classifier this.CurrentClassifier = null;
// -------------------------- Classification -------------------------------
// create the instances
// InstancesList = this.ListInstances;
this.attValsWithoutClasses = new FastVector();
if (IsCellular)
for (int i = 0; i < cGlobalInfo.ListCellularPhenotypes.Count; i++)
this.attValsWithoutClasses.addElement(cGlobalInfo.ListCellularPhenotypes[i].Name);
else
for (int i = 0; i < cGlobalInfo.ListWellClasses.Count; i++)
this.attValsWithoutClasses.addElement(cGlobalInfo.ListWellClasses[i].Name);
InstancesList.insertAttributeAt(new weka.core.Attribute("Class", this.attValsWithoutClasses), InstancesList.numAttributes());
//int A = Classes.Count;
for (int i = 0; i < Classes.Count; i++)
InstancesList.get(i).setValue(InstancesList.numAttributes() - 1, Classes[i]);
InstancesList.setClassIndex(InstancesList.numAttributes() - 1);
weka.core.Instances train = new weka.core.Instances(InstancesList, 0, InstancesList.numInstances());
if (PanelForVisualFeedback != null)
PanelForVisualFeedback.Controls.Clear();
#region List classifiers
#region J48
if (ClassifAlgoParams.Name == "J48")
{
this.CurrentClassifier = new weka.classifiers.trees.J48();
((J48)this.CurrentClassifier).setMinNumObj((int)Parameters.ListDoubleValues.Get("numericUpDownMinInstLeaf").Value);
((J48)this.CurrentClassifier).setConfidenceFactor((float)Parameters.ListDoubleValues.Get("numericUpDownConfFactor").Value);
((J48)this.CurrentClassifier).setNumFolds((int)Parameters.ListDoubleValues.Get("numericUpDownNumFolds").Value);
((J48)this.CurrentClassifier).setUnpruned((bool)Parameters.ListCheckValues.Get("checkBoxUnPruned").Value);
((J48)this.CurrentClassifier).setUseLaplace((bool)Parameters.ListCheckValues.Get("checkBoxLaplacianSmoothing").Value);
((J48)this.CurrentClassifier).setSeed((int)Parameters.ListDoubleValues.Get("numericUpDownSeedNumber").Value);
((J48)this.CurrentClassifier).setSubtreeRaising((bool)Parameters.ListCheckValues.Get("checkBoxSubTreeRaising").Value);
// CurrentClassif.SetJ48Tree((J48)this.CurrentClassifier, Classes.Length);
this.CurrentClassifier.buildClassifier(train);
// display results training
// display tree
if (PanelForVisualFeedback != null)
{
GViewer GraphView = DisplayTree(GlobalInfo, ((J48)this.CurrentClassifier), IsCellular).gViewerForTreeClassif;
GraphView.Size = new System.Drawing.Size(PanelForVisualFeedback.Width, PanelForVisualFeedback.Height);
GraphView.Anchor = (AnchorStyles.Bottom | AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
PanelForVisualFeedback.Controls.Clear();
PanelForVisualFeedback.Controls.Add(GraphView);
}
}
#endregion
#region Random Tree
else if (ClassifAlgoParams.Name == "RandomTree")
{
this.CurrentClassifier = new weka.classifiers.trees.RandomTree();
if ((bool)Parameters.ListCheckValues.Get("checkBoxMaxDepthUnlimited").Value)
((RandomTree)this.CurrentClassifier).setMaxDepth(0);
else
((RandomTree)this.CurrentClassifier).setMaxDepth((int)Parameters.ListDoubleValues.Get("numericUpDownMaxDepth").Value);
((RandomTree)this.CurrentClassifier).setSeed((int)Parameters.ListDoubleValues.Get("numericUpDownSeed").Value);
((RandomTree)this.CurrentClassifier).setMinNum((double)Parameters.ListDoubleValues.Get("numericUpDownMinWeight").Value);
if ((bool)Parameters.ListCheckValues.Get("checkBoxIsBackfitting").Value)
{
((RandomTree)this.CurrentClassifier).setNumFolds((int)Parameters.ListDoubleValues.Get("numericUpDownBackFittingFolds").Value);
}
else
{
((RandomTree)this.CurrentClassifier).setNumFolds(0);
}
this.CurrentClassifier.buildClassifier(train);
//string StringForTree = ((RandomTree)this.CurrentClassifier).graph().Remove(0, ((RandomTree)this.CurrentClassifier).graph().IndexOf("{") + 2);
//.........这里部分代码省略.........