Beispiel #1
0
 private static void CategoricalToString(IList <int> colInds, IMatrixData mdata)
 {
     int[]        inds         = ArrayUtils.Complement(colInds, mdata.CategoryColumnCount);
     string[]     names        = ArrayUtils.SubArray(mdata.CategoryColumnNames, colInds);
     string[]     descriptions = ArrayUtils.SubArray(mdata.CategoryColumnDescriptions, colInds);
     string[][][] cat          = PerseusPluginUtils.GetCategoryColumns(mdata, colInds).ToArray();
     string[][]   newString    = new string[cat.Length][];
     for (int j = 0; j < cat.Length; j++)
     {
         newString[j] = new string[cat[j].Length];
         for (int i = 0; i < newString[j].Length; i++)
         {
             if (cat[j][i] == null || cat[j][i].Length == 0)
             {
                 newString[j][i] = "";
             }
             else
             {
                 newString[j][i] = StringUtils.Concat(";", cat[j][i]);
             }
         }
     }
     mdata.StringColumnNames.AddRange(names);
     mdata.StringColumnDescriptions.AddRange(descriptions);
     mdata.StringColumns.AddRange(newString);
     mdata.CategoryColumns            = PerseusPluginUtils.GetCategoryColumns(mdata, inds);
     mdata.CategoryColumnNames        = ArrayUtils.SubList(mdata.CategoryColumnNames, inds);
     mdata.CategoryColumnDescriptions = ArrayUtils.SubList(mdata.CategoryColumnDescriptions, inds);
 }
Beispiel #2
0
 public void ProcessData(IMatrixData data, Parameters param, ref IMatrixData[] supplTables,
                         ref IDocumentData[] documents, ProcessInfo processInfo)
 {
     int[] exColInds       = param.GetParam <int[]>("Main columns").Value;
     int[] numColInds      = param.GetParam <int[]>("Numerical columns").Value;
     int[] multiNumColInds = param.GetParam <int[]>("Multi-numerical columns").Value;
     int[] catColInds      = param.GetParam <int[]>("Categorical columns").Value;
     int[] textColInds     = param.GetParam <int[]>("Text columns").Value;
     data.ExtractColumns(exColInds);
     data.NumericColumns                 = ArrayUtils.SubList(data.NumericColumns, numColInds);
     data.NumericColumnNames             = ArrayUtils.SubList(data.NumericColumnNames, numColInds);
     data.NumericColumnDescriptions      = ArrayUtils.SubList(data.NumericColumnDescriptions, numColInds);
     data.MultiNumericColumns            = ArrayUtils.SubList(data.MultiNumericColumns, multiNumColInds);
     data.MultiNumericColumnNames        = ArrayUtils.SubList(data.MultiNumericColumnNames, multiNumColInds);
     data.MultiNumericColumnDescriptions = ArrayUtils.SubList(data.MultiNumericColumnDescriptions, multiNumColInds);
     data.CategoryColumns                = PerseusPluginUtils.GetCategoryColumns(data, catColInds);
     data.CategoryColumnNames            = ArrayUtils.SubList(data.CategoryColumnNames, catColInds);
     data.CategoryColumnDescriptions     = ArrayUtils.SubList(data.CategoryColumnDescriptions, catColInds);
     data.StringColumns            = ArrayUtils.SubList(data.StringColumns, textColInds);
     data.StringColumnNames        = ArrayUtils.SubList(data.StringColumnNames, textColInds);
     data.StringColumnDescriptions = ArrayUtils.SubList(data.StringColumnDescriptions, textColInds);
 }
        private static void CategoricalToNumeric(IList <int> colInds, IMatrixData mdata)
        {
            int[]        inds        = ArrayUtils.Complement(colInds, mdata.CategoryColumnCount);
            string[]     name        = ArrayUtils.SubArray(mdata.CategoryColumnNames, colInds);
            string[]     description = ArrayUtils.SubArray(mdata.CategoryColumnDescriptions, colInds);
            string[][][] cat         = PerseusPluginUtils.GetCategoryColumns(mdata, colInds).ToArray();
            var          newNum      = new double[cat.Length][];

            for (int j = 0; j < cat.Length; j++)
            {
                newNum[j] = new double[cat[j].Length];
                for (int i = 0; i < newNum[j].Length; i++)
                {
                    if (cat[j][i] == null || cat[j][i].Length == 0)
                    {
                        newNum[j][i] = double.NaN;
                    }
                    else
                    {
                        double x;
                        bool   s = double.TryParse(cat[j][i][0], out x);
                        if (s)
                        {
                            newNum[j][i] = x;
                        }
                        else
                        {
                            newNum[j][i] = double.NaN;
                        }
                    }
                }
            }
            mdata.NumericColumnNames.AddRange(name);
            mdata.NumericColumnDescriptions.AddRange(description);
            mdata.NumericColumns.AddRange(newNum);
            mdata.CategoryColumns            = PerseusPluginUtils.GetCategoryColumns(mdata, inds);
            mdata.CategoryColumnNames        = ArrayUtils.SubList(mdata.CategoryColumnNames, inds);
            mdata.CategoryColumnDescriptions = ArrayUtils.SubList(mdata.CategoryColumnDescriptions, inds);
        }
 public void ProcessData(IMatrixData data, Parameters param, ref IMatrixData[] supplTables,
                         ref IDocumentData[] documents, ProcessInfo processInfo)
 {
     int[] exColInds       = GetValidExCols(data);
     int[] numColInds      = GetValidNumCols(data);
     int[] multiNumColInds = GetValidMultiNumCols(data);
     int[] catColInds      = GetValidCatCols(data);
     int[] textColInds     = GetValidTextCols(data);
     if (exColInds.Length < data.ColumnCount)
     {
         data.ExtractColumns(exColInds);
     }
     if (numColInds.Length < data.NumericColumnCount)
     {
         data.NumericColumns            = ArrayUtils.SubList(data.NumericColumns, numColInds);
         data.NumericColumnNames        = ArrayUtils.SubList(data.NumericColumnNames, numColInds);
         data.NumericColumnDescriptions = ArrayUtils.SubList(data.NumericColumnDescriptions, numColInds);
     }
     if (multiNumColInds.Length < data.MultiNumericColumnCount)
     {
         data.MultiNumericColumns            = ArrayUtils.SubList(data.MultiNumericColumns, multiNumColInds);
         data.MultiNumericColumnNames        = ArrayUtils.SubList(data.MultiNumericColumnNames, multiNumColInds);
         data.MultiNumericColumnDescriptions = ArrayUtils.SubList(data.MultiNumericColumnDescriptions, multiNumColInds);
     }
     if (catColInds.Length < data.CategoryColumnCount)
     {
         data.CategoryColumns            = PerseusPluginUtils.GetCategoryColumns(data, catColInds);
         data.CategoryColumnNames        = ArrayUtils.SubList(data.CategoryColumnNames, catColInds);
         data.CategoryColumnDescriptions = ArrayUtils.SubList(data.CategoryColumnDescriptions, catColInds);
     }
     if (textColInds.Length < data.StringColumnCount)
     {
         data.StringColumns      = ArrayUtils.SubList(data.StringColumns, textColInds);
         data.StringColumnNames  = ArrayUtils.SubList(data.StringColumnNames, textColInds);
         data.ColumnDescriptions = ArrayUtils.SubList(data.StringColumnDescriptions, textColInds);
     }
 }