当前位置: 首页>>代码示例>>C#>>正文


C# Instance.classIsMissing方法代码示例

本文整理汇总了C#中Instance.classIsMissing方法的典型用法代码示例。如果您正苦于以下问题:C# Instance.classIsMissing方法的具体用法?C# Instance.classIsMissing怎么用?C# Instance.classIsMissing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Instance的用法示例。


在下文中一共展示了Instance.classIsMissing方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: updateStatsForClassifier

		/// <summary> Updates all the statistics about a classifiers performance for 
		/// the current test instance.
		/// 
		/// </summary>
		/// <param name="predictedDistribution">the probabilities assigned to 
		/// each class
		/// </param>
		/// <param name="instance">the instance to be classified
		/// </param>
		/// <throws>  Exception if the class of the instance is not </throws>
		/// <summary> set
		/// </summary>
		protected internal virtual void  updateStatsForClassifier(double[] predictedDistribution, Instance instance)
		{
			
			//UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
			int actualClass = (int) instance.classValue();
			
			if (!instance.classIsMissing())
			{
				updateMargins(predictedDistribution, actualClass, instance.weight());
				
				// Determine the predicted class (doesn't detect multiple 
				// classifications)
				int predictedClass = - 1;
				double bestProb = 0.0;
				for (int i = 0; i < m_NumClasses; i++)
				{
					if (predictedDistribution[i] > bestProb)
					{
						predictedClass = i;
						bestProb = predictedDistribution[i];
					}
				}
				
				m_WithClass += instance.weight();
				
				// Determine misclassification cost
				if (m_CostMatrix != null)
				{
					if (predictedClass < 0)
					{
						// For missing predictions, we assume the worst possible cost.
						// This is pretty harsh.
						// Perhaps we could take the negative of the cost of a correct
						// prediction (-m_CostMatrix.getXmlElement(actualClass,actualClass)),
						// although often this will be zero
						m_TotalCost += instance.weight() * m_CostMatrix.getMaxCost(actualClass);
					}
					else
					{
						m_TotalCost += instance.weight() * m_CostMatrix.getXmlElement(actualClass, predictedClass);
					}
				}
				
				// Update counts when no class was predicted
				if (predictedClass < 0)
				{
					m_Unclassified += instance.weight();
					return ;
				}
				
				double predictedProb = System.Math.Max(MIN_SF_PROB, predictedDistribution[actualClass]);
				double priorProb = System.Math.Max(MIN_SF_PROB, m_ClassPriors[actualClass] / m_ClassPriorsSum);
				if (predictedProb >= priorProb)
				{
					m_SumKBInfo += (Utils.log2(predictedProb) - Utils.log2(priorProb)) * instance.weight();
				}
				else
				{
					m_SumKBInfo -= (Utils.log2(1.0 - predictedProb) - Utils.log2(1.0 - priorProb)) * instance.weight();
				}
				
				m_SumSchemeEntropy -= Utils.log2(predictedProb) * instance.weight();
				m_SumPriorEntropy -= Utils.log2(priorProb) * instance.weight();
				
				updateNumericScores(predictedDistribution, makeDistribution(instance.classValue()), instance.weight());
				
				// Update other stats
				m_ConfusionMatrix[actualClass][predictedClass] += instance.weight();
				if (predictedClass != actualClass)
				{
					m_Incorrect += instance.weight();
				}
				else
				{
					m_Correct += instance.weight();
				}
			}
			else
			{
				m_MissingClass += instance.weight();
			}
		}
开发者ID:intille,项目名称:mitessoftware,代码行数:94,代码来源:Evaluation.cs

示例2: updateStatsForPredictor

		/// <summary> Updates all the statistics about a predictors performance for 
		/// the current test instance.
		/// 
		/// </summary>
		/// <param name="predictedValue">the numeric value the classifier predicts
		/// </param>
		/// <param name="instance">the instance to be classified
		/// </param>
		/// <throws>  Exception if the class of the instance is not </throws>
		/// <summary> set
		/// </summary>
		protected internal virtual void  updateStatsForPredictor(double predictedValue, Instance instance)
		{
			
			if (!instance.classIsMissing())
			{
				
				// Update stats
				m_WithClass += instance.weight();
				if (Instance.isMissingValue(predictedValue))
				{
					m_Unclassified += instance.weight();
					return ;
				}
				m_SumClass += instance.weight() * instance.classValue();
				m_SumSqrClass += instance.weight() * instance.classValue() * instance.classValue();
				m_SumClassPredicted += instance.weight() * instance.classValue() * predictedValue;
				m_SumPredicted += instance.weight() * predictedValue;
				m_SumSqrPredicted += instance.weight() * predictedValue * predictedValue;
				
				if (m_ErrorEstimator == null)
				{
					setNumericPriorsFromBuffer();
				}
				double predictedProb = Math.Max(m_ErrorEstimator.getProbability(predictedValue - instance.classValue()), MIN_SF_PROB);
				double priorProb = Math.Max(m_PriorErrorEstimator.getProbability(instance.classValue()), MIN_SF_PROB);
				
				m_SumSchemeEntropy -= Utils.log2(predictedProb) * instance.weight();
				m_SumPriorEntropy -= Utils.log2(priorProb) * instance.weight();
				m_ErrorEstimator.addValue(predictedValue - instance.classValue(), instance.weight());
				
				updateNumericScores(makeDistribution(predictedValue), makeDistribution(instance.classValue()), instance.weight());
			}
			else
				m_MissingClass += instance.weight();
		}
开发者ID:intille,项目名称:mitessoftware,代码行数:46,代码来源:Evaluation.cs

示例3: updatePriors

		/// <summary> Updates the class prior probabilities (when incrementally 
		/// training)
		/// 
		/// </summary>
		/// <param name="instance">the new training instance seen
		/// </param>
		/// <throws>  Exception if the class of the instance is not </throws>
		/// <summary> set
		/// </summary>
		public virtual void  updatePriors(Instance instance)
		{
			if (!instance.classIsMissing())
			{
				if (!m_ClassIsNominal)
				{
					if (!instance.classIsMissing())
					{
						addNumericTrainClass(instance.classValue(), instance.weight());
					}
				}
				else
				{
					//UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
					m_ClassPriors[(int) instance.classValue()] += instance.weight();
					m_ClassPriorsSum += instance.weight();
				}
			}
		}
开发者ID:intille,项目名称:mitessoftware,代码行数:28,代码来源:Evaluation.cs


注:本文中的Instance.classIsMissing方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。