def graph_normalizedRRx(self, weeks, predict): """ UPDATE so that ending and starting weeks can be chosen UPDATE so that it returns the plot (use "ax" from matplotlib) so that it can be manipulated outside of the function Creats and shows a graph of "Normalized_RRx" and the specified number of weeks from the given dataframe PARAMETERS: weeks: number of weeks to dispaly. The graph displays the 0th entry to the specified number of weeks. (int) """ self.normalizedRRxChart = graphObj(self.drug, self.masterDf, weeks, "Week", ["Normalized_RRx"], ["scatter"], figW=self.figW, figH=self.figH) if predict == True: predictionDf = modelObj(self.masterDf, self.weeksToTrainOn, "Normalized_RRx", self.weeksToPredict).predictionDf self.normalizedRRxPredictionDf = predictionDf self.normalizedRRxChart.generateChart( ["scatter"], predictionDf["Week"], [predictionDf["Normalized_RRx"]])
def graph_eightWeekMARRx(self, weeks, predict): self.eightWeekMARRxChart = graphObj(self.drug, self.masterDf, weeks, "Week", ["Eight_Week_MA_RRx"], ["scatter"]) if predict == True: predictionDf = modelObj(self.masterDf, self.weeksToTrainOn, "Eight_Week_MA_RRx", self.weeksToPredict).predictionDf self.eightWeekMARRxChart.generateChart( ["scatter"], predictionDf["Week"], [predictionDf["Eight_Week_MA_RRx"]])
def prediction(): if request.headers["Content-Type"] == "application/json": drug = request.get_json()["drug"] weeks = request.get_json()["weeks"] source = request.get_json()["source"] predictBool = request.get_json()["predictBool"] weeksToTrainOn = request.get_json()["weeksToTrainOn"] drugobj = drugObj(drug, weeks, source, predictBool, weeksToTrainOn) target = request.get_json()["target"] weeksToPredict = request.get_json()["weeksToPredict"] predictionDf = modelClass.modelObj( drugobj.masterDf, drugobj.weeksToTrainOn, target, weeksToPredict ).predictionDf return predictionDf.to_json(orient="records") else: return "Unsupported mediatype"
def graph_eightWeekMARRxWoWGrowth(self, weeks, predict): self.eightWeekMARRxWoWGrowthChart = graphObj( self.drug, self.masterDf, weeks, "Week", ["Eight_Week_MA_RRx_WoW_Growth"], ["plot"], ) if predict == True: predictionDf = modelObj(self.masterDf, self.weeksToTrainOn, "Eight_Week_MA_RRx_WoW_Growth", self.weeksToPredict).predictionDf self.eightWeekMARRxWoWGrowthChart.generateChart( ["plot"], predictionDf["Week"], [predictionDf["Eight_Week_MA_RRx_WoW_Growth"]], )
def graph_thirteenWeekMANRx(self, weeks, predict): self.thirteenWeekMANRxChart = graphObj( self.drug, self.masterDf, weeks, "Week", ["Thirteen_Week_MA_NRx"], ["scatter"], ) if predict == True: predictionDf = modelObj(self.masterDf, self.weeksToTrainOn, "Thirteen_Week_MA_NRx", self.weeksToPredict).predictionDf self.thirteenWeekMANRxChart.generateChart( ["scatter"], predictionDf["Week"], [predictionDf["Thirteen_Week_MA_NRx"]], )
def graph_normalizedNRxLog(self, weeks, predict): self.normalizedNRxLogChart = graphObj( self.drug, self.masterDf, weeks, "Week", ["Normalized_NRx"], ["logy_plot"], yLabel="Normalized_TRx Log Scale", ) # might have wierd predict behavior if predict == True: predictionDf = modelObj(self.masterDf, self.weeksToTrainOn, "Normalized_NRx", self.weeksToPredict).predictionDf self.normalizedNRxLogChart.generateChart( ["logy_plot"], predictionDf["Week"], [predictionDf["Normalized_NRx"]])
def graph_rrxWowGrowth(self, weeks, predict): """ UPDATE so that ending and starting weeks can be chosen UPDATE so that it returns the plot (use "ax" from matplotlib) so that it can be manipulated outside of the function Creats and shows a graph of "RRx_Wow_Growth" and the specified number of weeks from the given dataframe. PARAMETERS: weeks: number of weeks to dispaly. The graph displays the 0th entry to the specified number of weeks. (int) df: the dataframe from which to use the data to be displayed in graph. Must have "RRx_Wow_Growth" column. (dataframe) """ self.rrxWowGrowthChart = graphObj(self.drug, self.masterDf, weeks, "Week", ["RRx_Wow_Growth"], ["plot"]) if predict == True: predictionDf = modelObj(self.masterDf, self.weeksToTrainOn, "RRx_Wow_Growth", self.weeksToPredict).predictionDf self.rrxWowGrowthChart.generateChart( ["plot"], predictionDf["Week"], [predictionDf["RRx_Wow_Growth"]])
def graph_thirteenWeekMANRxWoWGrowth(self, weeks, predict): self.thirteenWeekMANRxWoWGrowthChart = graphObj( self.drug, self.masterDf, weeks, "Week", ["Thirteen_Week_MA_NRx_WoW_Growth"], ["plot"], ) if predict == True: predictionDf = modelObj( self.masterDf, self.weeksToTrainOn, "Thirteen_Week_MA_NRx_WoW_Growth", self.weeksToPredict, ).predictionDf self.thirteenWeekMANRxWoWGrowthChart.generateChart( ["plot"], predictionDf["Week"], [predictionDf["Thirteen_Week_MA_NRx_WoW_Growth"]], )