当前位置: 首页>>代码示例>>C#>>正文


C# IDataset.GetReadOnlyDoubleValues方法代码示例

本文整理汇总了C#中IDataset.GetReadOnlyDoubleValues方法的典型用法代码示例。如果您正苦于以下问题:C# IDataset.GetReadOnlyDoubleValues方法的具体用法?C# IDataset.GetReadOnlyDoubleValues怎么用?C# IDataset.GetReadOnlyDoubleValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDataset的用法示例。


在下文中一共展示了IDataset.GetReadOnlyDoubleValues方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetPrognosedValues

    public IEnumerable<IEnumerable<double>> GetPrognosedValues(IDataset dataset, IEnumerable<int> rows, IEnumerable<int> horizons) {
      var rowsEnumerator = rows.GetEnumerator();
      var horizonsEnumerator = horizons.GetEnumerator();
      var targetValues = dataset.GetReadOnlyDoubleValues(TargetVariable);
      // produce a n-step forecast for all rows
      while (rowsEnumerator.MoveNext() & horizonsEnumerator.MoveNext()) {
        int row = rowsEnumerator.Current;
        int horizon = horizonsEnumerator.Current;
        if (row - TimeOffset < 0) {
          yield return Enumerable.Repeat(double.NaN, horizon);
          continue;
        }

        double[] prognosis = new double[horizon];
        for (int h = 0; h < horizon; h++) {
          double estimatedValue = 0.0;
          for (int i = 1; i <= TimeOffset; i++) {
            int offset = h - i;
            if (offset >= 0) estimatedValue += prognosis[offset] * Phi[i - 1];
            else estimatedValue += targetValues[row + offset] * Phi[i - 1];

          }
          estimatedValue += Constant;
          prognosis[h] = estimatedValue;
        }

        yield return prognosis;
      }

      if (rowsEnumerator.MoveNext() || horizonsEnumerator.MoveNext())
        throw new ArgumentException("Number of elements in rows and horizon enumerations doesn't match.");
    }
开发者ID:t-h-e,项目名称:HeuristicLab,代码行数:32,代码来源:TimeSeriesPrognosisAutoRegressiveModel.cs

示例2: GetSymbolicExpressionTreeValues

    public IEnumerable<double> GetSymbolicExpressionTreeValues(ISymbolicExpressionTree tree, IDataset dataset, IEnumerable<int> rows) {
      if (CheckExpressionsWithIntervalArithmetic.Value)
        throw new NotSupportedException("Interval arithmetic is not yet supported in the symbolic data analysis interpreter.");

      EvaluatedSolutions.Value++; // increment the evaluated solutions counter
      var state = PrepareInterpreterState(tree, dataset);

      Type[] methodArgs = { typeof(int), typeof(IList<double>[]) };
      DynamicMethod testFun = new DynamicMethod("TestFun", typeof(double), methodArgs, typeof(SymbolicDataAnalysisExpressionTreeILEmittingInterpreter).Module);

      ILGenerator il = testFun.GetILGenerator();
      CompileInstructions(il, state, dataset);
      il.Emit(System.Reflection.Emit.OpCodes.Conv_R8);
      il.Emit(System.Reflection.Emit.OpCodes.Ret);
      var function = (CompiledFunction)testFun.CreateDelegate(typeof(CompiledFunction));

      IList<double>[] columns = dataset.DoubleVariables.Select(v => dataset.GetReadOnlyDoubleValues(v)).ToArray();

      foreach (var row in rows) {
        yield return function(row, columns);
      }
    }
开发者ID:thunder176,项目名称:HeuristicLab,代码行数:22,代码来源:SymbolicDataAnalysisExpressionTreeILEmittingInterpreter.cs

示例3: SampleTrainingData

 private void SampleTrainingData(MersenneTwister rand, ModifiableDataset ds, int rRows,
   IDataset sourceDs, double[] curTarget, string targetVarName, IEnumerable<int> trainingIndices) {
   var selectedRows = trainingIndices.SampleRandomWithoutRepetition(rand, rRows).ToArray();
   int t = 0;
   object[] srcRow = new object[ds.Columns];
   var varNames = ds.DoubleVariables.ToArray();
   foreach (var r in selectedRows) {
     // take all values from the original dataset
     for (int c = 0; c < srcRow.Length; c++) {
       var col = sourceDs.GetReadOnlyDoubleValues(varNames[c]);
       srcRow[c] = col[r];
     }
     ds.ReplaceRow(t, srcRow);
     // but use the updated target values
     ds.SetVariableValue(curTarget[r], targetVarName, t);
     t++;
   }
 }
开发者ID:t-h-e,项目名称:HeuristicLab,代码行数:18,代码来源:GradientBoostingRegressionAlgorithm.cs

示例4: PrepareInterpreterState

 private static InterpreterState PrepareInterpreterState(ISymbolicExpressionTree tree, IDataset dataset) {
   Instruction[] code = SymbolicExpressionTreeCompiler.Compile(tree, OpCodes.MapSymbolToOpCode);
   int necessaryArgStackSize = 0;
   foreach (Instruction instr in code) {
     if (instr.opCode == OpCodes.Variable) {
       var variableTreeNode = (VariableTreeNode)instr.dynamicNode;
       instr.data = dataset.GetReadOnlyDoubleValues(variableTreeNode.VariableName);
     } else if (instr.opCode == OpCodes.LagVariable) {
       var laggedVariableTreeNode = (LaggedVariableTreeNode)instr.dynamicNode;
       instr.data = dataset.GetReadOnlyDoubleValues(laggedVariableTreeNode.VariableName);
     } else if (instr.opCode == OpCodes.VariableCondition) {
       var variableConditionTreeNode = (VariableConditionTreeNode)instr.dynamicNode;
       instr.data = dataset.GetReadOnlyDoubleValues(variableConditionTreeNode.VariableName);
     } else if (instr.opCode == OpCodes.Call) {
       necessaryArgStackSize += instr.nArguments + 1;
     }
   }
   return new InterpreterState(code, necessaryArgStackSize);
 }
开发者ID:thunder176,项目名称:HeuristicLab,代码行数:19,代码来源:SymbolicDataAnalysisExpressionTreeInterpreter.cs

示例5: GetEstimatedValues

    public override IEnumerable<double> GetEstimatedValues(IDataset ds, IEnumerable<int> rows) {
      // lookup columns for variableNames in one pass over the tree to speed up evaluation later on
      ReadOnlyCollection<double>[] columnCache = new ReadOnlyCollection<double>[tree.Length];

      for (int i = 0; i < tree.Length; i++) {
        if (tree[i].VarName != TreeNode.NO_VARIABLE) {
          // tree models also support calculating estimations if not all variables used for training are available in the dataset
          if (ds.ColumnNames.Contains(tree[i].VarName))
            columnCache[i] = ds.GetReadOnlyDoubleValues(tree[i].VarName);
        }
      }
      return rows.Select(r => GetPredictionForRow(tree, columnCache, 0, r));
    }
开发者ID:t-h-e,项目名称:HeuristicLab,代码行数:13,代码来源:RegressionTreeModel.cs

示例6: GetEstimatedValues

    public override IEnumerable<double> GetEstimatedValues(IDataset dataset, IEnumerable<int> rows) {
      var targetVariables = dataset.GetReadOnlyDoubleValues(TargetVariable);
      foreach (int row in rows) {
        double estimatedValue = 0.0;
        if (row - TimeOffset < 0) {
          yield return double.NaN;
          continue;
        }

        for (int i = 1; i <= TimeOffset; i++) {
          estimatedValue += targetVariables[row - i] * Phi[i - 1];
        }
        estimatedValue += Constant;
        yield return estimatedValue;
      }
    }
开发者ID:t-h-e,项目名称:HeuristicLab,代码行数:16,代码来源:TimeSeriesPrognosisAutoRegressiveModel.cs

示例7: GetEstimatedValues

    public IEnumerable<double> GetEstimatedValues(IDataset ds, IEnumerable<int> rows) {
      // lookup columns for variableNames in one pass over the tree to speed up evaluation later on
      ReadOnlyCollection<double>[] columnCache = new ReadOnlyCollection<double>[tree.Length];

      for (int i = 0; i < tree.Length; i++) {
        if (tree[i].VarName != TreeNode.NO_VARIABLE) {
          columnCache[i] = ds.GetReadOnlyDoubleValues(tree[i].VarName);
        }
      }
      return rows.Select(r => GetPredictionForRow(tree, columnCache, 0, r));
    }
开发者ID:thunder176,项目名称:HeuristicLab,代码行数:11,代码来源:RegressionTreeModel.cs

示例8: PrepareInstructions

 public static void PrepareInstructions(LinearInstruction[] code, IDataset dataset) {
   for (int i = 0; i != code.Length; ++i) {
     var instr = code[i];
     #region opcode switch
     switch (instr.opCode) {
       case OpCodes.Constant: {
           var constTreeNode = (ConstantTreeNode)instr.dynamicNode;
           instr.value = constTreeNode.Value;
           instr.skip = true; // the value is already set so this instruction should be skipped in the evaluation phase
         }
         break;
       case OpCodes.Variable: {
           var variableTreeNode = (VariableTreeNode)instr.dynamicNode;
           instr.data = dataset.GetReadOnlyDoubleValues(variableTreeNode.VariableName);
         }
         break;
       case OpCodes.LagVariable: {
           var laggedVariableTreeNode = (LaggedVariableTreeNode)instr.dynamicNode;
           instr.data = dataset.GetReadOnlyDoubleValues(laggedVariableTreeNode.VariableName);
         }
         break;
       case OpCodes.VariableCondition: {
           var variableConditionTreeNode = (VariableConditionTreeNode)instr.dynamicNode;
           instr.data = dataset.GetReadOnlyDoubleValues(variableConditionTreeNode.VariableName);
         }
         break;
       case OpCodes.TimeLag:
       case OpCodes.Integral:
       case OpCodes.Derivative: {
           var seq = GetPrefixSequence(code, i);
           var interpreterState = new InterpreterState(seq, 0);
           instr.data = interpreterState;
           for (int j = 1; j != seq.Length; ++j)
             seq[j].skip = true;
         }
         break;
     }
     #endregion
   }
 }
开发者ID:thunder176,项目名称:HeuristicLab,代码行数:40,代码来源:SymbolicDataAnalysisExpressionTreeLinearInterpreter.cs


注:本文中的IDataset.GetReadOnlyDoubleValues方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。