ArchiMathur commited on
Commit
87e08d6
·
verified ·
1 Parent(s): b253402

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -14
app.py CHANGED
@@ -10,16 +10,10 @@ import requests
10
  # Read the data
11
  data = pd.read_csv("mldata.csv")
12
 
13
- # Function to load model based on selection
14
- def load_model(model_choice):
15
- if model_choice == "Random Forest":
16
- with open('rfweights.pkl', 'rb') as pickleFile:
17
- return pickle.load(pickleFile)
18
- elif model_choice == "Decision Tree":
19
- with open('dtreeweights.pkl', 'rb') as pickleFile:
20
- return pickle.load(pickleFile)
21
- else:
22
- raise ValueError("Invalid model selection")
23
 
24
  # Prepare categorical data
25
  categorical_cols = data[[
@@ -216,14 +210,14 @@ def fetch_job_listings(job_title):
216
  ]
217
 
218
  # Prediction function (modified to return job suggestions)
219
- def rfprediction(model_choice, name, logical_thinking, hackathon_attend, coding_skills, public_speaking_skills,
220
  self_learning, extra_course, certificate_code, worskhop_code, read_writing_skill, memory_capability,
221
  subject_interest, career_interest, company_intend, senior_elder_advise, book_interest, introvert_extro,
222
  team_player, management_technical, smart_hardworker):
223
 
224
  try:
225
- # Load the selected model
226
- rfmodel = load_model(model_choice)
227
 
228
  # Create DataFrame
229
  df = pd.DataFrame({
@@ -347,7 +341,6 @@ def create_output_component():
347
  demo = gr.Interface(
348
  fn=rfprediction,
349
  inputs=[
350
- gr.Dropdown(["Random Forest", "Decision Tree"], label="Select Machine Learning Model"),
351
  gr.Textbox(placeholder="What is your name?", label="Name"),
352
  gr.Slider(minimum=1, maximum=9, value=3, step=1, label="Are you a logical thinking person?", info="Scale: 1 - 9"),
353
  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"),
 
10
  # Read the data
11
  data = pd.read_csv("mldata.csv")
12
 
13
+ # Function to load model
14
+ def load_model():
15
+ with open('rfweights.pkl', 'rb') as pickleFile:
16
+ return pickle.load(pickleFile)
 
 
 
 
 
 
17
 
18
  # Prepare categorical data
19
  categorical_cols = data[[
 
210
  ]
211
 
212
  # Prediction function (modified to return job suggestions)
213
+ def rfprediction(name, logical_thinking, hackathon_attend, coding_skills, public_speaking_skills,
214
  self_learning, extra_course, certificate_code, worskhop_code, read_writing_skill, memory_capability,
215
  subject_interest, career_interest, company_intend, senior_elder_advise, book_interest, introvert_extro,
216
  team_player, management_technical, smart_hardworker):
217
 
218
  try:
219
+ # Load the Random Forest model
220
+ rfmodel = load_model()
221
 
222
  # Create DataFrame
223
  df = pd.DataFrame({
 
341
  demo = gr.Interface(
342
  fn=rfprediction,
343
  inputs=[
 
344
  gr.Textbox(placeholder="What is your name?", label="Name"),
345
  gr.Slider(minimum=1, maximum=9, value=3, step=1, label="Are you a logical thinking person?", info="Scale: 1 - 9"),
346
  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"),