protected DataAnalysisProblemData(IDataset dataset, IEnumerable <string> allowedInputVariables, IEnumerable <ITransformation> transformations = null)
        {
            if (dataset == null)
            {
                throw new ArgumentNullException("The dataset must not be null.");
            }
            if (allowedInputVariables == null)
            {
                throw new ArgumentNullException("The allowed input variables must not be null.");
            }

            if (allowedInputVariables.Except(dataset.DoubleVariables).Except(dataset.StringVariables).Any())
            {
                throw new ArgumentException("All allowed input variables must be present in the dataset and of type double or string.");
            }

            var variables      = dataset.VariableNames.Where(variable => dataset.VariableHasType <double>(variable) || dataset.VariableHasType <string>(variable));
            var inputVariables = new CheckedItemList <StringValue>(variables.Select(x => new StringValue(x).AsReadOnly()));

            foreach (StringValue x in inputVariables)
            {
                inputVariables.SetItemCheckedState(x, allowedInputVariables.Contains(x.Value));
            }

            int trainingPartitionStart = 0;
            int trainingPartitionEnd   = dataset.Rows / 2;
            int testPartitionStart     = dataset.Rows / 2;
            int testPartitionEnd       = dataset.Rows;

            var transformationsList = new ItemList <ITransformation>(transformations ?? Enumerable.Empty <ITransformation>());

            Parameters.Add(new FixedValueParameter <Dataset>(DatasetParameterName, "", (Dataset)dataset));
            Parameters.Add(new FixedValueParameter <ReadOnlyCheckedItemList <StringValue> >(InputVariablesParameterName, "", inputVariables.AsReadOnly()));
            Parameters.Add(new FixedValueParameter <IntRange>(TrainingPartitionParameterName, "", new IntRange(trainingPartitionStart, trainingPartitionEnd)));
            Parameters.Add(new FixedValueParameter <IntRange>(TestPartitionParameterName, "", new IntRange(testPartitionStart, testPartitionEnd)));
            Parameters.Add(new FixedValueParameter <ReadOnlyItemList <ITransformation> >(TransformationsParameterName, "", transformationsList.AsReadOnly()));

            TransformationsParameter.Hidden = true;

            ((ValueParameter <Dataset>)DatasetParameter).ReactOnValueToStringChangedAndValueItemImageChanged = false;
            RegisterEventHandlers();
        }
Exemple #2
0
        private void symbol_Changed(object sender, EventArgs e)
        {
            ISymbol symbol = (ISymbol)sender;

            symbols.SetItemCheckedState(symbol, symbol.Enabled);
        }
    protected DataAnalysisProblemData(IDataset dataset, IEnumerable<string> allowedInputVariables, IEnumerable<ITransformation> transformations = null) {
      if (dataset == null) throw new ArgumentNullException("The dataset must not be null.");
      if (allowedInputVariables == null) throw new ArgumentNullException("The allowedInputVariables must not be null.");

      if (allowedInputVariables.Except(dataset.DoubleVariables).Any())
        throw new ArgumentException("All allowed input variables must be present in the dataset and of type double.");

      var inputVariables = new CheckedItemList<StringValue>(dataset.DoubleVariables.Select(x => new StringValue(x)));
      foreach (StringValue x in inputVariables)
        inputVariables.SetItemCheckedState(x, allowedInputVariables.Contains(x.Value));

      int trainingPartitionStart = 0;
      int trainingPartitionEnd = dataset.Rows / 2;
      int testPartitionStart = dataset.Rows / 2;
      int testPartitionEnd = dataset.Rows;

      var transformationsList = new ItemList<ITransformation>(transformations ?? Enumerable.Empty<ITransformation>());

      Parameters.Add(new FixedValueParameter<Dataset>(DatasetParameterName, "", (Dataset)dataset));
      Parameters.Add(new FixedValueParameter<ReadOnlyCheckedItemList<StringValue>>(InputVariablesParameterName, "", inputVariables.AsReadOnly()));
      Parameters.Add(new FixedValueParameter<IntRange>(TrainingPartitionParameterName, "", new IntRange(trainingPartitionStart, trainingPartitionEnd)));
      Parameters.Add(new FixedValueParameter<IntRange>(TestPartitionParameterName, "", new IntRange(testPartitionStart, testPartitionEnd)));
      Parameters.Add(new FixedValueParameter<ReadOnlyItemList<ITransformation>>(TransformationsParameterName, "", transformationsList.AsReadOnly()));

      TransformationsParameter.Hidden = true;

      ((ValueParameter<Dataset>)DatasetParameter).ReactOnValueToStringChangedAndValueItemImageChanged = false;
      RegisterEventHandlers();
    }