Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,223 @@
|
|
1 |
|
2 |
|
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
import gradio as gr
|
5 |
import pandas as pd
|
6 |
import numpy as np
|
@@ -10,7 +227,6 @@ from datasets import load_dataset
|
|
10 |
import joblib
|
11 |
import requests
|
12 |
|
13 |
-
|
14 |
# Read the data
|
15 |
data = pd.read_csv("mldata.csv")
|
16 |
|
@@ -26,7 +242,7 @@ def load_model(model_choice):
|
|
26 |
else:
|
27 |
raise ValueError("Invalid model selection")
|
28 |
|
29 |
-
# Prepare categorical data
|
30 |
categorical_cols = data[[
|
31 |
'certifications',
|
32 |
'workshops',
|
@@ -41,7 +257,7 @@ for i in categorical_cols:
|
|
41 |
data[i] = data[i].astype('category')
|
42 |
data[i] = data[i].cat.codes
|
43 |
|
44 |
-
# Create reference dictionaries for embeddings
|
45 |
def create_embedding_dict(column):
|
46 |
unique_names = list(categorical_cols[column].unique())
|
47 |
unique_codes = list(data[column].unique())
|
@@ -54,7 +270,44 @@ career_interest_references = create_embedding_dict('interested career area ')
|
|
54 |
company_intends_references = create_embedding_dict('Type of company want to settle in?')
|
55 |
book_interest_references = create_embedding_dict('Interested Type of Books')
|
56 |
|
57 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
def rfprediction(model_choice, name, logical_thinking, hackathon_attend, coding_skills, public_speaking_skills,
|
59 |
self_learning, extra_course, certificate_code, worskhop_code, read_writing_skill, memory_capability,
|
60 |
subject_interest, career_interest, company_intend, senior_elder_advise, book_interest, introvert_extro,
|
@@ -62,7 +315,7 @@ def rfprediction(model_choice, name, logical_thinking, hackathon_attend, coding_
|
|
62 |
# Load the selected model
|
63 |
rfmodel = load_model(model_choice)
|
64 |
|
65 |
-
# Create DataFrame
|
66 |
df = pd.DataFrame.from_dict(
|
67 |
{
|
68 |
"logical_thinking": [logical_thinking],
|
@@ -101,7 +354,7 @@ def rfprediction(model_choice, name, logical_thinking, hackathon_attend, coding_
|
|
101 |
"book_interest": book_interest_references
|
102 |
})
|
103 |
|
104 |
-
# Dummy encoding
|
105 |
userdata_list = df.values.tolist()
|
106 |
|
107 |
# Management-Technical dummy encoding
|
@@ -131,7 +384,7 @@ def rfprediction(model_choice, name, logical_thinking, hackathon_attend, coding_
|
|
131 |
# Prediction
|
132 |
prediction_result_all = rfmodel.predict_proba(userdata_list)
|
133 |
|
134 |
-
# Create result dictionary
|
135 |
result_list = {
|
136 |
"Applications Developer": float(prediction_result_all[0][0]),
|
137 |
"CRM Technical Developer": float(prediction_result_all[0][1]),
|
@@ -146,9 +399,16 @@ def rfprediction(model_choice, name, logical_thinking, hackathon_attend, coding_
|
|
146 |
"UX Designer": float(prediction_result_all[0][10]),
|
147 |
"Web Developer": float(prediction_result_all[0][11]),
|
148 |
}
|
149 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
|
151 |
-
# Lists for dropdown menus
|
152 |
cert_list = ["app development", "distro making", "full stack", "hadoop", "information security", "machine learning", "python", "r programming", "shell programming"]
|
153 |
workshop_list = ["cloud computing", "data science", "database security", "game development", "hacking", "system designing", "testing", "web technologies"]
|
154 |
skill = ["excellent", "medium", "poor"]
|
@@ -159,7 +419,13 @@ book_list = ["Action and Adventure", "Anthology", "Art", "Autobiographies", "Bio
|
|
159 |
Choice_list = ["Management", "Technical"]
|
160 |
worker_list = ["hard worker", "smart worker"]
|
161 |
|
162 |
-
# Create Gradio interface
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
demo = gr.Interface(
|
164 |
fn=rfprediction,
|
165 |
inputs=[
|
@@ -185,36 +451,12 @@ demo = gr.Interface(
|
|
185 |
gr.Dropdown(Choice_list, label="Which area do you prefer: Management or Technical?"),
|
186 |
gr.Dropdown(worker_list, label="Are you a Smart worker or Hard worker?")
|
187 |
],
|
188 |
-
outputs=
|
189 |
-
title="IT-Career Recommendation System: TMI4033
|
190 |
description="Members: Derrick Lim Kin Yeap 74597, Jason Jong Sheng Tat 75125, Jason Ng Yong Xing 75127, Muhamad Hazrie Bin Suhkery 73555 "
|
191 |
)
|
192 |
|
193 |
-
url = "https://jobs-api14.p.rapidapi.com/v2/list"
|
194 |
-
querystring = {
|
195 |
-
"query":"Web Developer",
|
196 |
-
"location":"India",
|
197 |
-
"autoTranslateLocation":"false",
|
198 |
-
"remoteOnly":"false",
|
199 |
-
"employmentTypes":"fulltime;parttime;intern;contractor"
|
200 |
-
}
|
201 |
-
headers = {
|
202 |
-
"x-rapidapi-key": "714f5a2539msh798d996c3243876p19c71ajsnfcd7ce481cb9",
|
203 |
-
"x-rapidapi-host": "jobs-api14.p.rapidapi.com"
|
204 |
-
}
|
205 |
-
|
206 |
-
|
207 |
# Main execution
|
208 |
if __name__ == "__main__":
|
209 |
-
# Fetch job listings before launching the app
|
210 |
-
try:
|
211 |
-
response = requests.get(url, headers=headers, params=querystring)
|
212 |
-
job_listings = response.json()
|
213 |
-
print("Job Listings Retrieved Successfully")
|
214 |
-
# You could potentially store or process job_listings here
|
215 |
-
except requests.RequestException as e:
|
216 |
-
print(f"Error fetching job listings: {e}")
|
217 |
-
|
218 |
demo.launch(share=True)
|
219 |
|
220 |
-
|
|
|
1 |
|
2 |
|
3 |
|
4 |
+
# import gradio as gr
|
5 |
+
# import pandas as pd
|
6 |
+
# import numpy as np
|
7 |
+
# import pickle
|
8 |
+
# import sklearn
|
9 |
+
# from datasets import load_dataset
|
10 |
+
# import joblib
|
11 |
+
# import requests
|
12 |
+
|
13 |
+
|
14 |
+
# # Read the data
|
15 |
+
# data = pd.read_csv("mldata.csv")
|
16 |
+
|
17 |
+
# # Function to load model based on selection
|
18 |
+
# def load_model(model_choice):
|
19 |
+
# if model_choice == "Random Forest":
|
20 |
+
# with open('rfweights (1).pkl', 'rb') as pickleFile:
|
21 |
+
# return pickle.load(pickleFile)
|
22 |
+
# elif model_choice == "Decision Tree":
|
23 |
+
# with open('dtreeweights.pkl', 'rb') as pickleFile:
|
24 |
+
# return pickle.load(pickleFile)
|
25 |
+
|
26 |
+
# else:
|
27 |
+
# raise ValueError("Invalid model selection")
|
28 |
+
|
29 |
+
# # Prepare categorical data (same as original code)
|
30 |
+
# categorical_cols = data[[
|
31 |
+
# 'certifications',
|
32 |
+
# 'workshops',
|
33 |
+
# 'Interested subjects',
|
34 |
+
# 'interested career area ',
|
35 |
+
# 'Type of company want to settle in?',
|
36 |
+
# 'Interested Type of Books'
|
37 |
+
# ]]
|
38 |
+
|
39 |
+
# # Assign category codes
|
40 |
+
# for i in categorical_cols:
|
41 |
+
# data[i] = data[i].astype('category')
|
42 |
+
# data[i] = data[i].cat.codes
|
43 |
+
|
44 |
+
# # Create reference dictionaries for embeddings (same as original code)
|
45 |
+
# def create_embedding_dict(column):
|
46 |
+
# unique_names = list(categorical_cols[column].unique())
|
47 |
+
# unique_codes = list(data[column].unique())
|
48 |
+
# return dict(zip(unique_names, unique_codes))
|
49 |
+
|
50 |
+
# certificates_references = create_embedding_dict('certifications')
|
51 |
+
# workshop_references = create_embedding_dict('workshops')
|
52 |
+
# subjects_interest_references = create_embedding_dict('Interested subjects')
|
53 |
+
# career_interest_references = create_embedding_dict('interested career area ')
|
54 |
+
# company_intends_references = create_embedding_dict('Type of company want to settle in?')
|
55 |
+
# book_interest_references = create_embedding_dict('Interested Type of Books')
|
56 |
+
|
57 |
+
# # Prediction function (modified to accept model choice)
|
58 |
+
# def rfprediction(model_choice, name, logical_thinking, hackathon_attend, coding_skills, public_speaking_skills,
|
59 |
+
# self_learning, extra_course, certificate_code, worskhop_code, read_writing_skill, memory_capability,
|
60 |
+
# subject_interest, career_interest, company_intend, senior_elder_advise, book_interest, introvert_extro,
|
61 |
+
# team_player, management_technical, smart_hardworker):
|
62 |
+
# # Load the selected model
|
63 |
+
# rfmodel = load_model(model_choice)
|
64 |
+
|
65 |
+
# # Create DataFrame (same as original code)
|
66 |
+
# df = pd.DataFrame.from_dict(
|
67 |
+
# {
|
68 |
+
# "logical_thinking": [logical_thinking],
|
69 |
+
# "hackathon_attend": [hackathon_attend],
|
70 |
+
# "coding_skills": [coding_skills],
|
71 |
+
# "public_speaking_skills": [public_speaking_skills],
|
72 |
+
# "self_learning": [self_learning],
|
73 |
+
# "extra_course": [extra_course],
|
74 |
+
# "certificate": [certificate_code],
|
75 |
+
# "workshop": [worskhop_code],
|
76 |
+
# "read_writing_skills": [
|
77 |
+
# (0 if "poor" in read_writing_skill else 1 if "medium" in read_writing_skill else 2)
|
78 |
+
# ],
|
79 |
+
# "memory_capability": [
|
80 |
+
# (0 if "poor" in memory_capability else 1 if "medium" in memory_capability else 2)
|
81 |
+
# ],
|
82 |
+
# "subject_interest": [subject_interest],
|
83 |
+
# "career_interest": [career_interest],
|
84 |
+
# "company_intend": [company_intend],
|
85 |
+
# "senior_elder_advise": [senior_elder_advise],
|
86 |
+
# "book_interest": [book_interest],
|
87 |
+
# "introvert_extro": [introvert_extro],
|
88 |
+
# "team_player": [team_player],
|
89 |
+
# "management_technical":[management_technical],
|
90 |
+
# "smart_hardworker": [smart_hardworker]
|
91 |
+
# }
|
92 |
+
# )
|
93 |
+
|
94 |
+
# # Replace string values with numeric representations
|
95 |
+
# df = df.replace({
|
96 |
+
# "certificate": certificates_references,
|
97 |
+
# "workshop": workshop_references,
|
98 |
+
# "subject_interest": subjects_interest_references,
|
99 |
+
# "career_interest": career_interest_references,
|
100 |
+
# "company_intend": company_intends_references,
|
101 |
+
# "book_interest": book_interest_references
|
102 |
+
# })
|
103 |
+
|
104 |
+
# # Dummy encoding (same as original code)
|
105 |
+
# userdata_list = df.values.tolist()
|
106 |
+
|
107 |
+
# # Management-Technical dummy encoding
|
108 |
+
# if(df["management_technical"].values == "Management"):
|
109 |
+
# userdata_list[0].extend([1])
|
110 |
+
# userdata_list[0].extend([0])
|
111 |
+
# userdata_list[0].remove('Management')
|
112 |
+
# elif(df["management_technical"].values == "Technical"):
|
113 |
+
# userdata_list[0].extend([0])
|
114 |
+
# userdata_list[0].extend([1])
|
115 |
+
# userdata_list[0].remove('Technical')
|
116 |
+
# else:
|
117 |
+
# return "Error in Management-Technical encoding"
|
118 |
+
|
119 |
+
# # Smart-Hard worker dummy encoding
|
120 |
+
# if(df["smart_hardworker"].values == "smart worker"):
|
121 |
+
# userdata_list[0].extend([1])
|
122 |
+
# userdata_list[0].extend([0])
|
123 |
+
# userdata_list[0].remove('smart worker')
|
124 |
+
# elif(df["smart_hardworker"].values == "hard worker"):
|
125 |
+
# userdata_list[0].extend([0])
|
126 |
+
# userdata_list[0].extend([1])
|
127 |
+
# userdata_list[0].remove('hard worker')
|
128 |
+
# else:
|
129 |
+
# return "Error in Smart-Hard worker encoding"
|
130 |
+
|
131 |
+
# # Prediction
|
132 |
+
# prediction_result_all = rfmodel.predict_proba(userdata_list)
|
133 |
+
|
134 |
+
# # Create result dictionary
|
135 |
+
# result_list = {
|
136 |
+
# "Applications Developer": float(prediction_result_all[0][0]),
|
137 |
+
# "CRM Technical Developer": float(prediction_result_all[0][1]),
|
138 |
+
# "Database Developer": float(prediction_result_all[0][2]),
|
139 |
+
# "Mobile Applications Developer": float(prediction_result_all[0][3]),
|
140 |
+
# "Network Security Engineer": float(prediction_result_all[0][4]),
|
141 |
+
# "Software Developer": float(prediction_result_all[0][5]),
|
142 |
+
# "Software Engineer": float(prediction_result_all[0][6]),
|
143 |
+
# "Software Quality Assurance (QA)/ Testing": float(prediction_result_all[0][7]),
|
144 |
+
# "Systems Security Administrator": float(prediction_result_all[0][8]),
|
145 |
+
# "Technical Support": float(prediction_result_all[0][9]),
|
146 |
+
# "UX Designer": float(prediction_result_all[0][10]),
|
147 |
+
# "Web Developer": float(prediction_result_all[0][11]),
|
148 |
+
# }
|
149 |
+
# return result_list
|
150 |
+
|
151 |
+
# # Lists for dropdown menus (same as original code)
|
152 |
+
# cert_list = ["app development", "distro making", "full stack", "hadoop", "information security", "machine learning", "python", "r programming", "shell programming"]
|
153 |
+
# workshop_list = ["cloud computing", "data science", "database security", "game development", "hacking", "system designing", "testing", "web technologies"]
|
154 |
+
# skill = ["excellent", "medium", "poor"]
|
155 |
+
# subject_list = ["cloud computing", "Computer Architecture", "data engineering", "hacking", "IOT", "Management", "networks", "parallel computing", "programming", "Software Engineering"]
|
156 |
+
# career_list = ["Business process analyst", "cloud computing", "developer", "security", "system developer", "testing"]
|
157 |
+
# company_list = ["BPA", "Cloud Services", "Finance", "Product based", "product development", "SAaS services", "Sales and Marketing", "Service Based", "Testing and Maintainance Services", "Web Services"]
|
158 |
+
# book_list = ["Action and Adventure", "Anthology", "Art", "Autobiographies", "Biographies", "Childrens", "Comics","Cookbooks","Diaries","Dictionaries","Drama","Encyclopedias","Fantasy","Guide","Health","History","Horror","Journals","Math","Mystery","Poetry","Prayer books","Religion-Spirituality","Romance","Satire","Science","Science fiction","Self help","Series","Travel","Trilogy"]
|
159 |
+
# Choice_list = ["Management", "Technical"]
|
160 |
+
# worker_list = ["hard worker", "smart worker"]
|
161 |
+
|
162 |
+
# # Create Gradio interface (modified to include model selection)
|
163 |
+
# demo = gr.Interface(
|
164 |
+
# fn=rfprediction,
|
165 |
+
# inputs=[
|
166 |
+
# gr.Dropdown(["Random Forest", "Decision Tree"], label="Select Machine Learning Model"),
|
167 |
+
# gr.Textbox(placeholder="What is your name?", label="Name"),
|
168 |
+
# gr.Slider(minimum=1, maximum=9, value=3, step=1, label="Are you a logical thinking person?", info="Scale: 1 - 9"),
|
169 |
+
# gr.Slider(minimum=0, maximum=6, value=0, step=1, label="Do you attend any Hackathons?", info="Scale: 0 - 6 | 0 - if not attended any"),
|
170 |
+
# gr.Slider(minimum=1, maximum=9, value=5, step=1, label="How do you rate your coding skills?", info="Scale: 1 - 9"),
|
171 |
+
# gr.Slider(minimum=1, maximum=9, value=3, step=1, label="How do you rate your public speaking skills/confidency?", info="Scale: 1 - 9"),
|
172 |
+
# gr.Radio({"Yes", "No"}, type="index", label="Are you a self-learning person? *"),
|
173 |
+
# gr.Radio({"Yes", "No"}, type="index", label="Do you take extra courses in uni (other than IT)? *"),
|
174 |
+
# gr.Dropdown(cert_list, label="Select a certificate you took!"),
|
175 |
+
# gr.Dropdown(workshop_list, label="Select a workshop you attended!"),
|
176 |
+
# gr.Dropdown(skill, label="Select your read and writing skill"),
|
177 |
+
# gr.Dropdown(skill, label="Is your memory capability good?"),
|
178 |
+
# gr.Dropdown(subject_list, label="What subject you are interested in?"),
|
179 |
+
# gr.Dropdown(career_list, label="Which IT-Career do you have interests in?"),
|
180 |
+
# gr.Dropdown(company_list, label="Do you have any interested company that you intend to settle in?"),
|
181 |
+
# gr.Radio({"Yes", "No"}, type="index", label="Do you ever seek any advices from senior or elders? *"),
|
182 |
+
# gr.Dropdown(book_list, label="Select your interested genre of book!"),
|
183 |
+
# gr.Radio({"Yes", "No"}, type="index", label="Are you an Introvert?| No - extrovert *"),
|
184 |
+
# gr.Radio({"Yes", "No"}, type="index", label="Ever worked in a team? *"),
|
185 |
+
# gr.Dropdown(Choice_list, label="Which area do you prefer: Management or Technical?"),
|
186 |
+
# gr.Dropdown(worker_list, label="Are you a Smart worker or Hard worker?")
|
187 |
+
# ],
|
188 |
+
# outputs=gr.Label(num_top_classes=5),
|
189 |
+
# title="IT-Career Recommendation System: TMI4033 Colletive Intelligence, Group 12",
|
190 |
+
# description="Members: Derrick Lim Kin Yeap 74597, Jason Jong Sheng Tat 75125, Jason Ng Yong Xing 75127, Muhamad Hazrie Bin Suhkery 73555 "
|
191 |
+
# )
|
192 |
+
|
193 |
+
# url = "https://jobs-api14.p.rapidapi.com/v2/list"
|
194 |
+
# querystring = {
|
195 |
+
# "query":"Web Developer",
|
196 |
+
# "location":"India",
|
197 |
+
# "autoTranslateLocation":"false",
|
198 |
+
# "remoteOnly":"false",
|
199 |
+
# "employmentTypes":"fulltime;parttime;intern;contractor"
|
200 |
+
# }
|
201 |
+
# headers = {
|
202 |
+
# "x-rapidapi-key": "714f5a2539msh798d996c3243876p19c71ajsnfcd7ce481cb9",
|
203 |
+
# "x-rapidapi-host": "jobs-api14.p.rapidapi.com"
|
204 |
+
# }
|
205 |
+
|
206 |
+
|
207 |
+
# # Main execution
|
208 |
+
# if __name__ == "__main__":
|
209 |
+
# # Fetch job listings before launching the app
|
210 |
+
# try:
|
211 |
+
# response = requests.get(url, headers=headers, params=querystring)
|
212 |
+
# job_listings = response.json()
|
213 |
+
# print("Job Listings Retrieved Successfully")
|
214 |
+
# # You could potentially store or process job_listings here
|
215 |
+
# except requests.RequestException as e:
|
216 |
+
# print(f"Error fetching job listings: {e}")
|
217 |
+
|
218 |
+
# demo.launch(share=True)
|
219 |
+
|
220 |
+
|
221 |
import gradio as gr
|
222 |
import pandas as pd
|
223 |
import numpy as np
|
|
|
227 |
import joblib
|
228 |
import requests
|
229 |
|
|
|
230 |
# Read the data
|
231 |
data = pd.read_csv("mldata.csv")
|
232 |
|
|
|
242 |
else:
|
243 |
raise ValueError("Invalid model selection")
|
244 |
|
245 |
+
# Prepare categorical data
|
246 |
categorical_cols = data[[
|
247 |
'certifications',
|
248 |
'workshops',
|
|
|
257 |
data[i] = data[i].astype('category')
|
258 |
data[i] = data[i].cat.codes
|
259 |
|
260 |
+
# Create reference dictionaries for embeddings
|
261 |
def create_embedding_dict(column):
|
262 |
unique_names = list(categorical_cols[column].unique())
|
263 |
unique_codes = list(data[column].unique())
|
|
|
270 |
company_intends_references = create_embedding_dict('Type of company want to settle in?')
|
271 |
book_interest_references = create_embedding_dict('Interested Type of Books')
|
272 |
|
273 |
+
# Function to fetch job listings
|
274 |
+
def fetch_job_listings(job_title):
|
275 |
+
url = "https://jobs-api14.p.rapidapi.com/v2/list"
|
276 |
+
querystring = {
|
277 |
+
"query": job_title,
|
278 |
+
"location": "India",
|
279 |
+
"autoTranslateLocation": "false",
|
280 |
+
"remoteOnly": "false",
|
281 |
+
"employmentTypes": "fulltime;parttime;intern;contractor"
|
282 |
+
}
|
283 |
+
headers = {
|
284 |
+
"x-rapidapi-key": "714f5a2539msh798d996c3243876p19c71ajsnfcd7ce481cb9",
|
285 |
+
"x-rapidapi-host": "jobs-api14.p.rapidapi.com"
|
286 |
+
}
|
287 |
+
|
288 |
+
try:
|
289 |
+
response = requests.get(url, headers=headers, params=querystring)
|
290 |
+
job_data = response.json()
|
291 |
+
|
292 |
+
# Process and format job listings
|
293 |
+
if job_data.get('jobs'):
|
294 |
+
job_listings = []
|
295 |
+
for job in job_data['jobs'][:5]: # Limit to 5 job listings
|
296 |
+
job_info = {
|
297 |
+
"Job Title": job.get('title', 'N/A'),
|
298 |
+
"Company": job.get('company', 'N/A'),
|
299 |
+
"Location": job.get('location', 'N/A'),
|
300 |
+
"Salary": job.get('salary', 'Not specified')
|
301 |
+
}
|
302 |
+
job_listings.append(job_info)
|
303 |
+
return job_listings
|
304 |
+
else:
|
305 |
+
return [{"Message": "No job listings found for this career path."}]
|
306 |
+
|
307 |
+
except requests.RequestException as e:
|
308 |
+
return [{"Error": f"Could not fetch job listings: {str(e)}"}]
|
309 |
+
|
310 |
+
# Prediction function (modified to return job suggestions)
|
311 |
def rfprediction(model_choice, name, logical_thinking, hackathon_attend, coding_skills, public_speaking_skills,
|
312 |
self_learning, extra_course, certificate_code, worskhop_code, read_writing_skill, memory_capability,
|
313 |
subject_interest, career_interest, company_intend, senior_elder_advise, book_interest, introvert_extro,
|
|
|
315 |
# Load the selected model
|
316 |
rfmodel = load_model(model_choice)
|
317 |
|
318 |
+
# Create DataFrame
|
319 |
df = pd.DataFrame.from_dict(
|
320 |
{
|
321 |
"logical_thinking": [logical_thinking],
|
|
|
354 |
"book_interest": book_interest_references
|
355 |
})
|
356 |
|
357 |
+
# Dummy encoding
|
358 |
userdata_list = df.values.tolist()
|
359 |
|
360 |
# Management-Technical dummy encoding
|
|
|
384 |
# Prediction
|
385 |
prediction_result_all = rfmodel.predict_proba(userdata_list)
|
386 |
|
387 |
+
# Create result dictionary with probabilities
|
388 |
result_list = {
|
389 |
"Applications Developer": float(prediction_result_all[0][0]),
|
390 |
"CRM Technical Developer": float(prediction_result_all[0][1]),
|
|
|
399 |
"UX Designer": float(prediction_result_all[0][10]),
|
400 |
"Web Developer": float(prediction_result_all[0][11]),
|
401 |
}
|
402 |
+
|
403 |
+
# Find the top predicted career
|
404 |
+
top_career = max(result_list, key=result_list.get)
|
405 |
+
|
406 |
+
# Fetch job listings for the top predicted career
|
407 |
+
job_suggestions = fetch_job_listings(top_career)
|
408 |
+
|
409 |
+
return result_list, job_suggestions
|
410 |
|
411 |
+
# Lists for dropdown menus
|
412 |
cert_list = ["app development", "distro making", "full stack", "hadoop", "information security", "machine learning", "python", "r programming", "shell programming"]
|
413 |
workshop_list = ["cloud computing", "data science", "database security", "game development", "hacking", "system designing", "testing", "web technologies"]
|
414 |
skill = ["excellent", "medium", "poor"]
|
|
|
419 |
Choice_list = ["Management", "Technical"]
|
420 |
worker_list = ["hard worker", "smart worker"]
|
421 |
|
422 |
+
# Create Gradio interface
|
423 |
+
def create_output_component():
|
424 |
+
return [
|
425 |
+
gr.Label(label="Career Probabilities"),
|
426 |
+
gr.Dataframe(label="Job Suggestions")
|
427 |
+
]
|
428 |
+
|
429 |
demo = gr.Interface(
|
430 |
fn=rfprediction,
|
431 |
inputs=[
|
|
|
451 |
gr.Dropdown(Choice_list, label="Which area do you prefer: Management or Technical?"),
|
452 |
gr.Dropdown(worker_list, label="Are you a Smart worker or Hard worker?")
|
453 |
],
|
454 |
+
outputs=create_output_component(),
|
455 |
+
title="IT-Career Recommendation System: TMI4033 Collective Intelligence, Group 12",
|
456 |
description="Members: Derrick Lim Kin Yeap 74597, Jason Jong Sheng Tat 75125, Jason Ng Yong Xing 75127, Muhamad Hazrie Bin Suhkery 73555 "
|
457 |
)
|
458 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
459 |
# Main execution
|
460 |
if __name__ == "__main__":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
461 |
demo.launch(share=True)
|
462 |
|
|