-
-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6dbfb65
commit 864f888
Showing
26 changed files
with
493 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.venv |
File renamed without changes.
File renamed without changes.
Binary file not shown.
Binary file added
BIN
+622 KB
DataAnalyticsSalaryPrediction/Images/Screenshot 2024-08-03 at 12.46.57 AM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+652 KB
DataAnalyticsSalaryPrediction/Images/Screenshot 2024-08-03 at 12.47.27 AM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
File renamed without changes.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pandas | ||
numpy | ||
scikit-learn | ||
tensorflow | ||
matplotlib | ||
keras |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
## Data Analysis Salary Prediction - Web Interface | ||
|
||
### Goal 🎯 | ||
|
||
The main goal of this project is to provide an easy-to-use web interface for predicting Salary of various job posts accross India based on user input parameters. This tool aims to make salary predition accessible to non-technical users by integrating a machine learning model with a user-friendly Flask web application. | ||
|
||
### Model(s) used for the Web App 🧮 | ||
|
||
The backend part of the web app uses a pre-trained machine learning model (`../Model`) serialized with `pickle`. The model was trained on a dataset of body measurements and is designed to predict body fat percentage accurately. | ||
|
||
### Video Demonstration 🎥 | ||
|
||
|
||
|
||
### Signature ✒️ | ||
|
||
Developed by [Akshaykumar](https://github.com/MRMORNINGSTAR2233) | ||
|
||
- [GitHub](https://github.com/MRMORNINGSTAR2233) | ||
- [LinkedIn](https://www.linkedin.com/in/akshay-kumar-hegde/) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import os | ||
import pickle | ||
import numpy as np | ||
from flask import Flask, request, jsonify, render_template | ||
from sklearn.preprocessing import OneHotEncoder, StandardScaler | ||
import pandas as pd | ||
import tensorflow as tf | ||
from tensorflow.keras.models import Sequential | ||
from tensorflow.keras.layers import Dense, Dropout, Input | ||
|
||
|
||
app = Flask(__name__) | ||
|
||
def create_model(optimizer='adam'): | ||
model = Sequential() | ||
model.add(Input(shape=(X_resampled.shape[1],))) # Assuming X_resampled.shape[1] is known | ||
model.add(Dense(128, activation='relu', kernel_regularizer=tf.keras.regularizers.l2(0.01))) | ||
model.add(Dropout(0.5)) | ||
model.add(Dense(64, activation='relu', kernel_regularizer=tf.keras.regularizers.l2(0.01))) | ||
model.add(Dropout(0.5)) | ||
model.add(Dense(32, activation='relu', kernel_regularizer=tf.keras.regularizers.l2(0.01))) | ||
model.add(Dense(5, activation='softmax')) | ||
model.compile(optimizer=optimizer, loss='sparse_categorical_crossentropy', metrics=['accuracy']) | ||
return model | ||
|
||
# Load the trained model | ||
with open('/Users/akshay/Desktop/ML-Crate/DataAnalyticsSalaryPrediction/Model/model1', 'rb') as file: | ||
model = pickle.load(file) | ||
|
||
# Load the encoder and scaler | ||
with open('/Users/akshay/Desktop/ML-Crate/DataAnalyticsSalaryPrediction/Model/encoder.pkl', 'rb') as file: | ||
encoder = pickle.load(file) | ||
|
||
with open('/Users/akshay/Desktop/ML-Crate/DataAnalyticsSalaryPrediction/Model/scaler.pkl', 'rb') as file: | ||
scaler = pickle.load(file) | ||
|
||
# Preprocessing function | ||
def preprocess_input(data): | ||
df = pd.DataFrame(data, index=[0]) | ||
df_encoded = encoder.transform(df) | ||
df_scaled = scaler.transform(df_encoded) | ||
return df_scaled | ||
|
||
@app.route('/') | ||
def home(): | ||
return render_template('index.html') | ||
|
||
@app.route('/predict', methods=['POST']) | ||
def predict(): | ||
data = request.get_json() | ||
input_data = preprocess_input(data) | ||
prediction = model.predict(input_data) | ||
return jsonify({'prediction': int(prediction[0])}) | ||
|
||
if __name__ == '__main__': | ||
app.run(debug=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Salary Prediction</title> | ||
<style> | ||
body { | ||
font-family: Arial, sans-serif; | ||
background-color: #f4f4f4; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
.container { | ||
width: 50%; | ||
margin: 50px auto; | ||
background: #fff; | ||
padding: 20px; | ||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); | ||
} | ||
|
||
h1 { | ||
text-align: center; | ||
} | ||
|
||
form { | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
label { | ||
margin: 10px 0 5px; | ||
} | ||
|
||
input { | ||
padding: 10px; | ||
font-size: 16px; | ||
} | ||
|
||
button { | ||
padding: 10px; | ||
background: #28a745; | ||
color: #fff; | ||
border: none; | ||
margin-top: 20px; | ||
cursor: pointer; | ||
} | ||
|
||
button:hover { | ||
background: #218838; | ||
} | ||
|
||
#result { | ||
margin-top: 20px; | ||
font-size: 18px; | ||
text-align: center; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<div class="container"> | ||
<h1>Salary Prediction</h1> | ||
<form id="prediction-form"> | ||
<label for="company_name">Company Name:</label> | ||
<input type="text" id="company_name" name="Company Name" required> | ||
|
||
<label for="job_title">Job Title:</label> | ||
<input type="text" id="job_title" name="Job Title" required> | ||
|
||
<label for="location">Location:</label> | ||
<input type="text" id="location" name="Location" required> | ||
|
||
<button type="submit">Predict Salary</button> | ||
</form> | ||
<div id="result"></div> | ||
</div> | ||
<script> | ||
document.getElementById('prediction-form').addEventListener('submit', function (e) { | ||
e.preventDefault(); | ||
|
||
const companyName = document.getElementById('company_name').value; | ||
const jobTitle = document.getElementById('job_title').value; | ||
const location = document.getElementById('location').value; | ||
|
||
const data = { | ||
"Company Name": companyName, | ||
"Job Title": jobTitle, | ||
"Location": location | ||
}; | ||
|
||
fetch('/predict', { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
body: JSON.stringify(data) | ||
}) | ||
.then(response => response.json()) | ||
.then(data => { | ||
let salaryRange = ''; | ||
switch (data.prediction) { | ||
case 0: | ||
salaryRange = 'greater than 50k'; | ||
break; | ||
case 1: | ||
salaryRange = 'greater than 1 lakh'; | ||
break; | ||
case 2: | ||
salaryRange = 'greater than 10 lakh'; | ||
break; | ||
case 3: | ||
salaryRange = 'greater than 15 lakh'; | ||
break; | ||
case 4: | ||
salaryRange = 'greater than 20 lakh'; | ||
break; | ||
default: | ||
salaryRange = 'unknown'; | ||
} | ||
document.getElementById('result').innerText = `Predicted Salary Range: ${salaryRange}`; | ||
}) | ||
.catch(error => { | ||
console.error('Error:', error); | ||
}); | ||
|
||
}); | ||
</script> | ||
</body> | ||
|
||
</html> |