Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- """
- Created on Tue Apr 18 19:06:15 2017
- @author: Menna
- """
- import pymysql
- import pandas as pd
- import numpy as np
- #import sys
- import math
- input_student = input('Choose an ID:')
- db = pymysql.connect(host="127.0.0.1",user="root",passwd="",db="registration_system")
- cur = db.cursor()
- cur1 = db.cursor()
- cur2 = db.cursor()
- cur3 = db.cursor()
- cur4 = db.cursor()
- cur5 = db.cursor()
- cur6 = db.cursor()
- cur.execute("SELECT student_id , course_code , grade FROM STUDENT_COURSE ")
- query_result = cur.fetchall()
- cur1.execute("SELECT course_code,course_creditHours FROM COURSE ")
- courses = cur1.fetchall()
- cur2.execute("SELECT student_id , total_hours FROM STUDENT ")
- Total_Hours = cur2.fetchall()
- cur3.execute("SELECT * FROM PREREQUISITES ")
- prerequisites = cur3.fetchall()
- cur4.execute("SELECT COUNT(DISTINCT student_semester) FROM student_course WHERE student_id="+ input_student+" AND student_semester LIKE 'F%'")
- FallCount = cur4.fetchone()
- cur5.execute("SELECT COUNT(DISTINCT student_semester) FROM student_course WHERE student_id="+ input_student+" AND student_semester LIKE 'Spr%'")
- SpringCount = cur5.fetchone()
- cur6.execute("SELECT * FROM student_course WHERE student_id="+input_student)
- query_result6 = cur6.fetchall()
- db.close()
- all_students = pd.DataFrame()
- Courses = pd.DataFrame()
- OutputDataFrame = pd.DataFrame()
- FinalDataFrame = pd.DataFrame()
- AssociationDataFrame = pd.DataFrame()
- TotalHoursDataFrame = pd.DataFrame()
- Prerequisite_Course = pd.DataFrame()
- for (i,row) in enumerate(query_result):
- current_student = pd.DataFrame({'ID':[int(row[0])],'Course':[row[1]],'Grade':[row[2]]},index=[i])
- all_students = all_students.append(current_student)
- #print(all_students)
- for (i,row) in enumerate(Total_Hours):
- totalhoursofstudent = pd.DataFrame({'ID':[int(row[0])],'Total_hours':[row[1]]},index=[i])
- TotalHoursDataFrame = TotalHoursDataFrame.append(totalhoursofstudent)
- for (i,row) in enumerate(courses):
- current_course = pd.DataFrame({'Course':[row[0]]}, index =[i])
- current_course['i'] = current_course.index
- Courses = Courses.append(current_course)
- for (i,row) in enumerate(prerequisites):
- prerequisitecourse = pd.DataFrame({'Course':[row[0]],'Prerequisite':[row[1]]}, index =[i])
- Prerequisite_Course = Prerequisite_Course.append(prerequisitecourse)
- OutputDataFrame = all_students.set_index('Course').join(Courses.set_index('Course'))
- Courses = None
- query_result = None
- OutputDataFrame = OutputDataFrame.sort_index(by=['ID'], ascending=[True])
- #print(OutputDataFrame)
- OutputDataFrame = OutputDataFrame.replace('A',10)
- OutputDataFrame = OutputDataFrame.replace('A-',9)
- OutputDataFrame = OutputDataFrame.replace('B+',8)
- OutputDataFrame = OutputDataFrame.replace('B',7)
- OutputDataFrame = OutputDataFrame.replace('B-',6)
- OutputDataFrame = OutputDataFrame.replace('C+',5)
- OutputDataFrame = OutputDataFrame.replace('C',4)
- OutputDataFrame = OutputDataFrame.replace('C-',3)
- OutputDataFrame = OutputDataFrame.replace('D+',2)
- OutputDataFrame = OutputDataFrame.replace('D',1)
- OutputDataFrame = OutputDataFrame.replace('W',0)
- OutputDataFrame = OutputDataFrame.replace('F',0)
- OutputDataFrame = OutputDataFrame.replace('Ab',0)
- OutputDataFrame = OutputDataFrame.replace('',0)
- OutputDataFrame = OutputDataFrame.replace('I',0)
- OutputDataFrame = OutputDataFrame.replace('E',0)
- OutputDataFrame = OutputDataFrame.replace('AU',0)
- for(i,row) in enumerate(OutputDataFrame.ID.unique()):
- Data = OutputDataFrame[ OutputDataFrame['ID'] == row]
- array = np.zeros(88)
- for(j,row1) in enumerate(Data['i']):
- Indices = row1
- array[Indices] = Data['Grade'][j]
- current_output = pd.DataFrame({'ID':row,'Array':[array]},index=[i])
- FinalDataFrame = FinalDataFrame.append(current_output)
- #with pd.option_context('display.max_rows', None, 'display.max_columns', 3,'display.max_colwidth', 1000):
- #print(FinalDataFrame) #to print whole data frame
- from sklearn.cluster import KMeans
- X = list(FinalDataFrame.Array)
- kmeans_model = KMeans(n_clusters=13, random_state = 22).fit(X) # root(333/2)
- labels = kmeans_model.labels_ # el array of 333 bytl3 feha kol wa7ed belongs le anhi cluster
- centers = kmeans_model.cluster_centers_ # btegb el centers bt3t el clusters
- xx=FinalDataFrame.loc[FinalDataFrame['ID'] == int(input_student)] #search in dataframe
- cluster_number = labels[xx.index]
- #x=kmeans_model.predict(FinalDataFrame.Array[1])
- #xx=FinalDataFrame.loc[FinalDataFrame['ID'] == 2222] #search in dataframe
- #labels[xx.index]
- def ClusterIndicesNumpy(clustNum, labels_array): #numpy
- return np.where(labels_array == clustNum)[0]
- np.set_printoptions(threshold=np.inf) #to print whole array
- ElementsInCluster=ClusterIndicesNumpy(int(cluster_number), labels)
- ClusterOfClusters = []
- for i in ElementsInCluster:
- ClusterOfClusters.append(X[i])
- IDsInCluster = []
- for i in ElementsInCluster:
- IDsInCluster.append(FinalDataFrame.iloc[i]['ID'])
- n = len(ClusterOfClusters)
- LengthOfNewCluster = math.ceil(math.sqrt(n/2))
- kmeans_clusterofclusters = KMeans(n_clusters=LengthOfNewCluster, random_state = 22).fit(ClusterOfClusters) # root(333/2)
- labels_clusterofclusters = kmeans_clusterofclusters.labels_
- centers_clusterofclusters = kmeans_clusterofclusters.cluster_centers_ # btegb el centers bt3t el clusters
- for (i,row) in enumerate(IDsInCluster):
- if(IDsInCluster[i]==int(input_student)):
- Index = i
- cluster_number_clusterofclusters = labels_clusterofclusters[Index]
- def ClusterIndicesNumpy(clustNum, labels_array): #numpy
- return np.where(labels_array == clustNum)[0]
- np.set_printoptions(threshold=np.inf) #to print whole array
- ElementsInCluster_clusterofcluster = ClusterIndicesNumpy(int(cluster_number_clusterofclusters), labels_clusterofclusters)
- indicesinClusterofCluster = []
- for i in ElementsInCluster_clusterofcluster:
- indicesinClusterofCluster.append(ElementsInCluster[i])
- IDsInClusterOfClusters = []
- for i in indicesinClusterofCluster:
- IDsInClusterOfClusters.append(FinalDataFrame.iloc[i]['ID'])
- for(i,row) in enumerate(IDsInClusterOfClusters):
- Data = OutputDataFrame[ OutputDataFrame['ID'] == row]
- courses_array = np.array(88)
- courses_array = Data.index.values
- association_input = pd.DataFrame({'Courses':[courses_array]},index=[i])
- AssociationDataFrame=AssociationDataFrame.append(association_input)
- ArrayOfCourses = list(AssociationDataFrame.Courses)
- import pyfpgrowth
- support = math.floor(len(ArrayOfCourses)*0.75)
- patterns = pyfpgrowth.find_frequent_patterns(ArrayOfCourses, support)
- rules = pyfpgrowth.generate_association_rules(patterns, 0.6)
- #sys.setrecursionlimit(1000)
- #rules = list(rules)
- FetchingCoursesOfID = OutputDataFrame[ OutputDataFrame['ID'] == int(input_student)]
- courses_Of_Given_ID = FetchingCoursesOfID.index.values
- courses_Of_Given_ID = set(courses_Of_Given_ID)
- keys = list(rules.keys())
- values = list(rules.values())
- keys = [set(elem) for elem in keys]
- #values = [list(elem) for elem in values]
- New_values=[]
- for (k,rows) in enumerate(keys):
- Output_intersection=courses_Of_Given_ID.intersection(keys[k])
- match=len(Output_intersection)/len(keys[k])
- if (match >= 0.6):
- New_values.append(values[k])
- OutputRulesCourses = []
- for (i,row) in enumerate(New_values):
- OutputRulesCourses.append(New_values[i][0])
- flattened = [val for sublist in OutputRulesCourses for val in sublist]
- flattened = set(flattened)
- ToBeRecommended = flattened - courses_Of_Given_ID
- ToBeRecommended = list(ToBeRecommended)
- addit = []
- nextterm = []
- mustbeadded = []
- for row in ToBeRecommended:
- pre = set(Prerequisite_Course.loc[Prerequisite_Course['Course'] == row]['Prerequisite'])
- condition = all(x in courses_Of_Given_ID for x in pre)
- if not pre:
- addit.append(row)
- elif(condition):
- addit.append(row)
- elif(not condition):
- pre =list(pre - courses_Of_Given_ID)
- mustbeadded.extend(pre)
- nextterm.append(row)
- addit = list(set(addit) - set(mustbeadded))
- mustbeadded.extend(addit)
- addit = mustbeadded
- nextterm = list(set(nextterm))
- FetchingTotalhoursofID = TotalHoursDataFrame[ TotalHoursDataFrame['ID'] == int(input_student)]
- FetchingTotalhoursofID = list(FetchingTotalhoursofID['Total_hours'])
- FetchingTotalhoursofID = FetchingTotalhoursofID[0]
- CurrentTermNo=int(FallCount[0])+int(SpringCount[0]) #el last term
- NextTermNo=CurrentTermNo+1 #el term el mfrod a-recommendelo
- FirstYear = 35
- SecondYear = 72
- ThirdYear = 106
- FourthYear = 140
- FifthYear = 175
- if (CurrentTermNo == 1 or CurrentTermNo == 2):
- Year=1
- elif (CurrentTermNo == 3 or CurrentTermNo == 4):
- Year=2
- elif (CurrentTermNo == 5 or CurrentTermNo == 6):
- Year=3
- elif (CurrentTermNo == 7 or CurrentTermNo == 8):
- Year=4
- elif (CurrentTermNo == 9 or CurrentTermNo == 10):
- Year=5
- if (Year ==1):
- RemainingHours = FirstYear - FetchingTotalhoursofID
- elif (Year ==2):
- RemainingHours = SecondYear - FetchingTotalhoursofID
- elif (Year ==3):
- RemainingHours = ThirdYear - FetchingTotalhoursofID
- elif (Year ==4):
- RemainingHours = FourthYear - FetchingTotalhoursofID
- elif (Year ==5):
- RemainingHours = FifthYear - FetchingTotalhoursofID
- CoursesCreditHr = pd.DataFrame()
- for (i,row) in enumerate(courses):
- Courses_CreditHr = pd.DataFrame({'Course':[row[0]],'CreditHr':[row[1]]}, index =[i])
- CoursesCreditHr = CoursesCreditHr.append(Courses_CreditHr)
- #totalHrsRec = 0
- #hr1 = 0
- #hr2 = 0
- #CurrentSemester = [] #NextTermNo
- #NextSemester = [] #NextTermNo+1
- #NextSemester.extend(nextterm)
- #for (i,row) in enumerate(addit):
- # CourseCredit=CoursesCreditHr.loc[CoursesCreditHr['Course'] == addit[i]]
- # HrPerCourse = int(CourseCredit['CreditHr'])
- # totalHrsRec=totalHrsRec+HrPerCourse
- # if (totalHrsRec <= 20):
- # CurrentSemester.append(addit[i])
- # hr1 = hr1+HrPerCourse
- # elif(totalHrsRec > 20):
- # NextSemester.append(addit[i])
- # hr2 = hr2+HrPerCourse
- #TookTerms=''
- #if(not NextSemester):
- # db = pymysql.connect(host="127.0.0.1",user="root",passwd="",db="registration_system")
- # cur7 = db.cursor()
- # TookTerms=str(NextTermNo)
- # cur7.execute("SELECT * FROM fixed_studyplan WHERE term <="+TookTerms)
- # query_result7 = cur7.fetchall()
- # db.close()
- #elif(NextSemester):
- # db = pymysql.connect(host="127.0.0.1",user="root",passwd="",db="registration_system")
- # cur7 = db.cursor()
- # TookTerms=str(int(NextTermNo)+1)
- # cur7.execute("SELECT * FROM fixed_studyplan WHERE term <="+TookTerms)
- # query_result7 = cur7.fetchall()
- # db.close()
- Courses_Taken_ID = pd.DataFrame()
- for (i,row) in enumerate(query_result6):
- CoursesTakenID = pd.DataFrame({'CoursesTaken':[row[1]]}, index =[i])
- Courses_Taken_ID = Courses_Taken_ID.append(CoursesTakenID)
- Courses_Taken_ID = list(Courses_Taken_ID.CoursesTaken)
- recommended = []
- CurrentSemester = []
- NextSemester = []
- remaining = []
- hr2 = 0
- should_Take_Courses = pd.DataFrame()
- TotalHrsID = FetchingTotalhoursofID
- RemHr = RemainingHours
- for i in range(NextTermNo,6):
- CR_HRS = 0
- if(i == 3 and (RemHr==0 or RemHr < 0)) :
- RemHr = 0
- CR_HRS = 20
- TotalHrsID = TotalHrsID + CR_HRS
- if (i == 1 or i == 2):
- Y=1
- elif (i == 3 or i == 4):
- Y=2
- elif (i == 5 or i == 6):
- Y=3
- elif (i == 7 or i == 8):
- Y=4
- elif (i == 9 or i == 10):
- Y=5
- if (Y ==1):
- RemHr = 35 - TotalHrsID
- elif (Y ==2):
- RemHr = 72 - TotalHrsID
- elif (Y ==3):
- RemHr = 106 - TotalHrsID
- elif (Y ==4):
- RemHr = 140 - TotalHrsID
- elif (Y ==5):
- RemHr = 175 - TotalHrsID
- elif(RemHr > 2 and not i % 2 == 0 ):
- RemHr = 0
- CR_HRS = 20
- if (i == NextTermNo):
- totalHrsRec = 0
- hr1 = 0
- NextSemester.extend(nextterm)
- for (k,row) in enumerate(nextterm):
- CourseCredit=CoursesCreditHr.loc[CoursesCreditHr['Course'] == nextterm[k]]
- HrPerCourse = int(CourseCredit['CreditHr'])
- totalHrsRec=totalHrsRec+HrPerCourse
- hr2 = totalHrsRec
- HrPerCourse = 0
- totalHrsRec = 0
- for (j,row) in enumerate(addit):
- CourseCredit=CoursesCreditHr.loc[CoursesCreditHr['Course'] == addit[j]]
- HrPerCourse = int(CourseCredit['CreditHr'])
- totalHrsRec=totalHrsRec+HrPerCourse
- if (totalHrsRec <= CR_HRS):
- CurrentSemester.append(addit[j])
- hr1 = hr1+HrPerCourse
- elif(totalHrsRec > CR_HRS):
- NextSemester.append(addit[j])
- hr2 = hr2+HrPerCourse
- totalHrsRec = totalHrsRec - HrPerCourse
- CR_HRS =hr1
- print("Term : "+str(i))
- print(CurrentSemester)
- recommended.extend(CurrentSemester)
- print("with "+str(hr1)+" credit hours")
- #fadel lw el addit feha mwad olyla
- elif (i == (NextTermNo+1)):
- print("not now")
- else:
- if(NextSemester):
- if (hr2 < CR_HRS ):
- db = pymysql.connect(host="127.0.0.1",user="root",passwd="",db="registration_system")
- cur8 = db.cursor()
- TookTerms=str(i)
- cur8.execute("SELECT * FROM fixed_studyplan WHERE term <=(%s) ORDER BY term",(TookTerms))
- query_result8 = cur8.fetchall()
- db.close()
- should_Take_Courses = None
- should_Take_Courses = pd.DataFrame()
- for (j,row) in enumerate(query_result8):
- shouldTakeCourses = pd.DataFrame({'Course':[row[0]],'term':[row[2]]}, index =[j])
- should_Take_Courses = should_Take_Courses.append(shouldTakeCourses)
- should_Take_Courses = should_Take_Courses.drop_duplicates().reset_index(drop=True)
- #should_Take_Courses = should_Take_Courses.sort_index(by=['term'], ascending=[True])
- should_Take_Courses = list(should_Take_Courses.Course)
- CurrentSemester = []
- CurrentSemester.extend(NextSemester)
- remaining = list(set(should_Take_Courses)-set(Courses_Taken_ID)-set(recommended))
- remaining = list(set(remaining)-set(NextSemester))
- NextSemester = []
- hr1=hr2
- HrPerCourse = 0
- totalHrsRec = hr2
- hr2=0
- for (j,row) in enumerate(remaining):
- CourseCredit=CoursesCreditHr.loc[CoursesCreditHr['Course'] == remaining[j]]
- HrPerCourse = int(CourseCredit['CreditHr'])
- totalHrsRec=totalHrsRec+HrPerCourse
- if (totalHrsRec <= CR_HRS):
- CurrentSemester.append(remaining[j])
- hr1 = hr1+HrPerCourse
- elif(totalHrsRec > CR_HRS):
- NextSemester.append(remaining[j])
- hr2 = hr2+HrPerCourse
- totalHrsRec = totalHrsRec - HrPerCourse
- CR_HRS =hr1
- print("Term : "+str(i))
- print(CurrentSemester)
- recommended.extend(CurrentSemester)
- remaining = list(set(remaining)-set(recommended))
- print("with "+str(hr1)+" credit hours")
- elif(hr2 >= CR_HRS):
- print("not now")
- elif(not NextSemester):
- print("not now")
- TotalHrsID = TotalHrsID + CR_HRS
- if (i == 1 or i == 2):
- Y=1
- elif (i == 3 or i == 4):
- Y=2
- elif (i == 5 or i == 6):
- Y=3
- elif (i == 7 or i == 8):
- Y=4
- elif (i == 9 or i == 10):
- Y=5
- if (Y ==1):
- RemHr = 35 - TotalHrsID
- elif (Y ==2):
- RemHr = 72 - TotalHrsID
- elif (Y ==3):
- RemHr = 106 - TotalHrsID
- elif (Y ==4):
- RemHr = 140 - TotalHrsID
- elif (Y ==5):
- RemHr = 175 - TotalHrsID
- elif(RemHr > 0 and RemHr < 3 and not i % 2 == 0 ):
- CR_HRS = 17 + RemHr
- RemHr = 0
- TotalHrsID = TotalHrsID + CR_HRS
- if (i == 1 or i == 2):
- Y=1
- elif (i == 3 or i == 4):
- Y=2
- elif (i == 5 or i == 6):
- Y=3
- elif (i == 7 or i == 8):
- Y=4
- elif (i == 9 or i == 10):
- Y=5
- if (Y ==1):
- RemHr = 35 - TotalHrsID
- elif (Y ==2):
- RemHr = 72 - TotalHrsID
- elif (Y ==3):
- RemHr = 106 - TotalHrsID
- elif (Y ==4):
- RemHr = 140 - TotalHrsID
- elif (Y ==5):
- RemHr = 175 - TotalHrsID
- elif(RemHr <= 12 and i % 2 == 0):
- RemHr = 0
- CR_HRS = 12
- TotalHrsID = TotalHrsID + CR_HRS
- if (i == 1 or i == 2):
- Y=1
- elif (i == 3 or i == 4):
- Y=2
- elif (i == 5 or i == 6):
- Y=3
- elif (i == 7 or i == 8):
- Y=4
- elif (i == 9 or i == 10):
- Y=5
- if (Y ==1):
- RemHr = 35 - TotalHrsID
- elif (Y ==2):
- RemHr = 72 - TotalHrsID
- elif (Y ==3):
- RemHr = 106 - TotalHrsID
- elif (Y ==4):
- RemHr = 140 - TotalHrsID
- elif (Y ==5):
- RemHr = 175 - TotalHrsID
- elif(RemHr > 12 and RemHr <= 20 and i % 2 == 0 ):#must be <=20
- CR_HRS = RemHr
- RemHr = 0
- TotalHrsID = TotalHrsID + CR_HRS
- if (i == 1 or i == 2):
- Y=1
- elif (i == 3 or i == 4):
- Y=2
- elif (i == 5 or i == 6):
- Y=3
- elif (i == 7 or i == 8):
- Y=4
- elif (i == 9 or i == 10):
- Y=5
- if (Y ==1):
- RemHr = 35 - TotalHrsID
- elif (Y ==2):
- RemHr = 72 - TotalHrsID
- elif (Y ==3):
- RemHr = 106 - TotalHrsID
- elif (Y ==4):
- RemHr = 140 - TotalHrsID
- elif (Y ==5):
- RemHr = 175 - TotalHrsID
- elif(RemHr > 20 and i % 2 == 0 ):
- RemHr = 0
- CR_HRS = 20
- if (i == NextTermNo):
- print("not now")
- elif (i == (NextTermNo+1)):
- if(NextSemester):
- if (hr2 < CR_HRS ):
- db = pymysql.connect(host="127.0.0.1",user="root",passwd="",db="registration_system")
- cur7 = db.cursor()
- TookTerms=str(i)
- cur7.execute("SELECT * FROM fixed_studyplan WHERE term <=(%s) ORDER BY term",(TookTerms))
- query_result7 = cur7.fetchall()
- db.close()
- for (j,row) in enumerate(query_result7):
- shouldTakeCourses = pd.DataFrame({'Course':[row[0]],'term':[row[2]]}, index =[j])
- should_Take_Courses = should_Take_Courses.append(shouldTakeCourses)
- should_Take_Courses = should_Take_Courses.drop_duplicates().reset_index(drop=True)
- #should_Take_Courses = should_Take_Courses.sort_index(by=['term'], ascending=[True])
- should_Take_Courses = list(should_Take_Courses.Course)
- remaining = list(set(should_Take_Courses)-set(Courses_Taken_ID)-set(recommended))
- remaining = list(set(remaining)-set(NextSemester))
- CurrentSemester = []
- CurrentSemester.extend(NextSemester)
- NextSemester = []
- hr1=hr2
- HrPerCourse = 0
- totalHrsRec = hr2
- hr2=0
- for (j,row) in enumerate(remaining):
- CourseCredit=CoursesCreditHr.loc[CoursesCreditHr['Course'] == remaining[j]]
- HrPerCourse = int(CourseCredit['CreditHr'])
- totalHrsRec=totalHrsRec+HrPerCourse
- if (totalHrsRec <= CR_HRS):
- CurrentSemester.append(remaining[j])
- hr1 = hr1+HrPerCourse
- elif(totalHrsRec > CR_HRS):
- NextSemester.append(remaining[j])
- hr2 = hr2+HrPerCourse
- totalHrsRec = totalHrsRec - HrPerCourse
- CR_HRS =hr1
- print("Term : "+str(i))
- print(CurrentSemester)
- recommended.extend(CurrentSemester)
- remaining = list(set(remaining)-set(recommended))
- print("with "+str(hr1)+" credit hours")
- elif(hr2 >= CR_HRS):
- print("not now")
- elif(not NextSemester):
- print("not now")
- else:
- if(NextSemester):
- if (hr2 < CR_HRS ):
- db = pymysql.connect(host="127.0.0.1",user="root",passwd="",db="registration_system")
- cur9 = db.cursor()
- TookTerms=str(i)
- cur9.execute("SELECT * FROM fixed_studyplan WHERE term <=(%s) ORDER BY term",(TookTerms))
- query_result9 = cur9.fetchall()
- db.close()
- should_Take_Courses = None
- should_Take_Courses = pd.DataFrame()
- for (j,row) in enumerate(query_result9):
- shouldTakeCourses = pd.DataFrame({'Course':[row[0]],'term':[row[2]]}, index =[j])
- should_Take_Courses = should_Take_Courses.append(shouldTakeCourses)
- should_Take_Courses = should_Take_Courses.drop_duplicates().reset_index(drop=True)
- #should_Take_Courses = should_Take_Courses.sort_index(by=['term'], ascending=[True])
- should_Take_Courses = list(should_Take_Courses.Course)
- CurrentSemester = []
- CurrentSemester.extend(NextSemester)
- remaining = list(set(should_Take_Courses)-set(Courses_Taken_ID)-set(recommended))
- remaining = list(set(remaining)-set(NextSemester))
- NextSemester = []
- hr1=hr2
- HrPerCourse = 0
- totalHrsRec = hr2
- hr2=0
- for (j,row) in enumerate(remaining):
- CourseCredit=CoursesCreditHr.loc[CoursesCreditHr['Course'] == remaining[j]]
- HrPerCourse = int(CourseCredit['CreditHr'])
- totalHrsRec=totalHrsRec+HrPerCourse
- if (totalHrsRec <= CR_HRS):
- CurrentSemester.append(remaining[j])
- hr1 = hr1+HrPerCourse
- elif(totalHrsRec > CR_HRS):
- NextSemester.append(remaining[j])
- hr2 = hr2+HrPerCourse
- totalHrsRec = totalHrsRec - HrPerCourse
- CR_HRS =hr1
- print("Term : "+str(i))
- print(CurrentSemester)
- recommended.extend(CurrentSemester)
- remaining = list(set(remaining)-set(recommended))
- print("with "+str(hr1)+" credit hours")
- elif(hr2 >= CR_HRS):
- print("not now")
- elif(not NextSemester):
- print("not now")
- TotalHrsID = TotalHrsID + CR_HRS
- if (i == 1 or i == 2):
- Y=1
- elif (i == 3 or i == 4):
- Y=2
- elif (i == 5 or i == 6):
- Y=3
- elif (i == 7 or i == 8):
- Y=4
- elif (i == 9 or i == 10):
- Y=5
- if (Y ==1):
- RemHr = 35 - TotalHrsID
- elif (Y ==2):
- RemHr = 72 - TotalHrsID
- elif (Y ==3):
- RemHr = 106 - TotalHrsID
- elif (Y ==4):
- RemHr = 140 - TotalHrsID
- elif (Y ==5):
- RemHr = 175 - TotalHrsID
- elif(not i % 2 == 0 and not i ==3 and (RemHr==0 or RemHr < 0)):
- RemHr = 0
- CR_HRS = 17
- TotalHrsID = TotalHrsID + CR_HRS
- if (i == 1 or i == 2):
- Y=1
- elif (i == 3 or i == 4):
- Y=2
- elif (i == 5 or i == 6):
- Y=3
- elif (i == 7 or i == 8):
- Y=4
- elif (i == 9 or i == 10):
- Y=5
- if (Y ==1):
- RemHr = 35 - TotalHrsID
- elif (Y ==2):
- RemHr = 72 - TotalHrsID
- elif (Y ==3):
- RemHr = 106 - TotalHrsID
- elif (Y ==4):
- RemHr = 140 - TotalHrsID
- elif (Y ==5):
- RemHr = 175 - TotalHrsID
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement