本文整理汇总了C#中IDataTable.Avg方法的典型用法代码示例。如果您正苦于以下问题:C# IDataTable.Avg方法的具体用法?C# IDataTable.Avg怎么用?C# IDataTable.Avg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDataTable
的用法示例。
在下文中一共展示了IDataTable.Avg方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: KMeans
public static DataSet KMeans(object threadpool,IDataTable<DataRow> data, string[] properties, int maxCount, int minClusterCount, int maxClusterCount, double m, double s, Protocol.Structure.WaitObject wt,int initialmode, int methodmode,int maxthread)
{
minClusterCount = minClusterCount < 2 ? 2 : minClusterCount;
maxClusterCount = maxClusterCount < 2 ? (int)Math.Pow(data.RowCount, 0.5) : maxClusterCount;
maxCount = maxCount < 2 ? 20 : maxCount;
maxthread = maxthread < 1 ? 1 : maxthread;
int paracount = properties.Length;
int i, j, k;
double[] mean;
double[] std;
if (!double.IsNaN(m))
{
mean = new double[paracount];
for (i = 0; i < paracount; i++)
mean[i] = m;
}
else
mean = data.Avg(properties);
if (!double.IsNaN(s))
{
std = new double[paracount];
for (i = 0; i < paracount; i++)
std[i] = s;
}
else
std = data.Stdev(properties, mean);
var temp = new MPPO.DataMining.KMeans(threadpool,data, properties, maxCount, minClusterCount, maxClusterCount, mean, std, wt,initialmode,methodmode,maxthread);
var clusterreport = temp.ParallelStart();
var report = new DataSet();
DataTable overview = new DataTable("OverView");
overview.Columns.Add(new DataColumn("序号", typeof(int)));
overview.Columns.Add(new DataColumn("分类数", typeof(int)));
overview.Columns.Add(new DataColumn("AvgBWP", typeof(double)));
overview.Columns.Add(new DataColumn("耗时", typeof(double)));
overview.Columns.Add(new DataColumn("循环次数", typeof(int)));
DataTable centers = new DataTable("Centers");
int len = properties.Length;
centers.Columns.Add(new DataColumn("序号", typeof(int)));
centers.Columns.Add(new DataColumn("类标号", typeof(int)));
for (i = 0; i < len; i++)
{
centers.Columns.Add(new DataColumn(properties[i], typeof(double)));
}
DataTable results = new DataTable("Results");
results.Columns.Add(new DataColumn("序号", typeof(int)));
results.Columns.Add(new DataColumn("行号", typeof(int)));
results.Columns.Add(new DataColumn("类标号", typeof(int)));
results.Columns.Add(new DataColumn("BWP", typeof(double)));
results.Columns.Add(new DataColumn("B", typeof(double)));
results.Columns.Add(new DataColumn("W", typeof(double)));
report.Tables.Add(overview);
report.Tables.Add(centers);
report.Tables.Add(results);
report.Relations.Add(new DataRelation("OverView_Centers", overview.Columns[0], centers.Columns[0]));
int count = clusterreport.HisResult.Count;
int datacount = data.RowCount;
for (i = 0; i < count; i++)
{
var tempresult = clusterreport.HisResult[i];
var tempreport = clusterreport.HisReport[i];
overview.Rows.Add(i, tempresult.cCount, tempreport.AvgBWP, tempresult.CostTime,tempresult.LoopCount);
for (j = 0; j < tempresult.cCount; j++)
{
var temprow = centers.NewRow();
temprow[0] = i;
temprow[1] = j;
for (k = 0; k < len; k++)
{
temprow[k+2] = tempresult.Centers[j,k];
}
centers.Rows.Add(temprow);
}
for (j = 0; j < datacount; j++)
{
results.Rows.Add(i, j, tempresult.ClassNumbers[j],tempreport.BWP[j], tempreport.B[j], tempreport.W[j]);
}
}
return report;
}