本文整理汇总了C#中Pair.GetUnique方法的典型用法代码示例。如果您正苦于以下问题:C# Pair.GetUnique方法的具体用法?C# Pair.GetUnique怎么用?C# Pair.GetUnique使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pair
的用法示例。
在下文中一共展示了Pair.GetUnique方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: selectfeatures
public static void selectfeatures(Pair<string, float>[] featureweights, Pair<string, string>[] labels, string inputFile, string outputFile)
{
orderfeatures(featureweights, inputFile);
opgroup[] featureIdx = new opgroup[featureweights.Length];
for (int i = 0; i < featureweights.Length; ++i)
{
featureIdx[i] = new opgroup(featureweights[i].first);
}
globvars.labels = labels;
SetMatchAttrFile(inputFile, featureIdx);
FileStream fso = new FileStream(outputFile, FileMode.Create, FileAccess.Write);
StreamWriter tfso = new StreamWriter(fso);
FileStream fs = new FileStream(inputFile, FileMode.Open, FileAccess.Read);
XmlTextReader xi = new XmlTextReader(fs);
XmlTextWriter xo = new XmlTextWriter(tfso);
xo.Indentation = 1;
xo.IndentChar = '\t';
xo.Formatting = Formatting.Indented;
while (xi.Read())
{
if (xi.NodeType == XmlNodeType.Element && xi.IsStartElement())
{
if (xi.Name == "dataset")
{
xo.WriteStartElement(xi.Name); // dataset
xo.WriteAttributes(xi, true);
break;
}
}
else
{
xo.WriteNode(xi, true);
}
}
xo.WriteStartElement("header");
xo.WriteStartElement("attributes");
for (int i = 0; i < featureweights.Length; ++i)
{
string s = featureweights[i].first;
float curweight = featureweights[i].second;
xo.WriteStartElement("attribute");
if (s == "class")
{
xo.WriteAttributeString("class", "yes");
xo.WriteAttributeString("name", "class");
xo.WriteAttributeString("type", "nominal");
xo.WriteStartElement("labels");
foreach (string x in labels.GetUnique())
{
xo.WriteElementString("label", x);
}
xo.WriteEndElement(); // labels
xo.WriteEndElement(); // attribute
}
else
{
xo.WriteAttributeString("name", s);
xo.WriteAttributeString("type", "numeric");
xo.WriteStartElement("metadata");
xo.WriteStartElement("property");
xo.WriteAttributeString("name", "weight");
xo.WriteValue(curweight);
xo.WriteEndElement(); // property
xo.WriteEndElement(); // metadata
xo.WriteEndElement(); // attribute
}
}
while (xi.Read())
{
if (xi.NodeType == XmlNodeType.EndElement)
{
if (xi.Name == "attributes")
{
xo.WriteEndElement();
}
else if (xi.Name == "header")
{
xo.WriteEndElement();
break;
}
}
}
while (xi.Read())
{
if (xi.NodeType == XmlNodeType.Element && xi.IsStartElement())
{
xo.WriteStartElement(xi.Name);
xo.WriteAttributes(xi, true);
if (xi.Name == "instances")
break;
}
}
int vcount = 0;
while (xi.Read())
{
if (xi.Name == "instance")
{
if (xi.IsStartElement())
{
//.........这里部分代码省略.........