Ejemplo n.º 1
0
    def call_mlp(self, other_args: List[str]):
        """Process mlp command"""
        try:
            ns_parser = pred_helper.parse_args(
                prog="mlp",
                description="""Multi-Layered-Perceptron. """,
                other_args=other_args,
            )
            if ns_parser:
                neural_networks_view.display_mlp(
                    dataset=self.coin,
                    data=self.data[self.target],
                    n_input_days=ns_parser.n_inputs,
                    n_predict_days=ns_parser.n_days,
                    learning_rate=ns_parser.lr,
                    epochs=ns_parser.n_epochs,
                    batch_size=ns_parser.n_batch_size,
                    test_size=ns_parser.valid_split,
                    n_loops=ns_parser.n_loops,
                    no_shuffle=ns_parser.no_shuffle,
                    time_res=self.resolution,
                )
        except Exception as e:
            console.print(e, "\n")

        finally:
            pred_helper.restore_env()
Ejemplo n.º 2
0
    def call_mlp(self, other_args: List[str]):
        """Process mlp command"""
        try:
            ns_parser = pred_helper.parse_args(
                prog="mlp",
                description="""Multi-Layered-Perceptron. """,
                other_args=other_args,
            )
            if ns_parser:
                if ns_parser.n_inputs > len(self.data):
                    console.print(
                        f"[red]Data only contains {len(self.data)} samples and the model is trying "
                        f"to use {ns_parser.n_inputs} inputs.  Either use less inputs or load with"
                        f" an earlier start date[/red]\n")
                    return
                neural_networks_view.display_mlp(
                    dataset=self.current_id,
                    data=self.data,
                    n_input_days=ns_parser.n_inputs,
                    n_predict_days=ns_parser.n_days,
                    learning_rate=ns_parser.lr,
                    epochs=ns_parser.n_epochs,
                    batch_size=ns_parser.n_batch_size,
                    test_size=ns_parser.valid_split,
                    n_loops=ns_parser.n_loops,
                    no_shuffle=ns_parser.no_shuffle,
                    time_res=self.resolution,
                )
        except Exception as e:
            console.print(e, "\n")

        finally:
            pred_helper.restore_env()