def __init__(self, arg_str):
     ProbabilisticInterleave.__init__(self, arg_str)
     # parse arguments
     parser = argparse.ArgumentParser(
         description="Initialize probabilistic"
         " interleave with history.",
         prog="ProbabilisticInterleaveWithHistory")
     parser.add_argument(
         "-l",
         "--history_length",
         type=int,
         required=True,
         help="Number of historical data points to keep in memory and use "
         "to infer feedback.")
     parser.add_argument(
         "-b",
         "--biased",
         default=False,
         help="Set to true if comparison should be biased (i.e., not use"
         "importance sampling).")
     if not arg_str:
         raise (Exception("Comparison arguments missing. " +
                          parser.format_usage()))
     args = vars(parser.parse_args(split_arg_str(arg_str)))
     self.history_length = args["history_length"]
     self.biased = string_to_boolean(args["biased"])
     logging.info("Initialized historical data usage to: %r" % self.biased)
     # initialize history
     self.history = []
    def __init__(self, feature_count, arg_str):
        """
        @param featur_count: the number of features
        @param arg_str: "-h HISTORY_LENGTH -e NUM_CANDIDATES \
            -s SELECT_CANDIDATE".
        """
        ListwiseLearningSystem.__init__(self, feature_count, arg_str)

        parser = argparse.ArgumentParser(prog=self.__class__.__name__)
        parser.add_argument("-e", "--num_candidates", required=True, type=int,
            help="Number of candidate rankers to explore in each round.")
        parser.add_argument("-l", "--history_length", required=True, type=int,
            help="Number of historic data points to take into account when "
            "pre-selecting candidates.")
        parser.add_argument("-s", "--select_candidate", required=True,
            help="Method for selecting a candidate ranker from a ranker pool."
            " Options: select_candidate_random, select_candidate_simple,"
            " select_candidate_repeated, or own implementation.")
        parser.add_argument("-b", "--biased", default="False",
            help="Set to true if comparison should be biased (i.e., not use"
            "importance sampling).")
        parser.add_argument("-r", "--num_repetitions", type=int, default=1,
            help="The number of repetitions for each ranker pair evaluation"
            "(when the selection method is select_candidate_repeated).")
        args = vars(parser.parse_known_args(split_arg_str(arg_str))[0])

        self.num_candidates = args["num_candidates"]
        self.select_candidate = getattr(self, args["select_candidate"])
        self.history_length = args["history_length"]
        self.biased = string_to_boolean(args["biased"])
        logging.info("Initialized historical data usage to: %r" % self.biased)
        self.num_repetitions = args["num_repetitions"]
        self.history = []
 def __init__(self, arg_str):
     ProbabilisticInterleave.__init__(self, arg_str)
     # parse arguments
     parser = argparse.ArgumentParser(
         description="Initialize probabilistic" " interleave with history.",
         prog="ProbabilisticInterleaveWithHistory",
     )
     parser.add_argument(
         "-l",
         "--history_length",
         type=int,
         required=True,
         help="Number of historical data points to keep in memory and use " "to infer feedback.",
     )
     parser.add_argument(
         "-b",
         "--biased",
         default=False,
         help="Set to true if comparison should be biased (i.e., not use" "importance sampling).",
     )
     if not arg_str:
         raise (Exception("Comparison arguments missing. " + parser.format_usage()))
     args = vars(parser.parse_args(split_arg_str(arg_str)))
     self.history_length = args["history_length"]
     self.biased = string_to_boolean(args["biased"])
     logging.info("Initialized historical data usage to: %r" % self.biased)
     # initialize history
     self.history = []
    def __init__(self, arg_str=None):
        self.pi = ProbabilisticInterleave(arg_str)
        if arg_str:
            parser = argparse.ArgumentParser(description="Parse arguments for "
                                             "interleaving method.",
                                             prog=self.__class__.__name__)
            parser.add_argument("-a",
                                "--aggregate",
                                choices=[
                                    "expectation", "log-likelihood-ratio",
                                    "likelihood-ratio", "log-ratio", "binary"
                                ],
                                default="expectation")
            parser.add_argument("-e",
                                "--exploration_rate",
                                type=float,
                                required=True,
                                help="Exploration rate, 0.5 = perfect "
                                "exploration, 0.0 = perfect exploitation.")
            parser.add_argument("-b", "--biased", default="False")

            args = vars(parser.parse_known_args(split_arg_str(arg_str))[0])
            self.exploration_rate = args["exploration_rate"]
            self.aggregate = args["aggregate"]

            self.biased = string_to_boolean(args["biased"])
        else:
            raise ValueError("Configuration arguments required. Please provide"
                             " at least a value for the exploration rate.")
    def __init__(self, feature_count, arg_str):
        """
        @param featur_count: the number of features
        @param arg_str: "-h HISTORY_LENGTH -e NUM_CANDIDATES \
            -s SELECT_CANDIDATE".
        """
        ListwiseLearningSystem.__init__(self, feature_count, arg_str)

        parser = argparse.ArgumentParser(prog=self.__class__.__name__)
        parser.add_argument(
            "-e",
            "--num_candidates",
            required=True,
            type=int,
            help="Number of candidate rankers to explore in each round.")
        parser.add_argument(
            "-l",
            "--history_length",
            required=True,
            type=int,
            help="Number of historic data points to take into account when "
            "pre-selecting candidates.")
        parser.add_argument(
            "-s",
            "--select_candidate",
            required=True,
            help="Method for selecting a candidate ranker from a ranker pool."
            " Options: select_candidate_random, select_candidate_simple,"
            " select_candidate_repeated, or own implementation.")
        parser.add_argument(
            "-b",
            "--biased",
            default="False",
            help="Set to true if comparison should be biased (i.e., not use"
            "importance sampling).")
        parser.add_argument(
            "-r",
            "--num_repetitions",
            type=int,
            default=1,
            help="The number of repetitions for each ranker pair evaluation"
            "(when the selection method is select_candidate_repeated).")
        args = vars(parser.parse_known_args(split_arg_str(arg_str))[0])

        self.num_candidates = args["num_candidates"]
        self.select_candidate = getattr(self, args["select_candidate"])
        self.history_length = args["history_length"]
        self.biased = string_to_boolean(args["biased"])
        logging.info("Initialized historical data usage to: %r" % self.biased)
        self.num_repetitions = args["num_repetitions"]
        self.history = []
    def __init__(self, arg_str=None):
        self.pi = ProbabilisticInterleave(arg_str)
        if arg_str:
            parser = argparse.ArgumentParser(description="Parse arguments for "
                "interleaving method.", prog=self.__class__.__name__)
            parser.add_argument("-a", "--aggregate", choices=["expectation",
                "log-likelihood-ratio", "likelihood-ratio", "log-ratio",
                "binary"], default="expectation")
            parser.add_argument("-e", "--exploration_rate", type=float,
                required=True, help="Exploration rate, 0.5 = perfect "
                "exploration, 0.0 = perfect exploitation.")
            parser.add_argument("-b", "--biased", default="False")

            args = vars(parser.parse_known_args(split_arg_str(arg_str))[0])
            self.exploration_rate = args["exploration_rate"]
            self.aggregate = args["aggregate"]

            self.biased = string_to_boolean(args["biased"])
        else:
            raise ValueError("Configuration arguments required. Please provide"
                " at least a value for the exploration rate.")
Esempio n. 7
0
import os

from flask import Flask, send_from_directory
from flask_restful import Api
from flask_cors import CORS

from db import redis_client
from utils import string_to_boolean
from resources.test_resource import TestResource
from resources.tags_resource import TagsResource

app = Flask(__name__, static_folder="front/build/")
if string_to_boolean(os.environ['DEV']):
    CORS(app)
api = Api(app)

# Environment variables
debug_mode = string_to_boolean(os.environ['DEV'])


@app.route("/", defaults={"path": ""})
@app.route("/<path:path>")
def serve_react(path):
    if path != "" and os.path.exists(app.static_folder + "/" + path):
        return send_from_directory(app.static_folder, path)
    else:
        return send_from_directory(app.static_folder, "index.html")


api.add_resource(TestResource, "/api/test")
api.add_resource(TagsResource, "/api/tags/<server_id>")