本文整理汇总了C#中Parameters.GetParam方法的典型用法代码示例。如果您正苦于以下问题:C# Parameters.GetParam方法的具体用法?C# Parameters.GetParam怎么用?C# Parameters.GetParam使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parameters
的用法示例。
在下文中一共展示了Parameters.GetParam方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessData
public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
ref IDocumentData[] documents, ProcessInfo processInfo)
{
Random2 rand = new Random2();
double std = param.GetParam<double>("Standard deviation").Value;
int[] inds = param.GetParam<int[]>("Columns").Value;
List<int> mainInds = new List<int>();
List<int> numInds = new List<int>();
foreach (int ind in inds){
if (ind < mdata.ColumnCount){
mainInds.Add(ind);
} else{
numInds.Add(ind - mdata.ColumnCount);
}
}
foreach (int j in mainInds){
for (int i = 0; i < mdata.RowCount; i++){
mdata.Values.Set(i, j, mdata.Values.Get(i, j) + (float) rand.NextGaussian(0, std));
}
}
foreach (int j in numInds){
for (int i = 0; i < mdata.RowCount; i++){
mdata.NumericColumns[j][i] += (float) rand.NextGaussian(0, std);
}
}
}
示例2: ProcessData
public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
ref IDocumentData[] documents, ProcessInfo processInfo)
{
bool rows = param.GetParam<int>("Matrix access").Value == 0;
double min = param.GetParam<double>("Minimum").Value;
double max = param.GetParam<double>("Maximum").Value;
MapToInterval1(rows, mdata, min, max, processInfo.NumThreads);
}
示例3: ProcessData
public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
ref IDocumentData[] documents, ProcessInfo processInfo)
{
string[] mods = param.GetParam<int[]>("Modifications").StringValue.Split(new[]{';'},
StringSplitOptions.RemoveEmptyEntries);
string[] up = mdata.StringColumns[param.GetParam<int>("Uniprot column").Value];
string[][] uprot = new string[up.Length][];
for (int i = 0; i < up.Length; i++){
uprot[i] = up[i].Length > 0 ? up[i].Split(';') : new string[0];
}
double[][] c = new double[mods.Length][];
for (int index = 0; index < mods.Length; index++){
string mod = mods[index];
string filename = PhosphoSitePlusParser.GetFilenameForMod(mod);
if (filename == null){
processInfo.ErrString = "File does not exist.";
return;
}
string[] seqWins;
string[] accs;
string[] pubmedLtp;
string[] pubmedMs2;
string[] cstMs2;
string[] species;
PhosphoSitePlusParser.ParseKnownMods(filename, out seqWins, out accs, out pubmedLtp, out pubmedMs2, out cstMs2, out species);
for (int i = 0; i < seqWins.Length; i++){
seqWins[i] = seqWins[i].ToUpper();
}
Dictionary<string, HashSet<string>> counts = new Dictionary<string, HashSet<string>>();
for (int i = 0; i < accs.Length; i++){
string acc = accs[i];
if (!counts.ContainsKey(acc)){
counts.Add(acc, new HashSet<string>());
}
counts[acc].Add(seqWins[i]);
}
c[index] = new double[up.Length];
for (int i = 0; i < up.Length; i++){
c[index][i] = CountSites(uprot[i], counts);
}
}
string[][] catCol = new string[up.Length][];
for (int i = 0; i < catCol.Length; i++){
List<string> x = new List<string>();
for (int j = 0; j < mods.Length; j++){
if (c[j][i] > 0){
x.Add(mods[j]);
}
}
x.Sort();
catCol[i] = x.ToArray();
}
mdata.AddCategoryColumn("Known modifications", "Known modifications", catCol);
for (int i = 0; i < mods.Length; i++){
mdata.AddNumericColumn(mods[i] + " count", mods[i] + " count", c[i]);
}
}
示例4: ProcessData
public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
ref IDocumentData[] documents, ProcessInfo processInfo)
{
string regexStr = param.GetParam<string>("Regular expression").Value;
Regex regex = new Regex(regexStr);
int[] inds = param.GetParam<int[]>("Columns").Value;
bool keepColumns = param.GetParam<bool>("Keep original columns").Value;
bool semicolons = param.GetParam<bool>("Strings separated by semicolons are independent").Value;
foreach (int col in inds){
ProcessCol(mdata, regex, col, keepColumns, semicolons);
}
}
示例5: ProcessData
public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
ref IDocumentData[] documents, ProcessInfo processInfo)
{
string colName = param.GetParam<string>("Name of new column").Value;
int[] columns = param.GetParam<int[]>("Categories").Value;
bool inverse = param.GetParam<bool>("Inverse").Value;
int[] catCols;
int[] stringCols;
Split(columns, out catCols, out stringCols, mdata.CategoryColumnCount);
string[] word1 = param.GetParam<string[]>("Search terms").Value;
if (word1.Length == 0){
processInfo.ErrString = "Please specify one or more search terms.";
return;
}
if (string.IsNullOrEmpty(colName)){
colName = word1[0];
}
string[] word = new string[word1.Length];
for (int i = 0; i < word.Length; i++){
word[i] = word1[i].ToLower().Trim();
}
bool[] indicator = new bool[mdata.RowCount];
foreach (int col in catCols){
for (int i = 0; i < mdata.RowCount; i++){
foreach (string s in mdata.GetCategoryColumnEntryAt(col, i)){
foreach (string s1 in word){
if (s.ToLower().Contains(s1)){
indicator[i] = true;
break;
}
}
}
}
}
foreach (string[] txt in stringCols.Select(col => mdata.StringColumns[col])){
for (int i = 0; i < txt.Length; i++){
string s = txt[i];
foreach (string s1 in word){
if (s.ToLower().Contains(s1)){
indicator[i] = true;
break;
}
}
}
}
string[][] newCol = new string[indicator.Length][];
for (int i = 0; i < newCol.Length; i++){
bool yes = inverse ? !indicator[i] : indicator[i];
newCol[i] = yes ? new[]{"+"} : new string[0];
}
mdata.AddCategoryColumn(colName, "", newCol);
}
示例6: ProcessData
public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
ref IDocumentData[] documents, ProcessInfo processInfo)
{
string word = param.GetParam<string>("Find what").Value;
int colInd = param.GetParam<int>("Look in").Value;
bool matchCase = param.GetParam<bool>("Match case").Value;
bool matchWholeWord = param.GetParam<bool>("Match whole word").Value;
string scolName = mdata.StringColumnNames[colInd];
string[] scol = mdata.StringColumns[colInd];
string[][] catCol = new string[mdata.RowCount][];
for (int i = 0; i < catCol.Length; i++){
bool found = Find(scol[i], word, matchCase, matchWholeWord);
catCol[i] = found ? new[]{"+"} : new string[0];
}
mdata.AddCategoryColumn("Search: " + scolName, "Search: " + scolName, catCol);
}
示例7: Train
public override ClassificationModel Train(BaseVector[] x, int[][] y, int ngroups, Parameters param, int nthreads,
Action<double> reportProgress)
{
int k = param.GetParam<int>("Number of neighbours").Value;
IDistance distance = Distances.GetDistanceFunction(param);
return new KnnClassificationModel(x, y, ngroups, k, distance);
}
示例8: ProcessData
public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
ref IDocumentData[] documents, ProcessInfo processInfo)
{
Parameter<int> access = param.GetParam<int>("Matrix access");
bool rows = access.Value == 0;
UnitVectors(rows, mdata);
}
示例9: Rank
public override int[] Rank(BaseVector[] x, int[][] y, int ngroups, Parameters param, IGroupDataProvider data,
int nthreads, Action<double> reportProgress)
{
SvmParameter sp = new SvmParameter{
kernelFunction = new LinearKernelFunction(),
svmType = SvmType.CSvc,
c = param.GetParam<double>("C").Value
};
double redfactor = param.GetParam<double>("Reduction factor").Value;
bool[] invert;
SvmProblem[] problems = CreateProblems(x, y, ngroups, out invert);
int[][] rankedSets = new int[problems.Length][];
for (int i = 0; i < problems.Length; ++i){
rankedSets[i] = RankBinary(problems[i], sp, redfactor);
}
return CombineRankedFeaturesLists(rankedSets);
}
示例10: ProcessData
public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
ref IDocumentData[] documents, ProcessInfo processInfo)
{
var vals = param.GetParam<Tuple<Regex, string>>("Regex").Value;
var pattern = vals.Item1;
string replacementStr = vals.Item2;
for (int i = 0; i < mdata.ColumnCount; i++){
mdata.ColumnNames[i] = pattern.Replace(mdata.ColumnNames[i], replacementStr);
}
}
示例11: ProcessData
public void ProcessData(IMatrixData data, Parameters param, ref IMatrixData[] supplTables,
ref IDocumentData[] documents, ProcessInfo processInfo)
{
int[] numColInds = param.GetParam<int[]>("Numerical rows").Value;
int[] multiNumColInds = param.GetParam<int[]>("Multi-numerical rows").Value;
int[] catColInds = param.GetParam<int[]>("Categorical rows").Value;
int[] textColInds = param.GetParam<int[]>("Text rows").Value;
data.NumericRows = ArrayUtils.SubList(data.NumericRows, numColInds);
data.NumericRowNames = ArrayUtils.SubList(data.NumericRowNames, numColInds);
data.NumericRowDescriptions = ArrayUtils.SubList(data.NumericRowDescriptions, numColInds);
data.MultiNumericRows = ArrayUtils.SubList(data.MultiNumericRows, multiNumColInds);
data.MultiNumericRowNames = ArrayUtils.SubList(data.MultiNumericRowNames, multiNumColInds);
data.MultiNumericRowDescriptions = ArrayUtils.SubList(data.MultiNumericRowDescriptions, multiNumColInds);
data.CategoryRows = PerseusPluginUtils.GetCategoryRows(data, catColInds);
data.CategoryRowNames = ArrayUtils.SubList(data.CategoryRowNames, catColInds);
data.CategoryRowDescriptions = ArrayUtils.SubList(data.CategoryRowDescriptions, catColInds);
data.StringRows = ArrayUtils.SubList(data.StringRows, textColInds);
data.StringRowNames = ArrayUtils.SubList(data.StringRowNames, textColInds);
data.StringRowDescriptions = ArrayUtils.SubList(data.StringRowDescriptions, textColInds);
}
示例12: Train
public RegressionModel Train(BaseVector[] x, float[] y, Parameters param, int nthreads)
{
ParameterWithSubParams<int> kernelParam = param.GetParamWithSubParams<int>("Kernel");
SvmParameter sp = new SvmParameter{
kernelFunction = KernelFunctions.GetKernelFunction(kernelParam.Value, kernelParam.GetSubParameters()),
svmType = SvmType.EpsilonSvr,
c = param.GetParam<double>("C").Value
};
SvmModel model = SvmMain.SvmTrain(new SvmProblem(x, y), sp);
return new SvmRegressionModel(model);
}
示例13: ProcessData
public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
ref IDocumentData[] documents, ProcessInfo processInfo)
{
int stringColumnIndx = param.GetParam<int>("Sequence window").Value;
string[] win = mdata.StringColumns[stringColumnIndx];
int start = param.GetParam<int>("Start").Value - 1;
int length = param.GetParam<int>("Length").Value;
if (start < 0){
processInfo.ErrString = "Start position cannot be smaller than 1.";
return;
}
if (start + length > win[0].Length){
processInfo.ErrString = "Start + length cannot exceed the total length of the sequence.";
return;
}
string[] shortenedMotifs = new string[win.Length];
for (int i = 0; i < mdata.RowCount; ++i){
shortenedMotifs[i] = win[i].Substring(start, length);
}
mdata.AddStringColumn("Short sequence window", "", shortenedMotifs);
}
示例14: ProcessData
public IMatrixData ProcessData(IMatrixData[] inputData, Parameters parameters, ref IMatrixData[] supplTables,
ref IDocumentData[] documents, ProcessInfo processInfo)
{
IMatrixData mdata1 = inputData[0];
Dictionary<string, string> map = GetMap(inputData[1], parameters);
IMatrixData result = (IMatrixData) mdata1.Clone();
int ind = parameters.GetParam<int>("Column in matrix 1 to be edited").Value;
string[] x = mdata1.StringColumns[ind];
for (int i = 0; i < x.Length; i++){
x[i] = Process(x[i], map);
}
return result;
}
示例15: ProcessData
public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
ref IDocumentData[] documents, ProcessInfo processInfo)
{
string[][] col = mdata.GetCategoryColumnAt(param.GetParam<int>("Indicator column").Value);
string term = param.GetParam<string>("Value").Value;
List<int> inds = new List<int>();
for (int i = 0; i < col.Length; i++){
if (Contains(col[i], term)){
inds.Add(i);
}
}
double[][] profiles = new double[inds.Count][];
for (int i = 0; i < profiles.Length; i++){
profiles[i] = ArrayUtils.ToDoubles(mdata.Values.GetRow(inds[i]));
float mean = (float) ArrayUtils.Mean(profiles[i]);
for (int j = 0; j < profiles[i].Length; j++){
profiles[i][j] -= mean;
}
}
double[] totalProfile = new double[mdata.ColumnCount];
for (int i = 0; i < totalProfile.Length; i++){
List<double> vals = new List<double>();
foreach (double[] t in profiles){
double val = t[i];
if (double.IsNaN(val) || double.IsInfinity(val)){
continue;
}
vals.Add(val);
}
totalProfile[i] = vals.Count > 0 ? ArrayUtils.Median(vals) : double.NaN;
}
for (int i = 0; i < mdata.RowCount; i++){
for (int j = 0; j < mdata.ColumnCount; j++){
mdata.Values.Set(i, j, mdata.Values.Get(i, j)-(float) totalProfile[j]);
}
}
}