本文整理汇总了C#中IMatrixData.SetAnnotationColumns方法的典型用法代码示例。如果您正苦于以下问题:C# IMatrixData.SetAnnotationColumns方法的具体用法?C# IMatrixData.SetAnnotationColumns怎么用?C# IMatrixData.SetAnnotationColumns使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMatrixData
的用法示例。
在下文中一共展示了IMatrixData.SetAnnotationColumns方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadMatrixData
//.........这里部分代码省略.........
q = q.Substring(1, q.Length - 2);
}
if (q.Length >= 2 && q[0] == '\'' && q[q.Length - 1] == '\''){
q = q.Substring(1, q.Length - 2);
}
string[] ww = q.Length == 0 ? new string[0] : q.Split(';');
List<int> valids = new List<int>();
for (int j = 0; j < ww.Length; j++){
ww[j] = ww[j].Trim();
if (ww[j].Length > 0){
valids.Add(j);
}
}
ww = ArrayUtils.SubArray(ww, valids);
Array.Sort(ww);
if (categoryAnnotation[i].Length > count){
categoryAnnotation[i][count] = ww;
}
}
}
for (int i = 0; i < textColIndices.Count; i++){
if (textColIndices[i] >= w.Length){
stringAnnotation[i][count] = "";
} else{
string q = w[textColIndices[i]].Trim();
if (stringAnnotation[i].Length > count){
stringAnnotation[i][count] = RemoveSplitWhitespace(RemoveQuotes(q));
}
}
}
count++;
}
reader.Close();
string[] columnNames = ArrayUtils.SubArray(colNames, mainColIndices);
if (shortenExpressionNames){
columnNames = StringUtils.RemoveCommonSubstrings(columnNames, true);
}
string[] catColnames = ArrayUtils.SubArray(colNames, catColIndices);
string[] numColnames = ArrayUtils.SubArray(colNames, numColIndices);
string[] multiNumColnames = ArrayUtils.SubArray(colNames, multiNumColIndices);
string[] textColnames = ArrayUtils.SubArray(colNames, textColIndices);
matrixData.Name = origin;
matrixData.ColumnNames = RemoveQuotes(columnNames);
matrixData.Values.Set(mainValues);
if (hasAddtlMatrices){
matrixData.Quality.Set(qualityValues);
matrixData.IsImputed.Set(isImputedValues);
} else{
matrixData.Quality.Set(new float[mainValues.GetLength(0), mainValues.GetLength(1)]);
matrixData.IsImputed.Set(new bool[mainValues.GetLength(0), mainValues.GetLength(1)]);
}
matrixData.SetAnnotationColumns(RemoveQuotes(textColnames), stringAnnotation, RemoveQuotes(catColnames),
categoryAnnotation, RemoveQuotes(numColnames), numericAnnotation, RemoveQuotes(multiNumColnames),
multiNumericAnnotation);
if (colDescriptions != null){
string[] columnDesc = ArrayUtils.SubArray(colDescriptions, mainColIndices);
string[] catColDesc = ArrayUtils.SubArray(colDescriptions, catColIndices);
string[] numColDesc = ArrayUtils.SubArray(colDescriptions, numColIndices);
string[] multiNumColDesc = ArrayUtils.SubArray(colDescriptions, multiNumColIndices);
string[] textColDesc = ArrayUtils.SubArray(colDescriptions, textColIndices);
matrixData.ColumnDescriptions = new List<string>(columnDesc);
matrixData.NumericColumnDescriptions = new List<string>(numColDesc);
matrixData.CategoryColumnDescriptions = new List<string>(catColDesc);
matrixData.StringColumnDescriptions = new List<string>(textColDesc);
matrixData.MultiNumericColumnDescriptions = new List<string>(multiNumColDesc);
}
foreach (string key in catAnnotatRows.Keys){
string name = key;
string[] svals = ArrayUtils.SubArray(catAnnotatRows[key], mainColIndices);
string[][] cat = new string[svals.Length][];
for (int i = 0; i < cat.Length; i++){
string s = svals[i].Trim();
cat[i] = s.Length > 0 ? s.Split(';') : new string[0];
List<int> valids = new List<int>();
for (int j = 0; j < cat[i].Length; j++){
cat[i][j] = cat[i][j].Trim();
if (cat[i][j].Length > 0){
valids.Add(j);
}
}
cat[i] = ArrayUtils.SubArray(cat[i], valids);
Array.Sort(cat[i]);
}
matrixData.AddCategoryRow(name, name, cat);
}
foreach (string key in numAnnotatRows.Keys){
string name = key;
string[] svals = ArrayUtils.SubArray(numAnnotatRows[key], mainColIndices);
double[] num = new double[svals.Length];
for (int i = 0; i < num.Length; i++){
string s = svals[i].Trim();
num[i] = double.NaN;
double.TryParse(s, out num[i]);
}
matrixData.AddNumericRow(name, name, num);
}
matrixData.Origin = origin;
progress(0);
status("");
}
示例2: ProcessData
public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
ref IDocumentData[] documents, ProcessInfo processInfo)
{
int nameCol = param.GetParam<int>("New column names").Value;
List<string> colNames;
if (nameCol >= 0){
HashSet<string> taken = new HashSet<string>();
colNames = new List<string>();
foreach (string n in mdata.StringColumns[nameCol]){
string n1 = StringUtils.GetNextAvailableName(n, taken);
taken.Add(n1);
colNames.Add(n1);
}
} else{
colNames = new List<string>();
for (int i = 0; i < mdata.RowCount; i++){
colNames.Add("Column" + (i + 1));
}
}
List<string> rowNames = mdata.ColumnNames;
mdata.Values = mdata.Values.Transpose();
if (mdata.IsImputed != null){
mdata.IsImputed = mdata.IsImputed.Transpose();
}
if (mdata.Quality != null){
mdata.Quality = mdata.Quality.Transpose();
}
List<string> stringColumnNames = mdata.StringColumnNames;
List<string> categoryColumnNames = mdata.CategoryColumnNames;
List<string> numericColumnNames = mdata.NumericColumnNames;
List<string> multiNumericColumnNames = mdata.MultiNumericColumnNames;
List<string> stringColumnDescriptions = mdata.StringColumnDescriptions;
List<string> categoryColumnDescriptions = mdata.CategoryColumnDescriptions;
List<string> numericColumnDescriptions = mdata.NumericColumnDescriptions;
List<string> multiNumericColumnDescriptions = mdata.MultiNumericColumnDescriptions;
List<string[]> stringColumns = mdata.StringColumns;
List<string[][]> categoryColumns = GetCategoryColumns(mdata);
List<double[]> numericColumns = mdata.NumericColumns;
List<double[][]> multiNumericColumns = mdata.MultiNumericColumns;
mdata.SetAnnotationColumns(new List<string>(new[]{"Name"}), new List<string>(new[]{"Name"}),
new List<string[]>(new[]{rowNames.ToArray()}), mdata.CategoryRowNames, mdata.CategoryRowDescriptions,
GetCategoryRows(mdata), mdata.NumericRowNames, mdata.NumericRowDescriptions, mdata.NumericRows, new List<string>(),
new List<string>(), new List<double[][]>());
mdata.ColumnNames = colNames;
mdata.SetAnnotationRows(stringColumnNames, stringColumnDescriptions, stringColumns, categoryColumnNames,
categoryColumnDescriptions, categoryColumns, numericColumnNames, numericColumnDescriptions, numericColumns,
multiNumericColumnNames, multiNumericColumnDescriptions, multiNumericColumns);
}
示例3: ProcessData
public void ProcessData(IMatrixData mdata, Parameters param1, ref IMatrixData[] supplTables,
ref IDocumentData[] documents, ProcessInfo processInfo)
{
int[] multiNumCols = param1.GetParam<int[]>("Multi-numeric columns").Value;
Array.Sort(multiNumCols);
int[] stringCols = param1.GetParam<int[]>("Text columns").Value;
Array.Sort(stringCols);
HashSet<int> multinumCols2 = new HashSet<int>(multiNumCols);
HashSet<int> stringCols2 = new HashSet<int>(stringCols);
if (multiNumCols.Length + stringCols.Length == 0){
processInfo.ErrString = "Please select some columns.";
return;
}
int rowCount = GetNewRowCount(mdata, multiNumCols, stringCols);
float[,] expVals = new float[rowCount, mdata.ColumnCount];
List<string[]> stringC = new List<string[]>();
for (int i = 0; i < mdata.StringColumnCount; i++){
stringC.Add(new string[rowCount]);
}
List<double[]> numC = new List<double[]>();
for (int i = 0; i < mdata.NumericColumnCount; i++){
numC.Add(new double[rowCount]);
}
List<string[][]> catC = new List<string[][]>();
for (int i = 0; i < mdata.CategoryColumnCount; i++){
catC.Add(new string[rowCount][]);
}
List<double[][]> multiNumC = new List<double[][]>();
for (int i = 0; i < mdata.MultiNumericColumnCount; i++){
multiNumC.Add(new double[rowCount][]);
}
int count = 0;
for (int i = 0; i < mdata.RowCount; i++){
string err;
int entryCount = GetEntryCount(i, mdata, multiNumCols, stringCols, out err);
if (err != null){
processInfo.ErrString = err;
return;
}
bool empty = entryCount == 0;
entryCount = Math.Max(entryCount, 1);
for (int j = 0; j < entryCount; j++){
for (int k = 0; k < mdata.ColumnCount; k++){
expVals[count + j, k] = mdata.Values.Get(i, k);
}
for (int k = 0; k < mdata.NumericColumnCount; k++){
numC[k][count + j] = mdata.NumericColumns[k][i];
}
for (int k = 0; k < mdata.CategoryColumnCount; k++){
catC[k][count + j] = mdata.GetCategoryColumnEntryAt(k, i);
}
}
for (int k = 0; k < mdata.MultiNumericColumnCount; k++){
if (multinumCols2.Contains(k)){
if (empty){
multiNumC[k][count] = new double[0];
} else{
double[] vals = mdata.MultiNumericColumns[k][i];
for (int j = 0; j < entryCount; j++){
multiNumC[k][count + j] = new[]{vals[j]};
}
}
} else{
for (int j = 0; j < entryCount; j++){
multiNumC[k][count + j] = mdata.MultiNumericColumns[k][i];
}
}
}
for (int k = 0; k < mdata.StringColumnCount; k++){
if (stringCols2.Contains(k)){
if (empty){
stringC[k][count] = "";
} else{
string[] vals = mdata.StringColumns[k][i].Split(';');
for (int j = 0; j < entryCount; j++){
stringC[k][count + j] = vals[j];
}
}
} else{
for (int j = 0; j < entryCount; j++){
stringC[k][count + j] = mdata.StringColumns[k][i];
}
}
}
count += entryCount;
}
int[] multiNumComplement = ArrayUtils.Complement(multiNumCols, mdata.MultiNumericColumnCount);
List<double[][]> toBeTransformed = ArrayUtils.SubList(multiNumC, multiNumCols);
multiNumC = ArrayUtils.SubList(multiNumC, multiNumComplement);
foreach (double[][] d in toBeTransformed){
numC.Add(Transform(d));
}
mdata.ColumnNames = mdata.ColumnNames;
mdata.Values.Set(expVals);
mdata.SetAnnotationColumns(mdata.StringColumnNames, stringC, mdata.CategoryColumnNames, catC,
new List<string>(ArrayUtils.Concat(mdata.NumericColumnNames,
ArrayUtils.SubList(mdata.MultiNumericColumnNames, multiNumCols))), numC,
new List<string>(ArrayUtils.SubArray(mdata.MultiNumericColumnNames, multiNumComplement)), multiNumC);
}
示例4: ProcessData
public void ProcessData(IMatrixData data, Parameters param, ref IMatrixData[] supplTables,
ref IDocumentData[] documents, ProcessInfo processInfo)
{
bool falseAreIndicated = param.GetParam<int>("Indicated are").Value == 0;
int catCol = param.GetParam<int>("In column").Value;
string word = param.GetParam<string>("Indicator").Value;
int[] scoreColumns = param.GetParam<int[]>("Scores").Value;
if (scoreColumns.Length == 0){
processInfo.ErrString = "Please specify at least one column with scores.";
return;
}
bool largeIsGood = param.GetParam<bool>("Large values are good").Value;
int[] showColumns = param.GetParam<int[]>("Display quantity").Value;
if (showColumns.Length == 0){
processInfo.ErrString = "Please select at least one quantity to display";
return;
}
bool[] indCol = GetIndicatorColumn(falseAreIndicated, catCol, word, data);
List<string> expColNames = new List<string>();
List<float[]> expCols = new List<float[]>();
foreach (int scoreColumn in scoreColumns){
double[] vals = scoreColumn < data.NumericColumnCount
? data.NumericColumns[scoreColumn]
: ArrayUtils.ToDoubles(data.Values.GetColumn(scoreColumn - data.NumericColumnCount));
string name = scoreColumn < data.NumericColumnCount
? data.NumericColumnNames[scoreColumn] : data.ColumnNames[scoreColumn - data.NumericColumnCount];
int[] order = GetOrder(vals, largeIsGood);
CalcCurve(ArrayUtils.SubArray(indCol, order), showColumns, name, expCols, expColNames);
}
float[,] expData = ToMatrix(expCols);
data.ColumnNames = expColNames;
data.Values.Set(expData);
data.SetAnnotationColumns( new List<string>(), new List<string[]>(), new List<string>(),
new List<string[][]>(), new List<string>(), new List<double[]>(), new List<string>(), new List<double[][]>());
}