File size: 1,745 Bytes
13fbe83
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# -*- coding: utf-8 -*-
""".2146

Automatically generated by Colab.

Original file is located at
    https://colab.research.google.com/drive/1zrav0p7dTPU_wC5Hee4bqYFrJU2qMRZw
"""

# Commented out IPython magic to ensure Python compatibility.
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
import warnings
warnings.filterwarnings('ignore')
# %matplotlib inline

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