本文整理汇总了C#中IMatrixData.SetCategoryRowAt方法的典型用法代码示例。如果您正苦于以下问题:C# IMatrixData.SetCategoryRowAt方法的具体用法?C# IMatrixData.SetCategoryRowAt怎么用?C# IMatrixData.SetCategoryRowAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMatrixData
的用法示例。
在下文中一共展示了IMatrixData.SetCategoryRowAt方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessDataEdit
private static void ProcessDataEdit(IMatrixData mdata, Parameters param)
{
SingleChoiceWithSubParams s = param.GetSingleChoiceWithSubParams("Category row");
int groupColInd = s.Value;
Parameters sp = s.GetSubParameters();
string[][] newRow = new string[mdata.ExpressionColumnCount][];
for (int i = 0; i < mdata.ExpressionColumnCount; i++){
string t = mdata.ExpressionColumnNames[i];
string x = sp.GetStringParam(t).Value;
newRow[i] = x.Length > 0 ? x.Split(';') : new string[0];
}
mdata.SetCategoryRowAt(newRow, groupColInd);
}
示例2: DivideByColumn
public static void DivideByColumn(IMatrixData data, int index)
{
int p = data.RowCount;
int n = data.ExpressionColumnCount;
float[,] newEx = new float[p,n - 1];
for (int i = 0; i < p; i++){
for (int j = 0; j < index; j++){
newEx[i, j] = data[i, j]/data[i, index];
if (float.IsInfinity(newEx[i, j])){
newEx[i, j] = float.NaN;
}
}
for (int j = index + 1; j < n; j++){
newEx[i, j - 1] = data[i, j]/data[i, index];
if (float.IsInfinity(newEx[i, j - 1])){
newEx[i, j - 1] = float.NaN;
}
}
}
bool[,] newImp = new bool[p,n - 1];
for (int i = 0; i < p; i++){
for (int j = 0; j < index; j++){
newImp[i, j] = data.IsImputed[i, j] || data.IsImputed[i, index];
}
for (int j = index + 1; j < n; j++){
newImp[i, j - 1] = data.IsImputed[i, j] || data.IsImputed[i, index];
}
}
data.ExpressionValues = newEx;
data.IsImputed = newImp;
data.ExpressionColumnNames.RemoveAt(index);
data.ExpressionColumnDescriptions.RemoveAt(index);
for (int i = 0; i < data.CategoryRowCount; i++){
data.SetCategoryRowAt(ArrayUtils.RemoveAtIndex(data.GetCategoryRowAt(i), index), i);
}
for (int i = 0; i < data.NumericRowCount; i++){
data.NumericRows[i] = ArrayUtils.RemoveAtIndex(data.NumericRows[i], index);
}
}
示例3: FillMatrixDontKeep
private static void FillMatrixDontKeep(int groupColInd, int validVals, IMatrixData mdata,
Func<IList<double>, double> func)
{
string[][] groupCol = mdata.GetCategoryRowAt(groupColInd);
string[] groupNames = ArrayUtils.UniqueValuesPreserveOrder(groupCol);
int[][] colInds = PerseusPluginUtils.GetExpressionColIndices(groupCol, groupNames);
float[,] newExCols = new float[mdata.RowCount,groupNames.Length];
float[,] newQuality = new float[mdata.RowCount,groupNames.Length];
bool[,] newImputed = new bool[mdata.RowCount,groupNames.Length];
for (int i = 0; i < newExCols.GetLength(0); i++){
for (int j = 0; j < newExCols.GetLength(1); j++){
List<double> vals = new List<double>();
List<bool> imps = new List<bool>();
foreach (int ind in colInds[j]){
double val = mdata[i, ind];
if (!double.IsNaN(val) && !double.IsInfinity(val)){
vals.Add(val);
imps.Add(mdata.IsImputed[i, ind]);
}
}
bool imp = false;
float xy = float.NaN;
if (vals.Count >= validVals){
xy = (float) func(vals);
imp = ArrayUtils.Or(imps);
}
newExCols[i, j] = xy;
newQuality[i, j] = float.NaN;
newImputed[i, j] = imp;
}
}
mdata.ExpressionColumnNames = new List<string>(groupNames);
mdata.ExpressionColumnDescriptions = GetEmpty(groupNames);
mdata.ExpressionValues = newExCols;
mdata.QualityValues = newQuality;
mdata.IsImputed = newImputed;
mdata.RemoveCategoryRowAt(groupColInd);
for (int i = 0; i < mdata.CategoryRowCount; i++){
mdata.SetCategoryRowAt(AverageCategoryRow(mdata.GetCategoryRowAt(i), colInds), i);
}
for (int i = 0; i < mdata.NumericRows.Count; i++){
mdata.NumericRows[i] = AverageNumericRow(mdata.NumericRows[i], colInds);
}
}
示例4: ProcessData
public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
ref IDocumentData[] documents, ProcessInfo processInfo)
{
SingleChoiceWithSubParams p = param.GetSingleChoiceWithSubParams("Row");
int colInd = p.Value;
if (colInd < 0) {
processInfo.ErrString = "No categorical rows available.";
return;
}
MultiChoiceParam mcp = p.GetSubParameters().GetMultiChoiceParam("Values");
int[] inds = mcp.Value;
if (inds.Length < 1) {
processInfo.ErrString = "Please select at least two terms for merging.";
return;
}
string newTerm = param.GetStringParam("New term").Value;
if (newTerm.Length == 0){
processInfo.ErrString = "Please specify a new term.";
return;
}
string[] values = new string[inds.Length];
for (int i = 0; i < values.Length; i++) {
values[i] = mdata.GetCategoryRowValuesAt(colInd)[inds[i]];
}
HashSet<string> value = new HashSet<string>(values);
string[][] cats = mdata.GetCategoryRowAt(colInd);
string[][] newCat = new string[cats.Length][];
for (int i = 0; i < cats.Length; i++){
string[] w = cats[i];
bool changed = false;
for (int j = 0; j < w.Length; j++){
if (value.Contains(w[j])){
w[j] = newTerm;
changed = true;
}
}
if (changed){
Array.Sort(w);
}
newCat[i] = w;
}
mdata.SetCategoryRowAt(newCat, colInd);
}
示例5: StringToExpression
private static void StringToExpression(IList<int> colInds, IMatrixData mdata)
{
int[] inds = ArrayUtils.Complement(colInds, mdata.StringColumnCount);
string[] names = ArrayUtils.SubArray(mdata.StringColumnNames, colInds);
string[] descriptions = ArrayUtils.SubArray(mdata.StringColumnDescriptions, colInds);
string[][] str = ArrayUtils.SubArray(mdata.StringColumns, colInds);
float[][] newEx = new float[str.Length][];
for (int j = 0; j < str.Length; j++){
newEx[j] = new float[str[j].Length];
for (int i = 0; i < newEx[j].Length; i++){
float f;
bool success = float.TryParse(str[j][i], out f);
newEx[j][i] = success ? f : float.NaN;
}
}
float[,] newExp = new float[mdata.RowCount,mdata.ExpressionColumnCount + str.Length];
float[,] newQual = new float[mdata.RowCount,mdata.ExpressionColumnCount + str.Length];
bool[,] newIsImputed = new bool[mdata.RowCount,mdata.ExpressionColumnCount + str.Length];
for (int i = 0; i < mdata.RowCount; i++){
for (int j = 0; j < mdata.ExpressionColumnCount; j++){
newExp[i, j] = mdata[i, j];
newQual[i, j] = mdata.QualityValues[i, j];
newIsImputed[i, j] = mdata.IsImputed[i, j];
}
for (int j = 0; j < newEx.Length; j++){
newExp[i, j + mdata.ExpressionColumnCount] = newEx[j][i];
newQual[i, j + mdata.ExpressionColumnCount] = float.NaN;
newIsImputed[i, j + mdata.ExpressionColumnCount] = false;
}
}
mdata.ExpressionValues = newExp;
mdata.QualityValues = newQual;
mdata.IsImputed = newIsImputed;
mdata.ExpressionColumnNames.AddRange(names);
mdata.ExpressionColumnDescriptions.AddRange(descriptions);
mdata.StringColumns = ArrayUtils.SubList(mdata.StringColumns, inds);
mdata.StringColumnNames = ArrayUtils.SubList(mdata.StringColumnNames, inds);
mdata.StringColumnDescriptions = ArrayUtils.SubList(mdata.StringColumnDescriptions, inds);
for (int i = 0; i < mdata.CategoryRowCount; i++){
mdata.SetCategoryRowAt(ExtendCategoryRow(mdata.GetCategoryRowAt(i), str.Length),i);
}
for (int i = 0; i < mdata.NumericRows.Count; i++){
mdata.NumericRows[i] = ExtendNumericRow(mdata.NumericRows[i], str.Length);
}
}