File size: 2,018 Bytes
07d207a
 
 
 
 
 
 
 
 
0af9978
07d207a
0af9978
07d207a
 
0af9978
 
 
07d207a
0af9978
07d207a
 
 
0af9978
07d207a
0af9978
 
 
 
 
 
07d207a
a944881
07d207a
0af9978
a944881
 
07d207a
a944881
 
 
 
07d207a
 
 
 
 
48692e1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import pandas as pd
import pickle 
import warnings
warnings.filterwarnings("ignore")

with open("static/rf_pipeline.pkl", "rb") as f:
        pipeline2 = pickle.load(f)

data = pd.read_csv("static/zone_course_and_colleges.csv")
df = pd.read_csv("static/final_data_zone.csv")

def get_prediction(college_name, course_name, category, gender, seat_level, round = 1):
    template = pd.DataFrame([[college_name, 
                              course_name, 
                              category, 
                              gender, 
                              seat_level, 
                              2024, 
                              round]], 
                            columns=['college_name', 'course_name', 'category', 'gender', 'seat_level_attribute', 'year', 'round'])
    return pipeline2.predict(template)

def get_colleges(marks, zone, course, category, gender, seat_level, round):
    try:
        row = df[(df["zone"] == zone) & (df["course_name"] == course) & (df["category"] == category) & (df["gender"] == gender) & (df["seat_level_attribute"] ==  seat_level)]
        if row.shape[0] == 0:
             return ["No Seat Found"]
        colleges = list(row["college_name"].unique())
    except Exception as e:
         print("Exception", e)
         return ["Too less to get into"]
    college_data = {}
    for college in colleges:
        prediciton = get_prediction(college, course, category, gender, seat_level, round)
        if prediciton >= 100:
             print(college, prediciton)
        if prediciton <= marks:
            college_code = college.split("-")[0].strip()
            college_name = " ".join(college.split("-")[1:]).strip()
            # college_data.append(college + f"  predicted cut off = {prediciton}")
            college_data[college_name] = {"college_code":college_code, "prediction": prediciton}
    return college_data 

def get_courses_for_zone(zone):
    row = data[data["zone"] == zone.strip()]
    courses = row["course_name"].unique()
    return courses