本文整理汇总了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;
}
示例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;
}
}
示例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;
}