示例#1
0
    def btn_analyse_clicked(self):
        self.statusbar.showMessage("Analysing " + self.selected_timeseries +
                                   "...")
        from utils.database_utils import DatabaseConnect
        db = DatabaseConnect()
        self.time_series_data = db.get_timeseries_details(
            timeseries_id=self.selected_timeseriesId, window=self.temp_window)
        self.analysed_data = []
        if "source_file" in self.time_series_data.keys(
        ) and self.time_series_data["source_file"]:
            import os
            if os.path.exists(self.time_series_data["source_file"]):
                for index in range(1, 11):
                    self.create_graph(
                        source_file=self.time_series_data["source_file"],
                        time_series_type=self.time_series_data["file_type"],
                        index=index)
                    self.show_graph(show=True)
                    self.statusbar.showMessage("", 1)
            else:
                QtWidgets.QMessageBox.about(self.temp_window, "Info",
                                            "Invalid source file !!!")

        else:
            QtWidgets.QMessageBox.about(self.temp_window, "Info",
                                        "No source file found !!!")
 def get_timeseries_details(self):
     """
             Get details of the Time series from the database.
     :return: timeseries_info
     """
     from utils.database_utils import DatabaseConnect
     db = DatabaseConnect()
     self.timeseries_info = db.get_timeseries_details(
         self.selected_timeseriesId, window=self.temp_window)
     return self.timeseries_info
示例#3
0
    def btn_export_prediction_clicked(self):
        """
                    Export the Prediction data as a CSV file
        """
        try:
            initial_data = ({
                "Time Series": self.selected_timeseries,
                "Model": self.selected_model,
                "Param 1": self.param_one.text(),
                "Param 2": self.param_two.text(),
                "Param 3": self.param_three.text()
            })
            initial_data.update(PREDICTION_DATA)
            col1 = list(initial_data.keys())
            col2 = list(initial_data.values())

            from utils.database_utils import DatabaseConnect
            db = DatabaseConnect()
            timeseries_data = db.get_timeseries_details(
                self.selected_timeseriesId, self.temp_window)
            source_file = timeseries_data["source_file"]

            import pandas as pd
            prediction_data = {}
            source_file_data = pd.read_excel(source_file,
                                             header=None).to_dict()
            if source_file_data:
                dates = dict(list(source_file_data.values())[0]).values()
                values = self.time_series_prediction(
                    dict(list(source_file_data.values())[1]).values())
                col1.extend([None, "Date"])
                col2.extend([None, "Predicted-values"])

                col1.extend(list(dates))
                col2.extend(list(values))
                prediction_data.update({"Column 1": col1, "Column 2": col2})

            from utils.window_utils import export_file
            export_file(window=self.temp_window, export_data=prediction_data)
        except Exception as ex:
            QtWidgets.QMessageBox.about(self.temp_window, "Error", str(ex))