def runner(self): logging.info('SubscriptionRatio.runner(), ' + self.currCourseName) try: print('Working on: ' + self.currCourseName + ' (' + self.progress() +')') self.anonForumIdMap = ModelHelper.getAnonForumIdMap() self.forumAnonIdMap = ModelHelper.getForumAnonIdMap() for k in range(100): percenters = CourseStats.getKPercenters(k) numPercenters = len(percenters) numSubscriptions = self.countSubscriptions(percenters) ratio = float(numSubscriptions)/ numPercenters path = os.path.join(self.resultsDir,'results' + str(k) + '.csv') with open(path,'at') as fid: fid.write(self.currCourseName + ', ' \ + str(numSubscriptions) + ', ' \ + str(numPercenters) + ', ' \ + str(ratio) + '\n') except CourseDBError: logging.info('\t\t+ ERROR (Connection does not exist), skipping...') pass except NoGradesError: logging.info('\t\t+ ERROR (CourseGrades does not exist), skipping...') pass
def runner(self): logging.info('ForumUseVsEngagement.runner(), ' + self.currCourseName) try: print('Working on: ' + self.currCourseName + ' (' + self.progress() + ')') self.anonForumIdMap = ModelHelper.getAnonForumIdMap() self.forumAnonIdMap = ModelHelper.getForumAnonIdMap() self.loadQuizInfo() self.loadFinalScoreMap() self.loadForumPostMap() self.getForumActivity() self.normalizeForumActivity() self.computeFinalScoreStats() self.normalizeFinalScores() self.loadLecturesViewed() self.normalizeLectureMap() self.allForumVsFinalScore() self.allForumVsLecturesViewed() except CourseDBError: logging.info( '\t\t+ ERROR (Connection does not exist), skipping...') pass except NoGradesError: logging.info( '\t\t+ ERROR (CourseGrades does not exist), skipping...') pass
def runner(self): try: print('Working on: ' + self.getCourseName() \ + ' (' + self.progress() +')') self.anonForumIdMap = ModelHelper.getAnonForumIdMap() self.forumAnonIdMap = ModelHelper.getForumAnonIdMap() numRegisteredUsers = Users.objects.count() path = os.path.join(self.getMainResultsDir(),'results.csv') with open(path,'at') as fid: fid.write(self.getCourseName() + ', ' + str(numRegisteredUsers) + '\n') except CourseDBError: logging.info('\t\t+ ERROR (Connection does not exist), skipping...') pass except NoGradesError: logging.info('\t\t+ ERROR (CourseGrades does not exist), skipping...') pass
def runner(self): logging.info('ForumUseVsQuizPerformance.runner(), ' + self.currCourseName) path = os.path.join(self.getResultsDir(), 'ForumActivityVsQuizScore.csv') pathStats = os.path.join(self.getResultsDir(), 'CourseStats.csv') pathCorrelation = os.path.join( self.getResultsDir(), 'ForumActivityVsQuizScore_regression.csv') try: print('Working on: ' + self.currCourseName + ' (' + self.progress() + ')') self.anonForumIdMap = ModelHelper.getAnonForumIdMap() self.forumAnonIdMap = ModelHelper.getForumAnonIdMap() self.loadQuizInfo() self.computeQuizStats() self.pruneQuizzes() self.loadQuizScoreMap() self.loadForumPostMap() if len(self.postMap) < MINPOSTERS: logging.info( '\t\t+ ERROR (Not enough forum activity, skipping...)') sys.exit() self.computeAvgWeeklyActivity() with open(path, 'wt') as fid: fid.write('Quiz Id, ') fid.write('# Forum Posts week before deadline, ') fid.write('# Original posts week before deadline, ') fid.write('Quiz score (normalized)\n') for quizId, quizNum in zip(self.quizzes, range(len(self.quizzes))): logging.info(' + ForumUseVsQuizPerformance progress: (quiz ' \ + str(quizNum) + ' of ' + str(len(self.quizzes)) + ')') self.computeForumVsQuizPerformance(quizId, path) self.getCorrelations(path, pathCorrelation) self.basicStats(pathStats) except CourseDBError: logging.info( '\t\t+ ERROR (Connection does not exist), skipping...') pass except NoGradesError: logging.info( '\t\t+ ERROR (CourseGrades does not exist), skipping...') pass
def runner(self): try: print('Working on: ' + self.getCourseName() \ + ' (' + self.progress() +')') self.anonForumIdMap = ModelHelper.getAnonForumIdMap() self.forumAnonIdMap = ModelHelper.getForumAnonIdMap() numRegisteredUsers = Users.objects.count() path = os.path.join(self.getMainResultsDir(), 'results.csv') with open(path, 'at') as fid: fid.write(self.getCourseName() + ', ' + str(numRegisteredUsers) + '\n') except CourseDBError: logging.info( '\t\t+ ERROR (Connection does not exist), skipping...') pass except NoGradesError: logging.info( '\t\t+ ERROR (CourseGrades does not exist), skipping...') pass
def runner(self): logging.info('ForumUseVsQuizPerformance.runner(), ' + self.currCourseName) path = os.path.join(self.getResultsDir(),'ForumActivityVsQuizScore.csv') pathStats = os.path.join(self.getResultsDir(),'CourseStats.csv') pathCorrelation = os.path.join(self.getResultsDir(),'ForumActivityVsQuizScore_regression.csv') try: print('Working on: ' + self.currCourseName + ' (' + self.progress() +')') self.anonForumIdMap = ModelHelper.getAnonForumIdMap() self.forumAnonIdMap = ModelHelper.getForumAnonIdMap() self.loadQuizInfo() self.computeQuizStats() self.pruneQuizzes() self.loadQuizScoreMap() self.loadForumPostMap() if len(self.postMap) < MINPOSTERS: logging.info('\t\t+ ERROR (Not enough forum activity, skipping...)') sys.exit() self.computeAvgWeeklyActivity() with open(path,'wt') as fid: fid.write('Quiz Id, ') fid.write('# Forum Posts week before deadline, ') fid.write('# Original posts week before deadline, ') fid.write('Quiz score (normalized)\n') for quizId, quizNum in zip(self.quizzes,range(len(self.quizzes))): logging.info(' + ForumUseVsQuizPerformance progress: (quiz ' \ + str(quizNum) + ' of ' + str(len(self.quizzes)) + ')') self.computeForumVsQuizPerformance(quizId, path) self.getCorrelations(path, pathCorrelation) self.basicStats(pathStats) except CourseDBError: logging.info('\t\t+ ERROR (Connection does not exist), skipping...') pass except NoGradesError: logging.info('\t\t+ ERROR (CourseGrades does not exist), skipping...') pass
def runner(self): logging.info('ForumUseVsEngagement.runner(), ' + self.currCourseName) try: print('Working on: ' + self.currCourseName + ' (' + self.progress() +')') self.anonForumIdMap = ModelHelper.getAnonForumIdMap() self.forumAnonIdMap = ModelHelper.getForumAnonIdMap() self.loadQuizInfo() self.loadFinalScoreMap() self.loadForumPostMap() self.getForumActivity() self.normalizeForumActivity() self.computeFinalScoreStats() self.normalizeFinalScores() self.loadLecturesViewed() self.normalizeLectureMap() self.allForumVsFinalScore() self.allForumVsLecturesViewed() except CourseDBError: logging.info('\t\t+ ERROR (Connection does not exist), skipping...') pass except NoGradesError: logging.info('\t\t+ ERROR (CourseGrades does not exist), skipping...') pass
import argparse from ModelHelper import ModelHelper # Single configuration trainer if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("filename", type=str) parser.add_argument("model_name", type=str) parser.add_argument("nb_hidden", type=int) parser.add_argument("window_size", type=int) parser.add_argument("stride", type=int) args = parser.parse_args() helper = ModelHelper(args.filename) helper.build(args.window_size, args.stride) model = helper.create_model(args.model_name, args.nb_hidden) helper.train(model, verbose=0)
import argparse from ModelHelper import ModelHelper from utils import product_dict from tqdm import tqdm # Multiple configuration trainer if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("--model_name", nargs="+", type=str) parser.add_argument("--nb_hidden", nargs="+", type=int) parser.add_argument("--window_size", nargs="+", type=int) parser.add_argument("--stride", nargs="+", type=int) args = parser.parse_args() helper = ModelHelper("beatles.txt") configs = list(product_dict(**args.__dict__)) for config in tqdm(configs): helper.build(config["window_size"], config["stride"]) model = helper.create_model(config["model_name"], config["nb_hidden"]) print(helper._label(config)) history = helper.train(model, nb_epochs=100, verbose=0) helper.plot_history(history, config) helper.plot_history(configs=args.__dict__, show_plot=True)