| |
| """.1393 |
| |
| Automatically generated by Colab. |
| |
| Original file is located at |
| https://colab.research.google.com/drive/1-65IULC0-UxJ7kZBDYo3KQ2a6m5JzwVV |
| """ |
|
|
| |
| import pandas as pd |
| import numpy as np |
| import seaborn as sns |
| import matplotlib.pyplot as plt |
| import warnings |
| warnings.filterwarnings('ignore') |
| |
|
|
| file_path = '/content/Fake Postings (2).csv' |
| df = pd.read_csv(file_path) |
|
|
| df.head() |
|
|
| df.isnull().sum() |
|
|
| sns.countplot(x='fraudulent', data=df) |
| plt.title('Distribution of Fraudulent Job Postings') |
| plt.show() |
|
|
| sns.countplot(y='employment_type', data=df, order=df['employment_type'].value_counts().index) |
| plt.title('Employment Type Distribution') |
| plt.show() |
|
|
| plt.figure(figsize=(10, 8)) |
| sns.countplot(y='industry', data=df, order=df['industry'].value_counts().index[:10]) |
| plt.title('Top 10 Industries by Job Postings') |
| plt.show() |
|
|
| df.fillna('Unknown', inplace=True) |
| df['fraudulent'] = df['fraudulent'].astype(int) |
|
|
| df['description_length'] = df['requirements'].apply(lambda x: len(x.split(','))) |
|
|
| from sklearn.model_selection import train_test_split |
| from sklearn.linear_model import LogisticRegression |
| from sklearn.metrics import accuracy_score, confusion_matrix, classification_report |
|
|
| |
| features = ['description_length', 'num_requirements'] |
| X = df[features] |
| y = df['fraudulent'] |
|
|
| |
| if len(y.unique()) < 2: |
| print("The target variable 'fraudulent' must have at least two classes. Exiting...") |
| else: |
| |
| X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) |
|
|
| |
| model = LogisticRegression() |
| model.fit(X_train, y_train) |