DanCip commited on
Commit
7f29d04
1 Parent(s): dcb7053

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -25
app.py CHANGED
@@ -77,10 +77,6 @@ def salary(work_year,
77
  job_title,
78
  country)-> str:
79
 
80
- other_param = {}
81
-
82
- other_param['gdp'] = get_gdp_by_country_code(country, work_year, 'NY.GDP.MKTP.CD')
83
- other_param['cpi'] = get_gdp_by_country_code(country, work_year, 'FP.CPI.TOTL')
84
 
85
  jobs = ['analytics_engineer',
86
  'applied_scientist',
@@ -119,7 +115,7 @@ def salary(work_year,
119
  role_flag = {}
120
 
121
  for name in role:
122
- if role in job_title.lower():
123
  role_flag[name]= True
124
  else:
125
  role_flag[name] = False
@@ -138,7 +134,6 @@ def salary(work_year,
138
  'L': 2,
139
  }
140
 
141
- other_param['company_size'] = company_size_dic[company_size]
142
 
143
  experience_level_map = {
144
  'EN': 0,
@@ -147,33 +142,50 @@ def salary(work_year,
147
  'EX': 3
148
  }
149
 
150
- other_param['experience_level'] = experience_level_map[experience_level]
151
 
152
- params = {}
153
 
154
- params.update(other_param)
155
- params.update(jobs_flag)
 
 
 
 
156
  params.update(currency_flag)
157
  params.update(role_flag)
 
 
 
158
 
159
 
160
- df = pd.DataFrame(params)
 
161
  print("Predicting")
162
  print(df)
 
163
 
164
  res = model.predict(df)
165
 
166
  print(f"{labels[res[0]]} $")
167
  return f"{labels[res[0]]} $"
168
 
169
- job_title_options = [
170
- 'Analytics Engineer', 'Applied Scientist', 'BI Developer',
171
- 'Business Intelligence Analyst', 'Business Intelligence Engineer',
172
- 'Data Analyst', 'Data Architect', 'Data Engineer', 'Data Manager',
173
- 'Data Science Consultant', 'Data Science Manager', 'Data Scientist',
174
- 'ML Engineer', 'Machine Learning Engineer', 'Machine Learning Scientist',
175
- 'Research Analyst', 'Research Engineer', 'Research Scientist'
176
- ]
 
 
 
 
 
 
 
 
 
 
177
 
178
  demo = gr.Interface(
179
  fn=salary,
@@ -182,12 +194,12 @@ demo = gr.Interface(
182
  allow_flagging="never",
183
  inputs=[
184
  gr.components.Number(label='work_year'),
185
- gr.components.Select(label='experience_level', options=['EN', 'MI', 'SE', 'EX']),
186
- gr.components.Select(label='company_size', options=['S', 'M', 'L']),
187
- gr.components.Select(label='currency', options=['EUR', 'GBP', 'USD']),
188
- gr.components.Select(label='job_title', options=job_title_options),
189
- gr.components.TextInput(label='country')
190
  ],
191
  outputs=gr.Text())
192
 
193
- demo.launch(debug=True)
 
77
  job_title,
78
  country)-> str:
79
 
 
 
 
 
80
 
81
  jobs = ['analytics_engineer',
82
  'applied_scientist',
 
115
  role_flag = {}
116
 
117
  for name in role:
118
+ if name in job_title.lower():
119
  role_flag[name]= True
120
  else:
121
  role_flag[name] = False
 
134
  'L': 2,
135
  }
136
 
 
137
 
138
  experience_level_map = {
139
  'EN': 0,
 
142
  'EX': 3
143
  }
144
 
 
145
 
 
146
 
147
+
148
+
149
+ params = {}
150
+ params['work_year'] = work_year
151
+ params['experience_level'] = experience_level_map[experience_level]
152
+ params['company_size'] = company_size_dic[company_size]
153
  params.update(currency_flag)
154
  params.update(role_flag)
155
+ params.update(jobs_flag)
156
+ params['gdp'] = get_gdp_by_country_code(country, work_year, 'NY.GDP.MKTP.CD')
157
+ params['cpi'] = get_gdp_by_country_code(country, work_year, 'FP.CPI.TOTL')
158
 
159
 
160
+
161
+ df = pd.DataFrame([params])
162
  print("Predicting")
163
  print(df)
164
+ print(df.columns)
165
 
166
  res = model.predict(df)
167
 
168
  print(f"{labels[res[0]]} $")
169
  return f"{labels[res[0]]} $"
170
 
171
+ job_title_options = ['analytics_engineer',
172
+ 'applied_scientist',
173
+ 'bi_developer',
174
+ 'business_intelligence_analyst',
175
+ 'business_intelligence_engineer',
176
+ 'data_analyst',
177
+ 'data_architect',
178
+ 'data_engineer',
179
+ 'data_manager',
180
+ 'data_science_consultant',
181
+ 'data_science_manager',
182
+ 'data_scientist',
183
+ 'ml_engineer',
184
+ 'machine_learning_engineer',
185
+ 'machine_learning_scientist',
186
+ 'research_analyst',
187
+ 'research_engineer',
188
+ 'research_scientist']
189
 
190
  demo = gr.Interface(
191
  fn=salary,
 
194
  allow_flagging="never",
195
  inputs=[
196
  gr.components.Number(label='work_year'),
197
+ gr.components.Radio(label='experience_level', choices=['EN', 'MI', 'SE', 'EX']),
198
+ gr.components.Radio(label='company_size', choices=['S', 'M', 'L']),
199
+ gr.components.Radio(label='currency', choices=['EUR', 'GBP', 'USD']),
200
+ gr.components.Dropdown(label='job_title', choices=job_title_options),
201
+ gr.components.Textbox(label='country', info='2 letter code', value='US')
202
  ],
203
  outputs=gr.Text())
204
 
205
+ demo.launch(debug=True, share=True)