예제 #1
0
    def runTest(self):

        for model in ['EvenOdd', 'FOL', 'Magnetism.Simple', 'Magnetism.Complex',
                      'NAND', 'Number', 'RegularExpression', 'RationalRules',
                      'StochasticGrammarInduction', 'SymbolicRegression.Galileo',
                      'SymbolicRegression.Symbolic', 'Prolog', 'PureLambda', 'Lua']:
            print "# Testing loading of example", model

            make_hypothesis, make_data = load_example(model)

            d  = make_data()
            d  = make_data(10) # require an amount

            # Let's just try initializing a bunch of times
            for _ in xrange(100):
                h0 = make_hypothesis()

            # and ensure that the samplign will run
            for _ in MHSampler(h0, d, steps=100):
                pass
예제 #2
0
    def runTest(self):

        for model in [
                'EvenOdd', 'FOL', 'Magnetism.Simple', 'Magnetism.Complex',
                'NAND', 'Number', 'RegularExpression', 'RationalRules',
                'StochasticGrammarInduction', 'SymbolicRegression.Galileo',
                'SymbolicRegression.Symbolic', 'Prolog', 'PureLambda', 'Lua'
        ]:
            print "# Testing loading of example", model

            make_hypothesis, make_data = load_example(model)

            d = make_data()
            d = make_data(10)  # require an amount

            # Let's just try initializing a bunch of times
            for _ in xrange(100):
                h0 = make_hypothesis()

            # and ensure that the samplign will run
            for _ in MHSampler(h0, d, steps=100):
                pass
예제 #3
0
파일: Demo.py 프로젝트: flrgsr/LOTlib
        default="None",
        help=
        "A function of a hypothesis we can also print at the start of a line to see things we "
        "want. E.g. --alsoprint='lambda h: h.get_knower_pattern()' ")
    (options, args) = parser.parse_args()

    from LOTlib.Miscellaneous import display_option_summary

    display_option_summary(options)

    # ========================================================================================================
    # Load the model specified on the command line
    # ========================================================================================================

    from LOTlib.Examples import load_example

    make_hypothesis, make_data = load_example(options.MODEL)

    # ========================================================================================================
    #  Run the example's standard sampler with these parameters
    # ========================================================================================================

    from LOTlib.Inference.Samplers.StandardSample import standard_sample

    # This is just a wrapper that nicely prints information
    standard_sample(make_hypothesis,
                    make_data,
                    alsoprint=options.ALSO_PRINT,
                    steps=options.STEPS,
                    skip=options.SKIP)
예제 #4
0
파일: Demo.py 프로젝트: joshrule/LOTlib
    parser.add_option("--model", dest="MODEL", type="string", default="Number",
                      help="Which model do we run? (e.g. 'Number', 'Magnetism.Simple', etc.")
    parser.add_option("--steps", dest="STEPS", type="int", default=Infinity, help="Draw this many samples")
    parser.add_option("--skip", dest="SKIP", type="int", default=0, help="Skip this many steps between samples")
    parser.add_option("--alsoprint", dest="ALSO_PRINT", type="string", default="None",
                      help="A function of a hypothesis we can also print at the start of a line to see things we "
                           "want. E.g. --alsoprint='lambda h: h.get_knower_pattern()' ")
    (options, args) = parser.parse_args()

    from LOTlib.Miscellaneous import display_option_summary

    display_option_summary(options)

    # ========================================================================================================
    # Load the model specified on the command line
    # ========================================================================================================

    from LOTlib.Examples import load_example

    make_hypothesis, make_data = load_example(options.MODEL)

    # ========================================================================================================
    #  Run the example's standard sampler with these parameters
    # ========================================================================================================

    from LOTlib.Inference.Samplers.StandardSample import standard_sample

    # This is just a wrapper that nicely prints information
    standard_sample(make_hypothesis, make_data, alsoprint=options.ALSO_PRINT, steps=options.STEPS, skip=options.SKIP)