This repository contains a Jupyter Notebook that demonstrates how to predict whether an employee earns more than $100K based on company, job role, and degree. The classification is performed using Decision Trees from the scikit-learn library.
The dataset salaries.csv contains the following columns:
company- Name of the companyjob- Job roledegree- Type of degree heldsalary_more_than_100k- Target variable (1 = Yes, 0 = No)
To run this project, install the required dependencies using:
pip install pandas scikit-learnClone the repository and open the Jupyter Notebook to explore the code and experiment with different inputs.
git clone <your-repository-url>
cd <your-repository-folder>
jupyter notebookimport pandas as pd
from sklearn.preprocessing import LabelEncoder
from sklearn import treedf = pd.read_csv('salaries.csv')
df.head()- Dropping the target column (
salary_more_than_100k) from input features - Encoding categorical variables (
company,job,degree) into numerical format
inputs = df.drop('salary_more_then_100k', axis='columns')
target = df['salary_more_then_100k']
le_company = LabelEncoder()
le_job = LabelEncoder()
le_degree = LabelEncoder()
inputs['company_n'] = le_company.fit_transform(inputs['company'])
inputs['job_n'] = le_job.fit_transform(inputs['job'])
inputs['degree_n'] = le_degree.fit_transform(inputs['degree'])
inputs_n = inputs.drop(['company', 'job', 'degree'], axis='columns')model = tree.DecisionTreeClassifier()
model.fit(inputs_n, target)Predicting whether an employee with specific attributes earns more than $100K:
# Example: Employee from company 2, job role 2, and degree 1
prediction = model.predict([[2, 2, 1]])
print("Prediction:", prediction)# Example: Employee from company 2, job role 0, and degree 1
model.predict([[2, 0, 1]])
# Example: Employee from company 2, job role 0, and degree 0
model.predict([[2, 0, 0]])- The model predicts whether a person earns more than $100K based on company, job, and degree.
- Categorical data is encoded into numerical format for processing.
- The Decision Tree model is used for classification.
Feel free to fork this repository, create a feature branch, and submit a pull request! 🚀
This project is open-source and available under the MIT License.