本文整理汇总了C#中Instance.value_Renamed方法的典型用法代码示例。如果您正苦于以下问题:C# Instance.value_Renamed方法的具体用法?C# Instance.value_Renamed怎么用?C# Instance.value_Renamed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Instance
的用法示例。
在下文中一共展示了Instance.value_Renamed方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SparseInstance
/// <summary> Constructor that generates a sparse instance from the given
/// instance. Reference to the dataset is set to null.
/// (ie. the instance doesn't have access to information about the
/// attribute types)
///
/// </summary>
/// <param name="instance">the instance from which the attribute values
/// and the weight are to be copied
/// </param>
public SparseInstance(Instance instance)
{
m_Weight = instance.m_Weight;
m_Dataset = null;
m_NumAttributes = instance.numAttributes();
if (instance is SparseInstance)
{
m_AttValues = ((SparseInstance) instance).m_AttValues;
m_Indices = ((SparseInstance) instance).m_Indices;
}
else
{
double[] tempValues = new double[instance.numAttributes()];
int[] tempIndices = new int[instance.numAttributes()];
int vals = 0;
for (int i = 0; i < instance.numAttributes(); i++)
{
if (instance.value_Renamed(i) != 0)
{
tempValues[vals] = instance.value_Renamed(i);
tempIndices[vals] = i;
vals++;
}
}
m_AttValues = new double[vals];
m_Indices = new int[vals];
Array.Copy(tempValues, 0, m_AttValues, 0, vals);
Array.Copy(tempIndices, 0, m_Indices, 0, vals);
}
}
示例2: 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);
}
示例3: 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);
}
示例4: 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;
}
}
示例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;
}
}
}