-
Notifications
You must be signed in to change notification settings - Fork 2
/
eda.py
148 lines (112 loc) · 4.35 KB
/
eda.py
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# Change made on 2024-06-26 20:40:59.440995
import pandas as pd
import numpy as np
from sklearn.linear_model import LinearRegression
# Load the data
data = pd.read_csv('data/countries.csv')
# Filter data for Chile
chile_data = data[data['Country'] == 'Chile']
# Fit a linear regression model to analyze the middle income trap
X = chile_data['Year'].values.reshape(-1, 1)
y = chile_data['GDP_per_capita'].values
model = LinearRegression()
model.fit(X, y)
# Predict future GDP per capita
future_years = np.array([[2023], [2024], [2025]])
predicted_gdp = model.predict(future_years)
print("Predicted GDP per capita for Chile in 2023, 2024, and 2025:")
for year, gdp in zip(future_years.flatten(), predicted_gdp):
print(f"Year: {year}, GDP per capita: {gdp}")
# Change made on 2024-06-26 20:41:04.561091
import pandas as pd
import numpy as np
from sklearn.linear_model import LinearRegression
# Load the data
data = pd.read_csv('data/countries.csv')
# Filter the data for Chile
chile_data = data[data['Country'] == 'Chile']
# Display the data
print(chile_data)
# Perform a linear regression analysis on GDP per capita and time to see if Chile is in the middle income trap
X = chile_data['Year'].values.reshape(-1, 1)
y = chile_data['GDP per capita'].values
model = LinearRegression()
model.fit(X, y)
# Make predictions
preds = model.predict(X)
# Check if Chile is in the middle income trap
if preds[-1] < preds[-2]:
print("Chile seems to be in the middle income trap")
else:
print("Chile does not appear to be in the middle income trap")
# Change made on 2024-06-26 20:41:09.720034
import pandas as pd
# Load the data
data = pd.read_csv('data/countries.csv')
# Filter data for Chile
chile_data = data[data['Country'] == 'Chile']
# Calculate the GDP growth rate for Chile
chile_data['GDP Growth Rate'] = chile_data['GDP'].pct_change()
# Define the middle income trap threshold
middle_income_trap_threshold = 3
# Determine if Chile is stuck in the middle income trap
if chile_data['GDP Growth Rate'].mean() < middle_income_trap_threshold:
print("Chile is stuck in the middle income trap.")
else:
print("Chile is not stuck in the middle income trap.")
# Save the results to a CSV file
chile_data.to_csv('chile_economic_research.csv', index=False)
# Change made on 2024-06-26 20:41:13.445283
import pandas as pd
# Load the data
data = pd.read_csv('data/countries.csv')
# Filter the data to only include information about Chile
chile_data = data[data['Country'] == 'Chile']
# Get the GDP per capita data for Chile
gdp_per_capita = chile_data['GDP per capita']
# Check if Chile is in the middle income trap
if gdp_per_capita.iloc[-1] < 12000:
print("Chile is in the middle income trap")
else:
print("Chile is not in the middle income trap")
# Calculate the average GDP per capita for Chile
average_gdp_per_capita = gdp_per_capita.mean()
print("Average GDP per capita for Chile:", average_gdp_per_capita)
# Change made on 2024-06-26 20:41:17.701589
import pandas as pd
import numpy as np
from sklearn.linear_model import LinearRegression
# Read data from countries.csv file
data = pd.read_csv('data/countries.csv')
# Filter data for Chile
chile_data = data[data['Country'] == 'Chile']
# Define variables for analysis
gdp_per_capita = chile_data['GDP per capita'].values
income_group = chile_data['Income Group'].values
# Check for middle income trap
regression = LinearRegression()
regression.fit(gdp_per_capita.reshape(-1, 1), income_group)
if regression.coef_[0] >= 0:
print("Chile may be at risk of falling into the middle income trap")
else:
print("Chile is showing signs of moving beyond the middle income trap")
# Further analysis and visualization can be done here for the article in the economics journal.
# Change made on 2024-06-26 20:41:22.367530
import pandas as pd
import numpy as np
from sklearn.linear_model import LinearRegression
# Load dataset
data = pd.read_csv('data/countries.csv')
# Filter data for Chile
chile_data = data[data['country'] == 'Chile']
# Calculate GDP growth rate
chile_data['gdp_growth_rate'] = chile_data['gdp'].pct_change() * 100
# Fit linear regression model to determine if Chile is in the middle income trap
X = chile_data['year'].values.reshape(-1, 1)
y = chile_data['gdp'].values
model = LinearRegression()
model.fit(X, y)
if model.coef_[0] < 0:
print("Chile is in the middle income trap")
else:
print("Chile is not in the middle income trap")