Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,222 +1,6 @@
|
|
| 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
|
|
@@ -319,28 +103,29 @@ def fetch_job_listings(job_title):
|
|
| 319 |
}
|
| 320 |
|
| 321 |
headers = {
|
| 322 |
-
"X-RapidAPI-Key": "
|
| 323 |
"X-RapidAPI-Host": "jobs-api14.p.rapidapi.com"
|
| 324 |
}
|
| 325 |
|
| 326 |
response = requests.get(url, headers=headers, params=querystring)
|
| 327 |
job_data = response.json()
|
| 328 |
|
| 329 |
-
print("RAW RESPONSE:", job_data) #
|
| 330 |
|
| 331 |
-
if job_data.get("
|
| 332 |
job_listings = []
|
| 333 |
-
for job in job_data["
|
| 334 |
job_listings.append([
|
| 335 |
-
job.get("
|
| 336 |
-
job.get("
|
| 337 |
-
job.get("
|
| 338 |
-
job.get("
|
| 339 |
])
|
| 340 |
return job_listings
|
| 341 |
else:
|
| 342 |
return [["No job listings", "found", "for this", "career path"]]
|
| 343 |
|
|
|
|
| 344 |
# Prediction function (modified to return job suggestions)
|
| 345 |
def rfprediction(model_choice, name, logical_thinking, hackathon_attend, coding_skills, public_speaking_skills,
|
| 346 |
self_learning, extra_course, certificate_code, worskhop_code, read_writing_skill, memory_capability,
|
|
|
|
| 1 |
|
| 2 |
|
| 3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
import gradio as gr
|
| 6 |
import pandas as pd
|
|
|
|
| 103 |
}
|
| 104 |
|
| 105 |
headers = {
|
| 106 |
+
"X-RapidAPI-Key": "YOUR_NEW_API_KEY",
|
| 107 |
"X-RapidAPI-Host": "jobs-api14.p.rapidapi.com"
|
| 108 |
}
|
| 109 |
|
| 110 |
response = requests.get(url, headers=headers, params=querystring)
|
| 111 |
job_data = response.json()
|
| 112 |
|
| 113 |
+
print("RAW RESPONSE:", job_data) # keep for now
|
| 114 |
|
| 115 |
+
if job_data.get("data"):
|
| 116 |
job_listings = []
|
| 117 |
+
for job in job_data["data"][:5]:
|
| 118 |
job_listings.append([
|
| 119 |
+
job.get("job_title", "N/A"),
|
| 120 |
+
job.get("employer_name", "N/A"),
|
| 121 |
+
job.get("job_city", "N/A"),
|
| 122 |
+
job.get("job_min_salary", "Not specified")
|
| 123 |
])
|
| 124 |
return job_listings
|
| 125 |
else:
|
| 126 |
return [["No job listings", "found", "for this", "career path"]]
|
| 127 |
|
| 128 |
+
|
| 129 |
# Prediction function (modified to return job suggestions)
|
| 130 |
def rfprediction(model_choice, name, logical_thinking, hackathon_attend, coding_skills, public_speaking_skills,
|
| 131 |
self_learning, extra_course, certificate_code, worskhop_code, read_writing_skill, memory_capability,
|