예제 #1
0
def getBestLsumOfFunctionsPredictorTEST1(plot: False):
    (HEADERS, DF, HEADER_X, HEADER_Y,
     HEADER_WEIGHT) = utilsTest.testFromFile1()
    myLsumOfFunctionsPredictor = modStats.mktPredictor.predictorFactory(
        modStats.TYPE_LSUM_OF_FUNCTIONS,
        DF,
        HEADER_X,
        HEADER_Y,
        HEADER_WEIGHT,
        utils.HEADER_MARKET,
        utils.HEADER_STOCK,
        displayCharts=plot)
    estimate = myLsumOfFunctionsPredictor.estimate(utilsTest.forPrediction1(),
                                                   HEADER_X, HEADER_Y)
    return (
        np.array_equal(np.around(estimate, 6), [0.023071, 0.022401])
        and (round(myLsumOfFunctionsPredictor.getAvgCoeffDetermin(), 6)
             == 0.943534)
        and np.array_equal(
            [f.__name__ for f in myLsumOfFunctionsPredictor.getXFunctions()], [
                'log', 'digit90Percent', 'log', 'digit80Percent',
                'digit90Percent', 'log', 'log', 'identity', 'identity',
                'digit90Percent', 'log'
            ]),
        'LsumOfFunctionsPredictor returns unexpected Value for prediction 1 from file 1'
    )
예제 #2
0
def getBestLsumOfFunctionsPredictorTEST3(plot: False):
    (HEADERS, DF, HEADER_X, HEADER_Y,
     HEADER_WEIGHT) = utilsTest.testFromFile1()
    utils.Constants().incrementalFunctionFit = True
    myLsumOfFunctionsPredictor = modStats.mktPredictor.predictorFactory(
        modStats.TYPE_LSUM_OF_FUNCTIONS,
        DF,
        HEADER_X,
        HEADER_Y,
        HEADER_WEIGHT,
        utils.HEADER_MARKET,
        utils.HEADER_STOCK,
        displayCharts=plot)
    estimate = myLsumOfFunctionsPredictor.estimate(utilsTest.forPrediction1(),
                                                   HEADER_X, HEADER_Y)
    return (
        np.array_equal(np.around(estimate, 6), [-0.085291, -0.900866])
        and (round(myLsumOfFunctionsPredictor.getAvgCoeffDetermin(), 6)
             == 0.945467)
        and np.array_equal(
            [f.__name__ for f in myLsumOfFunctionsPredictor.getXFunctions()], [
                'log', 'identity', 'identity', 'digit80PercentOfAddRatio',
                'digit90Percent', 'logOfMultRatio', 'identity', 'identity',
                'identity', 'digit90Percent', 'log'
            ]),
        'LsumOfFunctionsPredictor returns unexpected Value for prediction 1 from file 1 when functions are searched incrementally'
    )
예제 #3
0
def getLsumOfFunctionsPerStockPredictorTEST0(plot: False):
    (HEADERS, DF, HEADER_X, HEADER_Y,
     HEADER_WEIGHT) = utilsTest.testFromFile726()
    myLsumOfFunctionsPerStockPredictor = modStats.mktPredictor.predictorFactory(
        modStats.TYPE_LSUM_OF_FUNCTIONS_PER_STCK, DF, HEADER_X, HEADER_Y,
        HEADER_WEIGHT, utils.HEADER_MARKET, utils.HEADER_STOCK)
    estimate = myLsumOfFunctionsPerStockPredictor.estimate(
        utilsTest.forPrediction1(), HEADER_X, HEADER_Y)
    return (np.array_equal(np.around(estimate, 6), [2.530599, 3.0229]) and (
        round(myLsumOfFunctionsPerStockPredictor.getAvgCoeffDetermin(),
              6) == 0.932669
    ), 'LinearPerStockPredictor returns unexpected Value for prediction 1 from file 726'
            )
예제 #4
0
def getLsumOfFunctionsPerStockPredictorTEST1(plot: False):
    (HEADERS, DF, HEADER_X, HEADER_Y,
     HEADER_WEIGHT) = utilsTest.testFromFile726()
    utils.Constants().incrementalFunctionFit = True
    myLsumOfFunctionsPerStockPredictor = modStats.mktPredictor.predictorFactory(
        modStats.TYPE_LSUM_OF_FUNCTIONS_PER_STCK, DF, HEADER_X, HEADER_Y,
        HEADER_WEIGHT, utils.HEADER_MARKET, utils.HEADER_STOCK)
    estimate = myLsumOfFunctionsPerStockPredictor.estimate(
        utilsTest.forPrediction1(), HEADER_X, HEADER_Y)
    return (
        np.array_equal(np.around(estimate, 6), [-0.100358, -0.008756])
        and (round(myLsumOfFunctionsPerStockPredictor.getAvgCoeffDetermin(), 6)
             == 0.937514),
        'LinearPerStockPredictor returns unexpected Value for prediction 1 from file 726'
    )
예제 #5
0
def getLinearPerStockPredictorTEST0(plot: False):
    utils.Constants().fractionFullSampleForTest = 0.2
    (HEADERS, DF, HEADER_X, HEADER_Y,
     HEADER_WEIGHT) = utilsTest.testFromFile726()
    myLinearPerStockPredictor = modStats.mktPredictor.predictorFactory(
        modStats.TYPE_LINEAR_PER_STCK, DF, HEADER_X, HEADER_Y, HEADER_WEIGHT,
        utils.HEADER_MARKET, utils.HEADER_STOCK)
    estimate = myLinearPerStockPredictor.estimate(utilsTest.forPrediction1(),
                                                  HEADER_X, HEADER_Y)
    return (np.array_equal(np.around(estimate, 6), [
        -0.850607, -1.915488
    ]) and (
        round(myLinearPerStockPredictor.getAvgCoeffDetermin(), 6) == 0.847778
    ), 'LinearPerStockPredictor returns unexpected Value for prediction 1 from file 726'
            )
예제 #6
0
def getAccurateLinearPredictorTEST1(plot: False):
    (HEADERS, DF, HEADER_X, HEADER_Y,
     HEADER_WEIGHT) = utilsTest.testFromFile1()
    myLinearPredictor = modStats.mktPredictor.predictorFactory(
        modStats.TYPE_LINEAR,
        DF,
        HEADER_X,
        HEADER_Y,
        HEADER_WEIGHT,
        utils.HEADER_MARKET,
        utils.HEADER_STOCK,
        displayCharts=plot)
    estimate = myLinearPredictor.estimate(utilsTest.forPrediction1(), HEADER_X,
                                          HEADER_Y)
    return (
        np.array_equal(np.around(estimate, 6), [-0.823778, -1.519227])
        and (round(myLinearPredictor.getAvgCoeffDetermin(), 6) == 0.941377)
        and (myLinearPredictor.getk() == 6),
        'LinearPredictor returns unexpected Value for prediction 1 from file 1'
    )