本文整理汇总了C#中Instance.isMissing方法的典型用法代码示例。如果您正苦于以下问题:C# Instance.isMissing方法的具体用法?C# Instance.isMissing怎么用?C# Instance.isMissing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Instance
的用法示例。
在下文中一共展示了Instance.isMissing方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: convertInstance
/// <summary> Convert a single instance over. The converted instance is
/// added to the end of the output queue.
///
/// </summary>
/// <param name="instance">the instance to convert
/// </param>
private void convertInstance(Instance instance)
{
Instance inst = null;
if (instance is SparseInstance)
{
double[] vals = new double[instance.numValues()];
int[] indices = new int[instance.numValues()];
int num = 0;
for (int j = 0; j < instance.numValues(); j++)
{
if (instance.isMissingSparse(j) && (getInputFormat().classIndex() != instance.index(j)) && (instance.attributeSparse(j).Nominal || instance.attributeSparse(j).Numeric))
{
if (m_ModesAndMeans[instance.index(j)] != 0.0)
{
vals[num] = m_ModesAndMeans[instance.index(j)];
indices[num] = instance.index(j);
num++;
}
}
else
{
vals[num] = instance.valueSparse(j);
indices[num] = instance.index(j);
num++;
}
}
if (num == instance.numValues())
{
inst = new SparseInstance(instance.weight(), vals, indices, instance.numAttributes());
}
else
{
double[] tempVals = new double[num];
int[] tempInd = new int[num];
Array.Copy(vals, 0, tempVals, 0, num);
Array.Copy(indices, 0, tempInd, 0, num);
inst = new SparseInstance(instance.weight(), tempVals, tempInd, instance.numAttributes());
}
}
else
{
double[] vals = new double[getInputFormat().numAttributes()];
for (int j = 0; j < instance.numAttributes(); j++)
{
if (instance.isMissing(j) && (getInputFormat().classIndex() != j) && (getInputFormat().attribute(j).Nominal || getInputFormat().attribute(j).Numeric))
{
vals[j] = m_ModesAndMeans[j];
}
else
{
vals[j] = instance.value_Renamed(j);
}
}
inst = new Instance(instance.weight(), vals);
}
inst.Dataset = instance.dataset();
push(inst);
}
示例2: convertInstance
/// <summary> Convert a single instance over if the class is nominal. The converted
/// instance is added to the end of the output queue.
///
/// </summary>
/// <param name="instance">the instance to convert
/// </param>
private void convertInstance(Instance instance)
{
double[] vals = new double[outputFormatPeek().numAttributes()];
int attSoFar = 0;
for (int j = 0; j < getInputFormat().numAttributes(); j++)
{
weka.core.Attribute att = getInputFormat().attribute(j);
if (!att.Nominal || (j == getInputFormat().classIndex()) || !m_Columns.isInRange(j))
{
vals[attSoFar] = instance.value_Renamed(j);
attSoFar++;
}
else
{
if (att.numValues() <= 2)
{
vals[attSoFar] = instance.value_Renamed(j);
attSoFar++;
}
else
{
if (instance.isMissing(j))
{
for (int k = 0; k < att.numValues(); k++)
{
vals[attSoFar + k] = instance.value_Renamed(j);
}
}
else
{
for (int k = 0; k < att.numValues(); k++)
{
//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'"
if (k == (int) instance.value_Renamed(j))
{
vals[attSoFar + k] = 1;
}
else
{
vals[attSoFar + k] = 0;
}
}
}
attSoFar += att.numValues();
}
}
}
Instance inst = null;
if (instance is SparseInstance)
{
inst = new SparseInstance(instance.weight(), vals);
}
else
{
inst = new Instance(instance.weight(), vals);
}
copyStringValues(inst, false, instance.dataset(), InputStringIndex, getOutputFormat(), OutputStringIndex);
inst.Dataset = getOutputFormat();
push(inst);
}
示例3: whichSubset
/// <summary> Returns index of subset instance is assigned to.
/// Returns -1 if instance is assigned to more than one subset.
///
/// </summary>
/// <exception cref="Exception">if something goes wrong
/// </exception>
public override int whichSubset(Instance instance)
{
if (instance.isMissing(m_attIndex))
return - 1;
else
{
if (instance.attribute(m_attIndex).Nominal)
{
//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'"
return (int) instance.value_Renamed(m_attIndex);
}
else if (Utils.smOrEq(instance.value_Renamed(m_attIndex), m_splitPoint))
return 0;
else
return 1;
}
}
示例4: GetWeights
/// <summary> Returns weights if instance is assigned to more than one subset.
/// Returns null if instance is only assigned to one subset.
/// </summary>
public override double[] GetWeights(Instance instance)
{
double[] weights;
int i;
if (instance.isMissing(m_attIndex))
{
weights = new double[m_numSubsets];
for (i = 0; i < m_numSubsets; i++)
weights[i] = m_distribution.perBag(i) / m_distribution.total();
return weights;
}
else
{
return null;
}
}
示例5: checkInstance
/// <summary> Checks if the given instance is compatible
/// with this dataset. Only looks at the size of
/// the instance and the ranges of the values for
/// nominal and string attributes.
///
/// </summary>
/// <returns> true if the instance is compatible with the dataset
/// </returns>
public virtual bool checkInstance(Instance instance)
{
if (instance.numAttributes() != numAttributes())
{
return false;
}
for (int i = 0; i < numAttributes(); i++)
{
if (instance.isMissing(i))
{
continue;
}
else if (attribute(i).Nominal || attribute(i).String)
{
//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'"
if (!(Utils.eq(instance.value_Renamed(i), (double) instance.value_Renamed(i))))
{
return false;
}
else if (Utils.sm(instance.value_Renamed(i), 0) || Utils.gr(instance.value_Renamed(i), attribute(i).numValues()))
{
return false;
}
}
}
return true;
}
示例6: whichSubset
/// <summary> Returns the subset an instance falls into.</summary>
private int whichSubset(Instance instance)
{
if (instance.isMissing(m_AttIndex))
{
return 2;
}
else if (instance.attribute(m_AttIndex).Nominal)
{
//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'"
if ((int) instance.value_Renamed(m_AttIndex) == m_SplitPoint)
{
return 0;
}
else
{
return 1;
}
}
else
{
if (instance.value_Renamed(m_AttIndex) <= m_SplitPoint)
{
return 0;
}
else
{
return 1;
}
}
}