aigroup-econ-mcp 1.4.3__py3-none-any.whl → 2.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- PKG-INFO +344 -322
- README.md +335 -320
- __init__.py +1 -1
- aigroup_econ_mcp-2.0.1.dist-info/METADATA +732 -0
- aigroup_econ_mcp-2.0.1.dist-info/RECORD +170 -0
- cli.py +4 -0
- econometrics/advanced_methods/modern_computing_machine_learning/__init__.py +30 -0
- econometrics/advanced_methods/modern_computing_machine_learning/causal_forest.py +253 -0
- econometrics/advanced_methods/modern_computing_machine_learning/double_ml.py +268 -0
- econometrics/advanced_methods/modern_computing_machine_learning/gradient_boosting.py +249 -0
- econometrics/advanced_methods/modern_computing_machine_learning/hierarchical_clustering.py +243 -0
- econometrics/advanced_methods/modern_computing_machine_learning/kmeans_clustering.py +293 -0
- econometrics/advanced_methods/modern_computing_machine_learning/neural_network.py +264 -0
- econometrics/advanced_methods/modern_computing_machine_learning/random_forest.py +195 -0
- econometrics/advanced_methods/modern_computing_machine_learning/support_vector_machine.py +226 -0
- econometrics/advanced_methods/modern_computing_machine_learning/test_all_modules.py +329 -0
- econometrics/advanced_methods/modern_computing_machine_learning/test_report.md +107 -0
- econometrics/causal_inference/__init__.py +66 -0
- econometrics/causal_inference/causal_identification_strategy/__init__.py +104 -0
- econometrics/causal_inference/causal_identification_strategy/control_function.py +112 -0
- econometrics/causal_inference/causal_identification_strategy/difference_in_differences.py +107 -0
- econometrics/causal_inference/causal_identification_strategy/event_study.py +119 -0
- econometrics/causal_inference/causal_identification_strategy/first_difference.py +89 -0
- econometrics/causal_inference/causal_identification_strategy/fixed_effects.py +103 -0
- econometrics/causal_inference/causal_identification_strategy/hausman_test.py +69 -0
- econometrics/causal_inference/causal_identification_strategy/instrumental_variables.py +145 -0
- econometrics/causal_inference/causal_identification_strategy/mediation_analysis.py +121 -0
- econometrics/causal_inference/causal_identification_strategy/moderation_analysis.py +109 -0
- econometrics/causal_inference/causal_identification_strategy/propensity_score_matching.py +140 -0
- econometrics/causal_inference/causal_identification_strategy/random_effects.py +100 -0
- econometrics/causal_inference/causal_identification_strategy/regression_discontinuity.py +98 -0
- econometrics/causal_inference/causal_identification_strategy/synthetic_control.py +111 -0
- econometrics/causal_inference/causal_identification_strategy/triple_difference.py +86 -0
- econometrics/distribution_analysis/__init__.py +28 -0
- econometrics/distribution_analysis/oaxaca_blinder.py +184 -0
- econometrics/distribution_analysis/time_series_decomposition.py +152 -0
- econometrics/distribution_analysis/variance_decomposition.py +179 -0
- econometrics/missing_data/__init__.py +18 -0
- econometrics/missing_data/imputation_methods.py +219 -0
- econometrics/nonparametric/__init__.py +35 -0
- econometrics/nonparametric/gam_model.py +117 -0
- econometrics/nonparametric/kernel_regression.py +161 -0
- econometrics/nonparametric/quantile_regression.py +249 -0
- econometrics/nonparametric/spline_regression.py +100 -0
- econometrics/spatial_econometrics/__init__.py +68 -0
- econometrics/spatial_econometrics/geographically_weighted_regression.py +211 -0
- econometrics/spatial_econometrics/gwr_simple.py +154 -0
- econometrics/spatial_econometrics/spatial_autocorrelation.py +356 -0
- econometrics/spatial_econometrics/spatial_durbin_model.py +177 -0
- econometrics/spatial_econometrics/spatial_regression.py +315 -0
- econometrics/spatial_econometrics/spatial_weights.py +226 -0
- econometrics/specific_data_modeling/micro_discrete_limited_data/README.md +164 -0
- econometrics/specific_data_modeling/micro_discrete_limited_data/__init__.py +40 -0
- econometrics/specific_data_modeling/micro_discrete_limited_data/count_data_models.py +311 -0
- econometrics/specific_data_modeling/micro_discrete_limited_data/discrete_choice_models.py +294 -0
- econometrics/specific_data_modeling/micro_discrete_limited_data/limited_dependent_variable_models.py +282 -0
- econometrics/statistical_inference/__init__.py +21 -0
- econometrics/statistical_inference/bootstrap_methods.py +162 -0
- econometrics/statistical_inference/permutation_test.py +177 -0
- econometrics/survival_analysis/__init__.py +18 -0
- econometrics/survival_analysis/survival_models.py +259 -0
- econometrics/tests/causal_inference_tests/__init__.py +3 -0
- econometrics/tests/causal_inference_tests/detailed_test.py +441 -0
- econometrics/tests/causal_inference_tests/test_all_methods.py +418 -0
- econometrics/tests/causal_inference_tests/test_causal_identification_strategy.py +202 -0
- econometrics/tests/causal_inference_tests/test_difference_in_differences.py +53 -0
- econometrics/tests/causal_inference_tests/test_instrumental_variables.py +44 -0
- econometrics/tests/specific_data_modeling_tests/test_micro_discrete_limited_data.py +189 -0
- econometrics//321/206/320/254/320/272/321/205/342/225/235/320/220/321/205/320/237/320/241/321/205/320/264/320/267/321/207/342/226/222/342/225/227/321/204/342/225/235/320/250/321/205/320/225/320/230/321/207/342/225/221/320/267/321/205/320/230/320/226/321/206/320/256/320/240.md +544 -0
- pyproject.toml +9 -2
- server.py +15 -1
- tools/__init__.py +75 -1
- tools/causal_inference_adapter.py +658 -0
- tools/distribution_analysis_adapter.py +121 -0
- tools/gwr_simple_adapter.py +54 -0
- tools/machine_learning_adapter.py +567 -0
- tools/mcp_tool_groups/__init__.py +15 -1
- tools/mcp_tool_groups/causal_inference_tools.py +643 -0
- tools/mcp_tool_groups/distribution_analysis_tools.py +169 -0
- tools/mcp_tool_groups/machine_learning_tools.py +422 -0
- tools/mcp_tool_groups/microecon_tools.py +325 -0
- tools/mcp_tool_groups/missing_data_tools.py +117 -0
- tools/mcp_tool_groups/nonparametric_tools.py +225 -0
- tools/mcp_tool_groups/spatial_econometrics_tools.py +323 -0
- tools/mcp_tool_groups/statistical_inference_tools.py +131 -0
- tools/mcp_tools_registry.py +13 -3
- tools/microecon_adapter.py +412 -0
- tools/missing_data_adapter.py +73 -0
- tools/nonparametric_adapter.py +190 -0
- tools/spatial_econometrics_adapter.py +318 -0
- tools/statistical_inference_adapter.py +90 -0
- tools/survival_analysis_adapter.py +46 -0
- aigroup_econ_mcp-1.4.3.dist-info/METADATA +0 -710
- aigroup_econ_mcp-1.4.3.dist-info/RECORD +0 -92
- {aigroup_econ_mcp-1.4.3.dist-info → aigroup_econ_mcp-2.0.1.dist-info}/WHEEL +0 -0
- {aigroup_econ_mcp-1.4.3.dist-info → aigroup_econ_mcp-2.0.1.dist-info}/entry_points.txt +0 -0
- {aigroup_econ_mcp-1.4.3.dist-info → aigroup_econ_mcp-2.0.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"""
|
|
2
|
+
分布分析与分解方法适配器
|
|
3
|
+
将核心算法适配为MCP工具
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from typing import List, Optional
|
|
7
|
+
import json
|
|
8
|
+
|
|
9
|
+
from econometrics.distribution_analysis import (
|
|
10
|
+
oaxaca_blinder_decomposition,
|
|
11
|
+
variance_decomposition,
|
|
12
|
+
time_series_decomposition,
|
|
13
|
+
OaxacaResult,
|
|
14
|
+
VarianceDecompositionResult,
|
|
15
|
+
TimeSeriesDecompositionResult
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
from .output_formatter import OutputFormatter
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def oaxaca_blinder_adapter(
|
|
22
|
+
y_a: List[float],
|
|
23
|
+
x_a: List[List[float]],
|
|
24
|
+
y_b: List[float],
|
|
25
|
+
x_b: List[List[float]],
|
|
26
|
+
feature_names: Optional[List[str]] = None,
|
|
27
|
+
weight_matrix: str = "pooled",
|
|
28
|
+
output_format: str = "json",
|
|
29
|
+
save_path: Optional[str] = None
|
|
30
|
+
) -> str:
|
|
31
|
+
"""Oaxaca-Blinder分解适配器"""
|
|
32
|
+
|
|
33
|
+
result: OaxacaResult = oaxaca_blinder_decomposition(
|
|
34
|
+
y_a=y_a,
|
|
35
|
+
x_a=x_a,
|
|
36
|
+
y_b=y_b,
|
|
37
|
+
x_b=x_b,
|
|
38
|
+
feature_names=feature_names,
|
|
39
|
+
weight_matrix=weight_matrix
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
if output_format == "json":
|
|
43
|
+
json_result = json.dumps(result.dict(), ensure_ascii=False, indent=2)
|
|
44
|
+
if save_path:
|
|
45
|
+
OutputFormatter.save_to_file(json_result, save_path)
|
|
46
|
+
return f"分析完成!结果已保存到: {save_path}\n\n{json_result}"
|
|
47
|
+
return json_result
|
|
48
|
+
else:
|
|
49
|
+
formatted = f"""# Oaxaca-Blinder分解结果
|
|
50
|
+
|
|
51
|
+
{result.summary}
|
|
52
|
+
"""
|
|
53
|
+
if save_path:
|
|
54
|
+
OutputFormatter.save_to_file(formatted, save_path)
|
|
55
|
+
return formatted
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def variance_decomposition_adapter(
|
|
59
|
+
values: List[float],
|
|
60
|
+
groups: List[str],
|
|
61
|
+
group_names: Optional[List[str]] = None,
|
|
62
|
+
output_format: str = "json",
|
|
63
|
+
save_path: Optional[str] = None
|
|
64
|
+
) -> str:
|
|
65
|
+
"""方差分解适配器"""
|
|
66
|
+
|
|
67
|
+
result: VarianceDecompositionResult = variance_decomposition(
|
|
68
|
+
values=values,
|
|
69
|
+
groups=groups,
|
|
70
|
+
group_names=group_names
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
if output_format == "json":
|
|
74
|
+
json_result = json.dumps(result.dict(), ensure_ascii=False, indent=2)
|
|
75
|
+
if save_path:
|
|
76
|
+
OutputFormatter.save_to_file(json_result, save_path)
|
|
77
|
+
return f"分析完成!结果已保存到: {save_path}\n\n{json_result}"
|
|
78
|
+
return json_result
|
|
79
|
+
else:
|
|
80
|
+
formatted = f"""# 方差分解(ANOVA)结果
|
|
81
|
+
|
|
82
|
+
{result.summary}
|
|
83
|
+
"""
|
|
84
|
+
if save_path:
|
|
85
|
+
OutputFormatter.save_to_file(formatted, save_path)
|
|
86
|
+
return formatted
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def time_series_decomposition_adapter(
|
|
90
|
+
data: List[float],
|
|
91
|
+
period: int = 12,
|
|
92
|
+
model: str = "additive",
|
|
93
|
+
method: str = "classical",
|
|
94
|
+
extrapolate_trend: str = "freq",
|
|
95
|
+
output_format: str = "json",
|
|
96
|
+
save_path: Optional[str] = None
|
|
97
|
+
) -> str:
|
|
98
|
+
"""时间序列分解适配器"""
|
|
99
|
+
|
|
100
|
+
result: TimeSeriesDecompositionResult = time_series_decomposition(
|
|
101
|
+
data=data,
|
|
102
|
+
period=period,
|
|
103
|
+
model=model,
|
|
104
|
+
method=method,
|
|
105
|
+
extrapolate_trend=extrapolate_trend
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
if output_format == "json":
|
|
109
|
+
json_result = json.dumps(result.dict(), ensure_ascii=False, indent=2)
|
|
110
|
+
if save_path:
|
|
111
|
+
OutputFormatter.save_to_file(json_result, save_path)
|
|
112
|
+
return f"分析完成!结果已保存到: {save_path}\n\n{json_result}"
|
|
113
|
+
return json_result
|
|
114
|
+
else:
|
|
115
|
+
formatted = f"""# 时间序列分解结果
|
|
116
|
+
|
|
117
|
+
{result.summary}
|
|
118
|
+
"""
|
|
119
|
+
if save_path:
|
|
120
|
+
OutputFormatter.save_to_file(formatted, save_path)
|
|
121
|
+
return formatted
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"""
|
|
2
|
+
简化的GWR适配器
|
|
3
|
+
避免复杂的类型转换问题
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from typing import List, Optional, Tuple
|
|
7
|
+
import json
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
from econometrics.spatial_econometrics.gwr_simple import (
|
|
11
|
+
geographically_weighted_regression_simple,
|
|
12
|
+
GWRSimpleResult
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
from .output_formatter import OutputFormatter
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def gwr_simple_adapter(
|
|
19
|
+
y_data: List[float],
|
|
20
|
+
x_data: List[List[float]],
|
|
21
|
+
coordinates: List[Tuple[float, float]],
|
|
22
|
+
feature_names: Optional[List[str]] = None,
|
|
23
|
+
kernel_type: str = "gaussian",
|
|
24
|
+
bandwidth: Optional[float] = None,
|
|
25
|
+
fixed: bool = False,
|
|
26
|
+
output_format: str = "json",
|
|
27
|
+
save_path: Optional[str] = None
|
|
28
|
+
) -> str:
|
|
29
|
+
"""简化的地理加权回归适配器"""
|
|
30
|
+
|
|
31
|
+
result: GWRSimpleResult = geographically_weighted_regression_simple(
|
|
32
|
+
y_data=y_data,
|
|
33
|
+
x_data=x_data,
|
|
34
|
+
coordinates=coordinates,
|
|
35
|
+
feature_names=feature_names,
|
|
36
|
+
kernel_type=kernel_type,
|
|
37
|
+
bandwidth=bandwidth,
|
|
38
|
+
fixed=fixed
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
if output_format == "json":
|
|
42
|
+
json_result = json.dumps(result.model_dump(), ensure_ascii=False, indent=2)
|
|
43
|
+
if save_path:
|
|
44
|
+
OutputFormatter.save_to_file(json_result, save_path)
|
|
45
|
+
return f"分析完成!结果已保存到: {save_path}\n\n{json_result}"
|
|
46
|
+
return json_result
|
|
47
|
+
else:
|
|
48
|
+
formatted = f"""# 简化的地理加权回归 (GWR) 结果
|
|
49
|
+
|
|
50
|
+
{result.summary}
|
|
51
|
+
"""
|
|
52
|
+
if save_path:
|
|
53
|
+
OutputFormatter.save_to_file(formatted, save_path)
|
|
54
|
+
return formatted
|