|
|
|
""".2146 |
|
|
|
Automatically generated by Colab. |
|
|
|
Original file is located at |
|
https://colab.research.google.com/drive/1zrav0p7dTPU_wC5Hee4bqYFrJU2qMRZw |
|
""" |
|
|
|
|
|
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/employment_trends (1).csv' |
|
df = pd.read_csv(file_path) |
|
|
|
df.head() |
|
|
|
df['REF_DATE'] = pd.to_datetime(df['REF_DATE'], errors = 'coerce') |
|
|
|
missing_values = df.isnull().sum() |
|
missing_values |
|
|
|
sns.histplot(df['VALUE'].dropna(), bins=30, kde=True) |
|
plt.title('Distribution of Employment Values') |
|
plt.xlabel('Employment Value') |
|
plt.ylabel('Frequency') |
|
plt.show() |
|
|
|
plt.figure(figsize=(12, 6)) |
|
sns.countplot(data=df, x='GEO', order=df['GEO'].value_counts().index) |
|
plt.xticks(rotation=90) |
|
plt.title('Employment Trends by Geography') |
|
plt.xlabel('Geography') |
|
plt.ylabel('Count') |
|
plt.show() |
|
|
|
numeric_df = df.select_dtypes(include=[np.number]) |
|
plt.figure(figsize=(10, 8)) |
|
sns.heatmap(numeric_df.corr(), annot=True, cmap='coolwarm', fmt='.2f') |
|
plt.title('Correlation Heatmap') |
|
plt.show() |
|
|
|
from sklearn.model_selection import train_test_split |
|
from sklearn.ensemble import RandomForestRegressor |
|
from sklearn.metrics import mean_squared_error |
|
|
|
df_model = df.dropna(subset=['VALUE']) |
|
X = df_model[['UOM_ID', 'SCALAR_ID', 'DECIMALS']] |
|
y = df_model['VALUE'] |
|
|
|
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) |
|
|
|
model = RandomForestRegressor(n_estimators=100, random_state=42) |
|
model.fit(X_train, y_train) |
|
|
|
y_pred = model.predict(X_test) |
|
mse = mean_squared_error(y_test, y_pred) |
|
rmse = np.sqrt(mse) |
|
rmse |