Example #1
0
    def call_lstm(self, other_args: List[str]):
        """Process lstm command"""
        try:
            ns_parser = pred_helper.parse_args(
                prog="lstm",
                description="""Long-Short Term Memory. """,
                other_args=other_args,
            )
            if ns_parser:
                neural_networks_view.display_lstm(
                    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()
Example #2
0
    def call_lstm(self, other_args: List[str]):
        """Process lstm command"""
        try:
            ns_parser = pred_helper.parse_args(
                prog="lstm",
                description="""Long-Short Term Memory. """,
                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_lstm(
                    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()