Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/20/13 14:08:49 (12 years ago)
Author:
sluengo
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/sluengo/HeuristicLab.Problems.TradeRules/Solution/TradeRulesSolutionBase.cs

    r9262 r9386  
    2929        private const string TrainingMeanErrorResultName = "Mean error (training)";
    3030        private const string TestMeanErrorResultName = "Mean error (test)";
     31        private const string TestTradeDaysResultName = "Trade days";
     32        private const string TestNumberTradesResultName = "Number of trades";
     33        private const string TestTotalTradesResultName = "Total trades";
     34
    3135
    3236        public new IRegressionModel Model
     
    5862            get { return ((DoubleValue)this[TestCashResultName].Value).Value; }
    5963            private set { ((DoubleValue)this[TestCashResultName].Value).Value = value; }
     64        }
     65        public double TradeDays
     66        {
     67            get { return ((DoubleValue)this[TestTradeDaysResultName].Value).Value; }
     68            private set { ((DoubleValue)this[TestTradeDaysResultName].Value).Value = value; }
     69        }
     70        public double NumberTrades
     71        {
     72            get { return ((DoubleValue)this[TestNumberTradesResultName].Value).Value; }
     73            private set { ((DoubleValue)this[TestNumberTradesResultName].Value).Value = value; }
     74        }
     75        public double TotalTrades
     76        {
     77            get { return ((DoubleValue)this[TestTotalTradesResultName].Value).Value; }
     78            private set { ((DoubleValue)this[TestTotalTradesResultName].Value).Value = value; }
    6079        }
    6180        public double TrainingMeanSquaredError
     
    129148    protected TradeRulesSolutionBase(IRegressionModel model, IRegressionProblemData problemData)
    130149      : base(model, problemData) {
    131           Add(new Result(TrainingCashResultName, "Cash obtained after training period in the stock market", new DoubleValue()));
     150      Add(new Result(TrainingCashResultName, "Cash obtained after training period in the stock market", new DoubleValue()));
    132151      Add(new Result(TestCashResultName, "Cash obtained after test period in the stock market", new DoubleValue()));
    133       Add(new Result(TrainingMeanSquaredErrorResultName, "Mean of squared errors of the model on the training partition", new DoubleValue()));
    134       Add(new Result(TestMeanSquaredErrorResultName, "Mean of squared errors of the model on the test partition", new DoubleValue()));
    135       Add(new Result(TrainingMeanAbsoluteErrorResultName, "Mean of absolute errors of the model on the training partition", new DoubleValue()));
    136       Add(new Result(TestMeanAbsoluteErrorResultName, "Mean of absolute errors of the model on the test partition", new DoubleValue()));
    137       Add(new Result(TrainingSquaredCorrelationResultName, "Squared Pearson's correlation coefficient of the model output and the actual values on the training partition", new DoubleValue()));
    138       Add(new Result(TestSquaredCorrelationResultName, "Squared Pearson's correlation coefficient of the model output and the actual values on the test partition", new DoubleValue()));
    139       Add(new Result(TrainingRelativeErrorResultName, "Average of the relative errors of the model output and the actual values on the training partition", new PercentValue()));
    140       Add(new Result(TestRelativeErrorResultName, "Average of the relative errors of the model output and the actual values on the test partition", new PercentValue()));
    141       Add(new Result(TrainingNormalizedMeanSquaredErrorResultName, "Normalized mean of squared errors of the model on the training partition", new DoubleValue()));
    142       Add(new Result(TestNormalizedMeanSquaredErrorResultName, "Normalized mean of squared errors of the model on the test partition", new DoubleValue()));
    143       Add(new Result(TrainingMeanErrorResultName, "Mean of errors of the model on the training partition", new DoubleValue()));
    144       Add(new Result(TestMeanErrorResultName, "Mean of errors of the model on the test partition", new DoubleValue()));
    145     }
     152      Add(new Result(TestTradeDaysResultName, "Number of trading days", new DoubleValue()));
     153      Add(new Result(TestNumberTradesResultName, "Number of trades", new DoubleValue()));
     154      Add(new Result(TestTotalTradesResultName, "Total trades", new DoubleValue()));
     155     }
    146156
    147157    [StorableHook(HookType.AfterDeserialization)]
     
    194204        IEnumerable<double> originalTestValues = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TestIndices);
    195205
    196         OnlineCalculatorError errorState;
    197         double trainingMSE = OnlineMeanSquaredErrorCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);
    198         TrainingMeanSquaredError = errorState == OnlineCalculatorError.None ? trainingMSE : double.NaN;
    199         double testMSE = OnlineMeanSquaredErrorCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);
    200         TestMeanSquaredError = errorState == OnlineCalculatorError.None ? testMSE : double.NaN;
    201 
    202         double trainingMAE = OnlineMeanAbsoluteErrorCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);
    203         TrainingMeanAbsoluteError = errorState == OnlineCalculatorError.None ? trainingMAE : double.NaN;
    204         double testMAE = OnlineMeanAbsoluteErrorCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);
    205         TestMeanAbsoluteError = errorState == OnlineCalculatorError.None ? testMAE : double.NaN;
    206 
    207         double trainingR2 = OnlinePearsonsRSquaredCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);
    208         TrainingRSquared = errorState == OnlineCalculatorError.None ? trainingR2 : double.NaN;
    209         double testR2 = OnlinePearsonsRSquaredCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);
    210         TestRSquared = errorState == OnlineCalculatorError.None ? testR2 : double.NaN;
    211 
    212         double trainingRelError = OnlineMeanAbsolutePercentageErrorCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);
    213         TrainingRelativeError = errorState == OnlineCalculatorError.None ? trainingRelError : double.NaN;
    214         double testRelError = OnlineMeanAbsolutePercentageErrorCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);
    215         TestRelativeError = errorState == OnlineCalculatorError.None ? testRelError : double.NaN;
    216 
    217         double trainingNMSE = OnlineNormalizedMeanSquaredErrorCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);
    218         TrainingNormalizedMeanSquaredError = errorState == OnlineCalculatorError.None ? trainingNMSE : double.NaN;
    219         double testNMSE = OnlineNormalizedMeanSquaredErrorCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);
    220         TestNormalizedMeanSquaredError = errorState == OnlineCalculatorError.None ? testNMSE : double.NaN;
    221 
    222         double trainingME = OnlineMeanErrorCalculator.Calculate(originalTrainingValues, estimatedTrainingValues, out errorState);
    223         TrainingMeanError = errorState == OnlineCalculatorError.None ? trainingME : double.NaN;
    224         double testME = OnlineMeanErrorCalculator.Calculate(originalTestValues, estimatedTestValues, out errorState);
    225         TestMeanError = errorState == OnlineCalculatorError.None ? testME : double.NaN;
    226 
    227206        double trainingCTR = OnlineTradeRulesCalculator.Calculate(estimatedTrainingValues, ProblemData, ProblemData.TrainingIndices);
    228207        TrainingCash = trainingCTR;
    229208        double testCTR = OnlineTradeRulesCalculator.Calculate(estimatedTestValues, ProblemData, ProblemData.TestIndices);
    230209        TestCash = testCTR;
     210        double testTradeDays = OnlineTradeRulesCalculator.getTradeDays();
     211        TradeDays = testTradeDays;
     212        double testNumberTrades = OnlineTradeRulesCalculator.getNumberTrades();
     213        NumberTrades = testNumberTrades;
     214        double testTotalTradeDays = OnlineTradeRulesCalculator.getTotalTradesDays();
     215        TotalTrades = testTotalTradeDays;
     216
    231217    }
    232218
Note: See TracChangeset for help on using the changeset viewer.