| |
| """1040_249_949 |
| |
| Automatically generated by Colab. |
| |
| Original file is located at |
| https://colab.research.google.com/drive/1T8VCDZs5tRg-mTI4qNqCct_92fcd_7Rl |
| """ |
|
|
| import pandas as pd |
| import matplotlib.pyplot as plt |
| import seaborn as sns |
| import numpy as np |
| import warnings as w |
| w.filterwarnings('ignore') |
|
|
| df=pd.read_csv('//content/1000_ml_jobs_us.csv') |
|
|
| df.head() |
|
|
| df.isnull().sum() |
|
|
| df.drop(columns=['company_website', 'company_description', 'job_description_text', 'Unnamed: 0'], inplace=True) |
|
|
| df['company_address_locality'] = df['company_address_locality'].fillna(df['company_address_locality'].mode()[0]) |
| df['company_address_region'] = df['company_address_region'].fillna(df['company_address_region'].mode()[0]) |
| df['seniority_level'] = (df['seniority_level'].fillna(df['seniority_level']).mode()[0]) |
|
|
| df.info() |
|
|
| df['job_posted_date'] = pd.to_datetime(df['job_posted_date']) |
|
|
| df['company_address_locality'].value_counts().head(10).plot(kind='bar', title='Top 10 Localities') |
|
|
| df['company_address_region'].value_counts().head(10).plot(kind='bar', title='Top 10 Regions') |
|
|
| df['company_name'].value_counts().head(10).plot(kind='barh', title='Top 10 Hiring Companies') |
|
|
| df['seniority_level'].value_counts().plot(kind='pie', autopct='%1.1f%%', title='Seniority Level Distribution') |
|
|
| df['job_title'].value_counts().head(15).plot(kind='bar', title='Top 15 Job Titles') |
|
|
| import pandas as pd |
| from sklearn.preprocessing import LabelEncoder |
| from sklearn.model_selection import train_test_split |
| from sklearn.ensemble import RandomForestClassifier |
| from sklearn.metrics import classification_report, accuracy_score |
| import warnings as w |
| w.filterwarnings('ignore') |
|
|
| |
| |
| |
|
|
| le = LabelEncoder() |
|
|
| |
| for col in ['job_posted_date', 'company_address_locality', 'company_address_region', 'company_name', 'job_title']: |
| df[col] = le.fit_transform(df[col].astype(str)) |
|
|
| |
| X = df.drop('seniority_level', axis=1) |
| y = le.fit_transform(df['seniority_level']) |
|
|
| |
| X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) |
|
|
| |
| model = RandomForestClassifier(random_state=42) |
| model.fit(X_train, y_train) |
|
|
| |
| y_pred = model.predict(X_test) |
|
|
| print("Accuracy:", accuracy_score(y_test, y_pred)) |
| print(classification_report(y_test, y_pred)) |