Esempio n. 1
0
def refreshBars():
    setMainTable(Tables.Tables(getMainWindow()).Table)
    getMainWindow().SpecialTools = SpecialTools.SpecialTools(getMainWindow())
    if uni.tableType in ["2", "6", "8", "9"]:
        from Bars import PlayerBar

        getMainWindow().PlayerBar = PlayerBar.PlayerBar(getMainWindow())
        getMainWindow().addToolBar(Mt.TopToolBarArea,
                                   getMainWindow().PlayerBar)
    getMainWindow().Menu.refreshForTableType()
Esempio n. 2
0
 def predict_length(self,vector,course_list):
     tb = Tables()
     tb.read_data("grade2.csv", "student.csv")
     vector=self.courses_to_numeric(vector,True)
     lst = np.empty(tb.studyTable.shape[1])
     lst[:] = np.nan
     for i in range(len(course_list)):
         if course_list[i] in tb.courseList:
             lst[tb.courseList.index(course_list[i])] = vector[i]
     lst = lst.reshape(1,-1)
     lst = tb.study_imp.transform(lst)
     result = self.study_length.predict(lst)
     return np.round(result[0])
Esempio n. 3
0
 def predict_dropout(self,vector,course_list):
     tb = Tables()
     tb.read_data("grade2.csv", "student.csv")
     vector=self.courses_to_numeric(vector,True)
     lst = np.empty(tb.dropoutTable.shape[1])
     lst[:] = np.nan
     for i in range(len(course_list)):
         if course_list[i] in tb.courseList:
             lst[tb.courseList.index(course_list[i])] = vector[i]
     lst = lst.reshape(1,-1)
     lst = tb.dropout_imp.transform(lst)
     result = self.dropout.predict(lst)
     if result[0] == 1: return True
     else:   return False
Esempio n. 4
0
    def predict_gpa(self,vector,course_list):
        tb = Tables()
        tb.read_data("grade2.csv", "student.csv")
        vector=self.courses_to_numeric(vector,True)
        lst = np.empty(tb.graduationTable.shape[1])
        lst[:] = np.nan
        for i in range(len(course_list)):
            if course_list[i] in tb.courseList:
                lst[tb.courseList.index(course_list[i])] = vector[i]
        lst = lst.reshape(1,-1)
        lst = tb.graduation_imp.transform(lst)

        result = self.gpa.predict(lst)
        if result<0: result=result*-1
        return "%.2f"%result
Esempio n. 5
0
def Output():
    db.create_all()
    if request.method == 'POST':
        userdata = Tables(request.form["Username"], request.form["psw"])
        users = Tables.query.filter_by(
            Username=request.form["Username"]).first()
        if users is not None:
            message = "User name is already existing.Register with new user name"
            return render_template("Registration.html", message1=message)
        db.session.add(userdata)
        db.session.commit()
        message = "Registartion is successful"
        return render_template("Registration.html", message=message)
    #     result = request.form
    #     print(result['Username'])
    else:
        return render_template("Registration.html")
Esempio n. 6
0
    def create_new_model(self, grade_file, student_file, predict_function, algorithm_name, parameters, course_name, semester):

        tb = Tables()
        tb.read_data(grade_file, student_file)
        
        if predict_function=='gpa':
             if algorithm_name=='linear':
                 return ML.linear_regression(tb.graduationTable, tb.graduationLabel, parameters)
            
        elif predict_function=='dropout':            
            if algorithm_name=='logistic':
                return ML.logistic_regression(tb.dropoutTable, tb.dropoutLabel, parameters)
            elif algorithm_name=='svm':
                return ML.svm(tb.dropoutTable, tb.dropoutLabel, parameters)
            elif algorithm_name=='mlp':
                return ML.mlp(tb.dropoutTable, tb.dropoutLabel, parameters)

        elif predict_function=='course_grade':
            ##get required table without target label
            c = [0,0.5,1,1.5,2,2.5,3,3.5,4]
            x = tb.courseTable.copy()
            class_index = tb.courseList.index(course_name.lower())
            y = x[:,class_index] ## class label
            x = np.delete(x,class_index,1) ## remove class column from input data
            ## change y label with class value (eg. if y[0] = 3.5 then it become 7th class)
            for i in range(y.size):
                    index = c.index(y[i])
                    y[i] = index
            
            if algorithm_name=='logistic':
                return ML.logistic_regression(x,y,parameters)
            elif algorithm_name=='svm':
                return ML.svm(x,y,parameters)
            elif algorithm_name=='mlp':
                return ML.mlp(x,y,parameters)

        elif predict_function=='study_length':
            if algorithm_name=='linear':
                return ML.linear_regression(tb.studyTable, tb.studyLabel, parameters)
            elif algorithm_name=='mlp_regressor':
                return ML.mlp_regressor(tb.studyTable, tb.studyLabel, parameters)
Esempio n. 7
0
    def predict_course_grade(self,vector,course_list,pcourse_name):
        tb = Tables()
        tb.read_data("grade2.csv", "student.csv")
        if (pcourse_name not in tb.courseList):
            return (pcourse_name+" is not available anymore")

        model=None
        q_course = "SELECT path \
                    FROM models \
                    WHERE gradeFile='%s' AND studentFile='%s' AND function='%s' AND course='%s' AND isDefault='%d'" % ("grade2.csv","student.csv","course_grade",pcourse_name,1)
        
        db = MySQLdb.connect("localhost",mysql_user,password,"gpa_db_4" )
        cursor = db.cursor()
        try:
            cursor.execute(q_course)
            path = cursor.fetchone()
            model = joblib.load(path[0])
        except IOError as e:
            print("Model file doesn't exist.")
 
        db.close()

        if model==None:
            return ("There is no available model file for" + pcourse_name)
        
        vector=self.courses_to_numeric(vector,True) ##convert course grades to numeric ones(eg. AA=4, CB = 2.5)
        lst = np.empty(tb.courseTable.shape[1])
        lst[:] = np.nan
        for i in range(len(course_list)):
            if course_list[i] in tb.courseList:
                lst[tb.courseList.index(course_list[i])] = vector[i]
        lst = lst.reshape(1,-1)
        lst = tb.course_imp.transform(lst)

        class_index = tb.courseList.index(pcourse_name)
        lst = np.delete(lst,class_index,1) ## remove class column from input data
        result = model.predict(lst)
        result = self.courses_to_numeric(result,False)
        return result[0]
Esempio n. 8
0
 def __init__(self, value):
     self.value  = value
     self.tables= Tables(value)
     self.left   = None
     self.right  = None
     self.height = 0   #altura