def test_mlp(self):
        if not cfg.ENABLE_PREDICT:
            return

        # Fix: need to come up with a better way of doing this
        try:
            # Fix: need to move loading of ticker data into a df somewhere
            mlp([], "TLSA", None)
        except NameError as e:
            print("One of the optional packages seems to be missing")
            print(e)
            print("Skipping the test")
Пример #2
0
def pred_menu(df_stock, s_ticker, s_start, s_interval):

    # Add list of arguments that the prediction techniques parser accepts
    pred_parser = argparse.ArgumentParser(prog="pred", add_help=False)
    choices = [
        "help",
        "q",
        "quit",
        "sma",
        "ets",
        "knn",
        "linear",
        "quadratic",
        "cubic",
        "regression",
        "arima",
        "prophet",
        "mlp",
        "rnn",
        "lstm",
    ]
    pred_parser.add_argument("cmd", choices=choices)
    completer = NestedCompleter.from_nested_dict({c: None for c in choices})

    print_prediction(s_ticker, s_start, s_interval)

    # Loop forever and ever
    while True:
        # Get input command from user
        if session and gtff.USE_PROMPT_TOOLKIT:
            as_input = session.prompt(
                f"{get_flair()} (pred)> ",
                completer=completer,
            )
        else:
            as_input = input(f"{get_flair()} (pred)> ")

        # Images are non blocking - allows to close them if we type other command
        plt.close("all")

        # Parse prediction techniques command of the list of possible commands
        try:
            (ns_known_args, l_args) = pred_parser.parse_known_args(as_input.split())

        except SystemExit:
            print("The command selected doesn't exist\n")
            continue

        if ns_known_args.cmd == "help":
            print_prediction(s_ticker, s_start, s_interval)

        elif ns_known_args.cmd == "q":
            # Just leave the FA menu
            return False

        elif ns_known_args.cmd == "quit":
            # Abandon the program
            return True

        elif ns_known_args.cmd == "sma":
            sma.simple_moving_average(l_args, s_ticker, df_stock)

        elif ns_known_args.cmd == "ets":
            ets.exponential_smoothing(l_args, s_ticker, df_stock)

        elif ns_known_args.cmd == "knn":
            knn.k_nearest_neighbors(l_args, s_ticker, df_stock)

        elif ns_known_args.cmd == "linear":
            regression.regression(l_args, s_ticker, df_stock, regression.LINEAR)

        elif ns_known_args.cmd == "quadratic":
            regression.regression(l_args, s_ticker, df_stock, regression.QUADRATIC)

        elif ns_known_args.cmd == "cubic":
            regression.regression(l_args, s_ticker, df_stock, regression.CUBIC)

        elif ns_known_args.cmd == "regression":
            regression.regression(l_args, s_ticker, df_stock, regression.USER_INPUT)

        elif ns_known_args.cmd == "arima":
            arima.arima(l_args, s_ticker, df_stock)

        elif ns_known_args.cmd == "prophet":
            fbprophet.fbprophet(l_args, s_ticker, df_stock)

        elif ns_known_args.cmd == "mlp":
            neural_networks.mlp(l_args, s_ticker, df_stock)

        elif ns_known_args.cmd == "rnn":
            neural_networks.rnn(l_args, s_ticker, df_stock)

        elif ns_known_args.cmd == "lstm":
            neural_networks.lstm(l_args, s_ticker, df_stock)

        else:
            print("Command not recognized!")
Пример #3
0
 def call_mlp(self, other_args: List[str]):
     """Process mlp command"""
     neural_networks.mlp(other_args, self.ticker, self.stock)