def confirmDataSimulatorUserInputLoop(self): """ Since this option require time to build the model, ask user confirmation he/she wants to pursue """ userInput="" catagory_mapping = {2: 'Autos & Vehicles', 23: 'Comedy' , 27: 'Education', 24: 'Entertainment' , 1: 'Film & Animation', 20: 'Gaming' ,26: 'Howto & Style', 10: 'Music',25: 'News & Politics', 29:'Nonprofits & Activism' , 22:'People & Blogs', 15: 'Pets & Animals' , 28: 'Science & Technology', 17: 'Sports' , 19:'Travel & Events'} try: while userInput != "quit": self.printConfirmDataSimulationOptions() userInput = raw_input("\nPlease provide the input : ") if userInput == "1": # Building the model tree, model_count_title, model_count_description, count_vectorizer_title, count_vectorizer_description = Video.generatePredictingModel(DataManager.cleaned_data) # Performing the predictions on the user inputs try: while userInput != "quit": self.printPredictionOptions() userInput = raw_input("\nPlease provide the input : ") if userInput == "1": print "\nYou can either go on YoutTube and enter the title and the description of a video of your choice, or enter a title and a description of a random video you have in mind" time.sleep(1.5) # delay for 1.5 seconds title = raw_input("\nPlease provide the title of your video : ") description = raw_input("\nPlease provide the description of the video : ") video = Video(title,description) predicted_category_value = video.predictVideoCategory(tree, model_count_title, model_count_description, count_vectorizer_title, count_vectorizer_description) predicted_category_name = catagory_mapping[predicted_category_value] print "\nMy prediction is that your video is a {} video".format(predicted_category_name) time.sleep(3) # delay for 3 seconds elif userInput == "4": print "\nYou are now in the previous control" self.InitiateFlow() elif userInput == "quit": self.ExitProgram() except KeyboardInterrupt: print "quitting..." sys.exit() elif userInput == "4": print "\nYou are now in the previous control" self.InitiateFlow() elif userInput == "quit": self.ExitProgram() except KeyboardInterrupt: print "quitting..." sys.exit()
def confirmDataSimulatorUserInputLoop(self): """ Since this option require time to build the model, ask user confirmation he/she wants to pursue """ userInput="" try: while userInput != "quit": self.printConfirmDataSimulationOptions() userInput = raw_input("\nPlease provide the input : ") if userInput == "1": # Building the model tree, model_count_title, model_count_description, count_vectorizer_title, count_vectorizer_description = Video.generatePredictingModel(DataManager.cleaned_data) # Performing the predictions on the user inputs try: while userInput != "quit": self.printPredictionOptions() userInput = raw_input("\nPlease provide the input : ") if userInput == "1": print "\nNow please go on YoutTube, chose the video of your choice, and enter the title and the description of that video (for more information, please read the README file)" time.sleep(1.5) # delay for 1.5 seconds title = raw_input("\nPlease provide the title of your video : ") description = raw_input("\nPlease provide the description of the video : ") video = Video(title,description) predicted_category_value = video.predictVideoCategory(tree, model_count_title, model_count_description, count_vectorizer_title, count_vectorizer_description) predicted_category_name = DataExplorer.Catagory_mapping[predicted_category_value] print "\nMy prediction is that your video is a {} video".format(predicted_category_name) time.sleep(3) # delay for 3 seconds elif userInput == "4": self.self.InitiateFlow() elif userInput == "quit": self.ExitProgram() except KeyboardInterrupt: print "quitting..." sys.exit() elif userInput == "4": self.self.InitiateFlow() elif userInput == "quit": self.ExitProgram() except KeyboardInterrupt: print "quitting..." sys.exit()
def performPrediction( self, tree, model_count_title, model_count_description, count_vectorizer_title, count_vectorizer_description ): """ Data Simulation Option loop Ask the user which action he/she wants to take, initialize model construction and perform prediction if required The loop is break (and the program ends) whenever the user types quit. """ try: userInput = "" while userInput != "quit": self.printPredictionOptions() userInput = raw_input("\nPlease provide the input : ") if userInput == "1": print "\nNow please go on YoutTube, chose the video of your choice, and enter the title and the description of that video (for more information, please read the README file)" time.sleep(1.5) title = raw_input("\nPlease provide the title of your video (as one single line) : ") description = raw_input("\nPlease provide the description of the video (as one single line) : ") video = Video(title, description) predicted_category_value = video.predictVideoCategory( tree, model_count_title, model_count_description, count_vectorizer_title, count_vectorizer_description, ) predicted_category_name = self.dataexplorer.Catagory_mapping[predicted_category_value] print "\nMy prediction is that your video is a {} video".format(predicted_category_name) time.sleep(3) elif userInput == "4": self.InitiateFlow() elif userInput == "quit": self.ExitProgram() else: print "\nOops...Incorrect Input...Please enter correct Input !!!\n" self.performPrediction( tree, model_count_title, model_count_description, count_vectorizer_title, count_vectorizer_description, ) except KeyboardInterrupt: print "quitting..." sys.exit()
def performPrediction(self, tree, model_count_title, model_count_description, count_vectorizer_title, count_vectorizer_description): """ Data Simulation Option loop Ask the user which action he/she wants to take, initialize model construction and perform prediction if required The loop is break (and the program ends) whenever the user types quit. """ try: userInput = "" while userInput != "quit": self.printPredictionOptions() userInput = raw_input("\nPlease provide the input : ") if userInput == "1": print "\nNow please go on YoutTube, chose the video of your choice, and enter the title and the description of that video (for more information, please read the README file)" time.sleep(1.5) title = raw_input( "\nPlease provide the title of your video (as one single line) : " ) description = raw_input( "\nPlease provide the description of the video (as one single line) : " ) video = Video(title, description) predicted_category_value = video.predictVideoCategory( tree, model_count_title, model_count_description, count_vectorizer_title, count_vectorizer_description) predicted_category_name = self.dataexplorer.Catagory_mapping[ predicted_category_value] print "\nMy prediction is that your video is a {} video".format( predicted_category_name) time.sleep(3) elif userInput == "4": self.InitiateFlow() elif userInput == "quit": self.ExitProgram() else: print "\nOops...Incorrect Input...Please enter correct Input !!!\n" self.performPrediction(tree, model_count_title, model_count_description, count_vectorizer_title, count_vectorizer_description) except KeyboardInterrupt: print "quitting..." sys.exit()
def confirmDataSimulatorUserInputLoop(self): """ Data Simulation Option loop Ask the user which action he/she wants to take and send user to appropriate option The loop is break (and the program ends) whenever the user types quit. """ userInput = "" try: while userInput != "quit": self.printConfirmDataSimulationOptions() userInput = raw_input("\nPlease provide the input : ") if userInput == "1": # Building the model tree, model_count_title, model_count_description, count_vectorizer_title, count_vectorizer_description = Video.generatePredictingModel( self.datamanager.cleaned_data) print "\nNow give it a try and check out our awesome predictions !!!" time.sleep(3) # Perform as many prediction as required by the user self.performPrediction(tree, model_count_title, model_count_description, count_vectorizer_title, count_vectorizer_description) elif userInput == "4": self.InitiateFlow() elif userInput == "quit": self.ExitProgram() else: print "\nOops...Incorrect Input...Please enter correct Input !!!\n" self.confirmDataSimulatorUserInputLoop() except KeyboardInterrupt: print "quitting..." sys.exit()