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


C# Instance.numClasses方法代码示例

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


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

示例1: distributionForInstance

		/// <summary> Returns class probabilities for a weighted instance.
		/// 
		/// </summary>
		/// <exception cref="Exception">if something goes wrong
		/// </exception>
		public double[] distributionForInstance(Instance instance, bool useLaplace)
		{
			
			double[] doubles = new double[instance.numClasses()];
			
			for (int i = 0; i < doubles.Length; i++)
			{
				if (!useLaplace)
				{
					doubles[i] = getProbs(i, instance, 1);
				}
				else
				{
					doubles[i] = getProbsLaplace(i, instance, 1);
				}
			}
			
			return doubles;
		}
开发者ID:intille,项目名称:mitessoftware,代码行数:24,代码来源:ClassifierTree.cs

示例2: distributionForInstance

		/// <summary> Predicts the class memberships for a given instance. If
		/// an instance is unclassified, the returned array elements
		/// must be all zero. If the class is numeric, the array
		/// must consist of only one element, which contains the
		/// predicted value. Note that a classifier MUST implement
		/// either this or classifyInstance().
		/// 
		/// </summary>
		/// <param name="instance">the instance to be classified
		/// </param>
		/// <returns> an array containing the estimated membership 
		/// probabilities of the test instance in each class 
		/// or the numeric prediction
		/// </returns>
		/// <exception cref="Exception">if distribution could not be 
		/// computed successfully
		/// </exception>
		public virtual double[] distributionForInstance(Instance instance)
		{
			double[] dist = new double[instance.numClasses()];
			switch (instance.classAttribute().type())
			{
				
				case weka.core.Attribute.NOMINAL: 
					double classification = classifyInstance(instance);
					if (Instance.isMissingValue(classification))
					{
						return dist;
					}
					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'"
						dist[(int) classification] = 1.0;
					}
					return dist;

                case weka.core.Attribute.NUMERIC: 
					dist[0] = classifyInstance(instance);
					return dist;
				
				default: 
					return dist;
				
			}
		}
开发者ID:intille,项目名称:mitessoftware,代码行数:45,代码来源:Classifier.cs

示例3: classifyInstance

		/// <summary> Classifies an instance.
		/// 
		/// </summary>
		/// <exception cref="Exception">if something goes wrong
		/// </exception>
		public virtual double classifyInstance(Instance instance)
		{
			
			double maxProb = - 1;
			double currentProb;
			int maxIndex = 0;
			int j;
			
			for (j = 0; j < instance.numClasses(); j++)
			{
				currentProb = getProbs(j, instance, 1);
				if (Utils.gr(currentProb, maxProb))
				{
					maxIndex = j;
					maxProb = currentProb;
				}
			}
			
			return (double) maxIndex;
		}
开发者ID:intille,项目名称:mitessoftware,代码行数:25,代码来源:ClassifierTree.cs


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