PROBLEM SymbReg CODE << double[,] inputValues; double[] targetValues; string[] variableNames; Dictionary nameToCol; double GetValue(double[,] data, string varName, int row) { if(nameToCol == null) { /* init mapping */ nameToCol = new Dictionary(); for(int i=0; i xs, IEnumerable ys) { HeuristicLab.Problems.DataAnalysis.OnlineCalculatorError error; var r2 = HeuristicLab.Problems.DataAnalysis.OnlinePearsonsRSquaredCalculator.Calculate(xs, ys, out error); if(error == HeuristicLab.Problems.DataAnalysis.OnlineCalculatorError.None) return r2; else return 0.0; } void LoadData(string fileName, out double[,] inputValues, out string[] variableNames, out double[] target) { var prov = new HeuristicLab.Problems.Instances.DataAnalysis.RegressionRealWorldInstanceProvider(); var dd = prov.GetDataDescriptors().OfType().Single(); var problemData = prov.LoadData(dd); inputValues = new double[problemData.TrainingIndices.Count(), problemData.AllowedInputVariables.Count()]; foreach(var r in problemData.TrainingIndices) { int i=0; foreach(var v in problemData.AllowedInputVariables) { inputValues[r, i++] = problemData.Dataset.GetDoubleValue(v, r); } } variableNames = problemData.AllowedInputVariables.ToArray(); target = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, problemData.TrainingIndices).ToArray(); } >> INIT << LoadData("filename.csv", out inputValues, out variableNames, out targetValues); >> NONTERMINALS Model<>. RPB<>. Addition<>. Subtraction<>. Multiplication<>. Division<>. TERMINALS Const<> CONSTRAINTS val IN RANGE <<-100>> .. <<100>> . Var<> CONSTRAINTS varName IN SET <> weight IN RANGE <<-100>> .. <<100>> . RULES Model<> = RPB<> . RPB<> = LOCAL << string varName; double w; >> Addition<> | Subtraction<> | Division<> | Multiplication<> | Var<> SEM << val = w * GetValue(inputValues, varName, row); >> | Const<> . Addition<> = LOCAL << double x1, x2; >> RPB<> RPB<> SEM << val = x1 + x2; >> . Subtraction<> = LOCAL << double x1, x2; >> RPB<> RPB<> SEM << val = x1 - x2; >> . Division<> = LOCAL << double x1, x2; >> RPB<> RPB<> SEM << val = x1 / x2; >> . Multiplication<> = LOCAL << double x1, x2; >> RPB<> RPB<> SEM << val = x1 * x2; >> . MAXIMIZE /* could also use the keyword MINIMIZE here */ << var rows = System.Linq.Enumerable.Range(0, inputValues.GetLength(0)); var predicted = rows.Select(r => { double result; Model(r, out result); /* we can call the root symbol directly */ return result; }); return RSquared(predicted, targetValues); >> END SymbReg.