aigroup-econ-mcp 0.4.1__tar.gz → 0.4.2__tar.gz

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.

Potentially problematic release.


This version of aigroup-econ-mcp might be problematic. Click here for more details.

Files changed (32) hide show
  1. {aigroup_econ_mcp-0.4.1 → aigroup_econ_mcp-0.4.2}/PKG-INFO +1 -1
  2. {aigroup_econ_mcp-0.4.1 → aigroup_econ_mcp-0.4.2}/pyproject.toml +1 -1
  3. {aigroup_econ_mcp-0.4.1 → aigroup_econ_mcp-0.4.2}/src/aigroup_econ_mcp/__init__.py +1 -1
  4. {aigroup_econ_mcp-0.4.1 → aigroup_econ_mcp-0.4.2}/src/aigroup_econ_mcp/server.py +1 -1
  5. {aigroup_econ_mcp-0.4.1 → aigroup_econ_mcp-0.4.2}/src/aigroup_econ_mcp/tools/base.py +204 -5
  6. {aigroup_econ_mcp-0.4.1 → aigroup_econ_mcp-0.4.2}/src/aigroup_econ_mcp/tools/file_parser.py +273 -4
  7. aigroup_econ_mcp-0.4.2/src/aigroup_econ_mcp/tools/machine_learning.py +60 -0
  8. aigroup_econ_mcp-0.4.2/src/aigroup_econ_mcp/tools/ml_ensemble.py +210 -0
  9. aigroup_econ_mcp-0.4.2/src/aigroup_econ_mcp/tools/ml_evaluation.py +272 -0
  10. aigroup_econ_mcp-0.4.2/src/aigroup_econ_mcp/tools/ml_models.py +54 -0
  11. aigroup_econ_mcp-0.4.2/src/aigroup_econ_mcp/tools/ml_regularization.py +172 -0
  12. {aigroup_econ_mcp-0.4.1 → aigroup_econ_mcp-0.4.2}/src/aigroup_econ_mcp/tools/tool_registry.py +1 -1
  13. aigroup_econ_mcp-0.4.1/src/aigroup_econ_mcp/tools/decorators.py +0 -178
  14. aigroup_econ_mcp-0.4.1/src/aigroup_econ_mcp/tools/file_input_handler.py +0 -268
  15. aigroup_econ_mcp-0.4.1/src/aigroup_econ_mcp/tools/machine_learning.py +0 -673
  16. {aigroup_econ_mcp-0.4.1 → aigroup_econ_mcp-0.4.2}/.gitignore +0 -0
  17. {aigroup_econ_mcp-0.4.1 → aigroup_econ_mcp-0.4.2}/LICENSE +0 -0
  18. {aigroup_econ_mcp-0.4.1 → aigroup_econ_mcp-0.4.2}/README.md +0 -0
  19. {aigroup_econ_mcp-0.4.1 → aigroup_econ_mcp-0.4.2}/src/aigroup_econ_mcp/cli.py +0 -0
  20. {aigroup_econ_mcp-0.4.1 → aigroup_econ_mcp-0.4.2}/src/aigroup_econ_mcp/config.py +0 -0
  21. {aigroup_econ_mcp-0.4.1 → aigroup_econ_mcp-0.4.2}/src/aigroup_econ_mcp/tools/__init__.py +0 -0
  22. {aigroup_econ_mcp-0.4.1 → aigroup_econ_mcp-0.4.2}/src/aigroup_econ_mcp/tools/cache.py +0 -0
  23. {aigroup_econ_mcp-0.4.1 → aigroup_econ_mcp-0.4.2}/src/aigroup_econ_mcp/tools/data_loader.py +0 -0
  24. {aigroup_econ_mcp-0.4.1 → aigroup_econ_mcp-0.4.2}/src/aigroup_econ_mcp/tools/monitoring.py +0 -0
  25. {aigroup_econ_mcp-0.4.1 → aigroup_econ_mcp-0.4.2}/src/aigroup_econ_mcp/tools/optimized_example.py +0 -0
  26. {aigroup_econ_mcp-0.4.1 → aigroup_econ_mcp-0.4.2}/src/aigroup_econ_mcp/tools/panel_data.py +0 -0
  27. {aigroup_econ_mcp-0.4.1 → aigroup_econ_mcp-0.4.2}/src/aigroup_econ_mcp/tools/regression.py +0 -0
  28. {aigroup_econ_mcp-0.4.1 → aigroup_econ_mcp-0.4.2}/src/aigroup_econ_mcp/tools/statistics.py +0 -0
  29. {aigroup_econ_mcp-0.4.1 → aigroup_econ_mcp-0.4.2}/src/aigroup_econ_mcp/tools/time_series.py +0 -0
  30. {aigroup_econ_mcp-0.4.1 → aigroup_econ_mcp-0.4.2}/src/aigroup_econ_mcp/tools/timeout.py +0 -0
  31. {aigroup_econ_mcp-0.4.1 → aigroup_econ_mcp-0.4.2}/src/aigroup_econ_mcp/tools/tool_handlers.py +0 -0
  32. {aigroup_econ_mcp-0.4.1 → aigroup_econ_mcp-0.4.2}/src/aigroup_econ_mcp/tools/validation.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aigroup-econ-mcp
3
- Version: 0.4.1
3
+ Version: 0.4.2
4
4
  Summary: 专业计量经济学MCP工具 - 让大模型直接进行数据分析
5
5
  Project-URL: Homepage, https://github.com/aigroup/aigroup-econ-mcp
6
6
  Project-URL: Repository, https://github.com/aigroup/aigroup-econ-mcp.git
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "aigroup-econ-mcp"
7
- version = "0.4.1"
7
+ version = "0.4.2"
8
8
  description = "专业计量经济学MCP工具 - 让大模型直接进行数据分析"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -10,7 +10,7 @@ AIGroup 计量经济学 MCP 服务
10
10
  - 模型诊断
11
11
  """
12
12
 
13
- __version__ = "0.4.1"
13
+ __version__ = "0.4.2"
14
14
  __author__ = "AIGroup"
15
15
  __description__ = "专业计量经济学MCP工具 - 让大模型直接进行数据分析"
16
16
 
@@ -38,7 +38,7 @@ from .tools.tool_handlers import (
38
38
  )
39
39
 
40
40
  # 导入装饰器
41
- from .tools.decorators import econometric_tool
41
+ from .tools.base import with_file_support_decorator as econometric_tool
42
42
 
43
43
 
44
44
  # 应用上下文
@@ -1,16 +1,26 @@
1
1
  """
2
- 工具模块基类
3
- 提供统一的优化组件集成和错误处理
2
+ 工具模块基类和装饰器
3
+ 整合了工具基类、装饰器、错误处理和优化组件
4
4
  """
5
5
 
6
6
  import functools
7
7
  from typing import Any, Dict, List, Optional, Callable, Type
8
+ from functools import wraps
9
+ from mcp.server.session import ServerSession
10
+ from mcp.server.fastmcp import Context
11
+ from mcp.types import CallToolResult, TextContent
12
+
8
13
  from .validation import ValidationError, validate_econometric_data, validate_model_parameters
9
14
  from .cache import cache_result, cache_model, global_econometric_cache
10
15
  from .monitoring import monitor_performance, track_progress, global_performance_monitor
16
+ from .file_parser import FileParser
11
17
  from ..config import get_config, econometric_config
12
18
 
13
19
 
20
+ # ============================================================================
21
+ # 错误类定义
22
+ # ============================================================================
23
+
14
24
  class EconometricToolError(Exception):
15
25
  """计量经济学工具错误基类"""
16
26
 
@@ -45,6 +55,177 @@ class ConfigurationError(EconometricToolError):
45
55
  pass
46
56
 
47
57
 
58
+ # ============================================================================
59
+ # 装饰器函数
60
+ # ============================================================================
61
+
62
+ def with_file_input(tool_type: str):
63
+ """
64
+ 为工具函数添加文件输入支持的装饰器
65
+
66
+ 支持两种输入方式:
67
+ 1. file_path: CSV/JSON文件路径
68
+ 2. file_content: 文件内容字符串
69
+
70
+ Args:
71
+ tool_type: 工具类型 ('single_var', 'multi_var_dict', 'regression', 'panel', 'time_series')
72
+
73
+ 使用示例:
74
+ @with_file_input('regression')
75
+ async def my_tool(ctx, y_data=None, x_data=None, file_path=None, file_content=None, file_format='auto', **kwargs):
76
+ # 如果提供了file_path或file_content,数据会被自动填充
77
+ pass
78
+ """
79
+ def decorator(func: Callable) -> Callable:
80
+ @wraps(func)
81
+ async def wrapper(*args, **kwargs):
82
+ # 提取上下文和文件参数
83
+ ctx = args[0] if args else kwargs.get('ctx')
84
+ file_path = kwargs.get('file_path')
85
+ file_content = kwargs.get('file_content')
86
+ file_format = kwargs.get('file_format', 'auto')
87
+
88
+ # 优先处理file_path
89
+ if file_path:
90
+ try:
91
+ await ctx.info(f"检测到文件路径输入: {file_path}")
92
+
93
+ # 从文件路径解析
94
+ parsed = FileParser.parse_file_path(file_path, file_format)
95
+
96
+ await ctx.info(
97
+ f"文件解析成功:{parsed['n_variables']}个变量,"
98
+ f"{parsed['n_observations']}个观测"
99
+ )
100
+
101
+ # 转换为工具格式
102
+ converted = FileParser.convert_to_tool_format(parsed, tool_type)
103
+
104
+ # 更新kwargs
105
+ kwargs.update(converted)
106
+
107
+ await ctx.info(f"数据已转换为{tool_type}格式")
108
+
109
+ except Exception as e:
110
+ await ctx.error(f"文件解析失败: {str(e)}")
111
+ return CallToolResult(
112
+ content=[TextContent(type="text", text=f"文件解析错误: {str(e)}")],
113
+ isError=True
114
+ )
115
+
116
+ # 如果没有file_path但有file_content,处理文件内容
117
+ elif file_content:
118
+ try:
119
+ await ctx.info("检测到文件内容输入,开始解析...")
120
+
121
+ # 解析文件内容
122
+ parsed = FileParser.parse_file_content(file_content, file_format)
123
+
124
+ await ctx.info(
125
+ f"文件解析成功:{parsed['n_variables']}个变量,"
126
+ f"{parsed['n_observations']}个观测"
127
+ )
128
+
129
+ # 转换为工具格式
130
+ converted = FileParser.convert_to_tool_format(parsed, tool_type)
131
+
132
+ # 更新kwargs
133
+ kwargs.update(converted)
134
+
135
+ await ctx.info(f"数据已转换为{tool_type}格式")
136
+
137
+ except Exception as e:
138
+ await ctx.error(f"文件解析失败: {str(e)}")
139
+ return CallToolResult(
140
+ content=[TextContent(type="text", text=f"文件解析错误: {str(e)}")],
141
+ isError=True
142
+ )
143
+
144
+ # 调用原函数
145
+ return await func(*args, **kwargs)
146
+
147
+ return wrapper
148
+ return decorator
149
+
150
+
151
+ def with_error_handling(func: Callable) -> Callable:
152
+ """
153
+ 为工具函数添加统一错误处理的装饰器
154
+ """
155
+ @wraps(func)
156
+ async def wrapper(*args, **kwargs):
157
+ ctx = args[0] if args else kwargs.get('ctx')
158
+ tool_name = func.__name__
159
+
160
+ try:
161
+ return await func(*args, **kwargs)
162
+ except Exception as e:
163
+ await ctx.error(f"{tool_name}执行出错: {str(e)}")
164
+ return CallToolResult(
165
+ content=[TextContent(type="text", text=f"错误: {str(e)}")],
166
+ isError=True
167
+ )
168
+
169
+ return wrapper
170
+
171
+
172
+ def with_logging(func: Callable) -> Callable:
173
+ """
174
+ 为工具函数添加日志记录的装饰器
175
+ """
176
+ @wraps(func)
177
+ async def wrapper(*args, **kwargs):
178
+ ctx = args[0] if args else kwargs.get('ctx')
179
+ tool_name = func.__name__
180
+
181
+ await ctx.info(f"开始执行 {tool_name}")
182
+ result = await func(*args, **kwargs)
183
+ await ctx.info(f"{tool_name} 执行完成")
184
+
185
+ return result
186
+
187
+ return wrapper
188
+
189
+
190
+ def with_file_support_decorator(
191
+ tool_type: str,
192
+ enable_error_handling: bool = True,
193
+ enable_logging: bool = True
194
+ ):
195
+ """
196
+ 组合装饰器:为计量经济学工具添加文件支持和其他标准功能
197
+
198
+ Args:
199
+ tool_type: 工具类型
200
+ enable_error_handling: 是否启用错误处理
201
+ enable_logging: 是否启用日志记录
202
+
203
+ 使用示例:
204
+ @with_file_support_decorator('regression')
205
+ async def ols_regression(ctx, y_data=None, x_data=None, **kwargs):
206
+ # 只需要编写核心业务逻辑
207
+ pass
208
+ """
209
+ def decorator(func: Callable) -> Callable:
210
+ wrapped = func
211
+
212
+ if enable_error_handling:
213
+ wrapped = with_error_handling(wrapped)
214
+
215
+ wrapped = with_file_input(tool_type)(wrapped)
216
+
217
+ if enable_logging:
218
+ wrapped = with_logging(wrapped)
219
+
220
+ return wrapped
221
+
222
+ return decorator
223
+
224
+
225
+ # ============================================================================
226
+ # 工具基类
227
+ # ============================================================================
228
+
48
229
  class EconometricTool:
49
230
  """
50
231
  计量经济学工具基类
@@ -206,16 +387,27 @@ class EconometricTool:
206
387
  return global_econometric_cache.result_cache.get_function_cache_stats(self.tool_name) or {}
207
388
 
208
389
 
390
+ # ============================================================================
209
391
  # 便捷装饰器函数
210
- def econometric_tool(tool_name: str = None):
392
+ # ============================================================================
393
+
394
+ def econometric_tool_with_optimization(tool_name: str = None):
211
395
  """
212
- 计量经济学工具装饰器
396
+ 计量经济学工具装饰器(带优化)
397
+
398
+ 应用缓存、性能监控和错误处理
213
399
 
214
400
  Args:
215
401
  tool_name: 工具名称
216
402
 
217
403
  Returns:
218
404
  Callable: 装饰器函数
405
+
406
+ 使用示例:
407
+ @econometric_tool_with_optimization('my_analysis')
408
+ def my_analysis(data):
409
+ # 自动获得缓存、监控和错误处理
410
+ pass
219
411
  """
220
412
  def decorator(func):
221
413
  name = tool_name or func.__name__
@@ -261,11 +453,18 @@ def validate_input(data_type: str = "generic"):
261
453
 
262
454
  # 导出主要类和函数
263
455
  __all__ = [
456
+ # 错误类
264
457
  "EconometricToolError",
265
458
  "DataValidationError",
266
459
  "ModelFittingError",
267
460
  "ConfigurationError",
461
+ # 基类
268
462
  "EconometricTool",
269
- "econometric_tool",
463
+ # 装饰器
464
+ "with_file_input",
465
+ "with_error_handling",
466
+ "with_logging",
467
+ "with_file_support_decorator",
468
+ "econometric_tool_with_optimization",
270
469
  "validate_input"
271
470
  ]
@@ -1,12 +1,13 @@
1
1
  """
2
- 文件解析模块
3
- 支持CSV和JSON格式文件的智能解析和数据转换
2
+ 文件解析与输入处理模块
3
+ 整合了文件解析、数据转换和输入处理功能
4
4
  """
5
5
 
6
6
  import json
7
7
  import csv
8
- from typing import Dict, List, Any, Union, Tuple, Optional
8
+ from typing import Dict, List, Any, Union, Tuple, Optional, Callable
9
9
  from pathlib import Path
10
+ from functools import wraps
10
11
  import io
11
12
  import base64
12
13
 
@@ -540,6 +541,204 @@ class FileParser:
540
541
  return recommendations
541
542
 
542
543
 
544
+ # ============================================================================
545
+ # 文件输入处理组件
546
+ # ============================================================================
547
+
548
+ class FileInputHandler:
549
+ """
550
+ 文件输入处理组件
551
+
552
+ 使用组件模式,为任何工具函数添加文件输入支持
553
+ """
554
+
555
+ @staticmethod
556
+ def process_input(
557
+ file_content: Optional[str],
558
+ file_format: str,
559
+ tool_type: str,
560
+ data_params: Dict[str, Any]
561
+ ) -> Dict[str, Any]:
562
+ """
563
+ 处理文件输入并转换为工具参数
564
+
565
+ Args:
566
+ file_content: 文件内容
567
+ file_format: 文件格式
568
+ tool_type: 工具类型
569
+ data_params: 当前数据参数
570
+
571
+ Returns:
572
+ 更新后的参数字典
573
+ """
574
+ # 如果没有文件输入,直接返回原参数
575
+ if file_content is None:
576
+ return data_params
577
+
578
+ # 解析文件
579
+ parsed = FileParser.parse_file_content(file_content, file_format)
580
+
581
+ # 转换为工具格式
582
+ converted = FileParser.convert_to_tool_format(parsed, tool_type)
583
+
584
+ # 合并参数(文件数据优先)
585
+ result = {**data_params, **converted}
586
+
587
+ return result
588
+
589
+ @staticmethod
590
+ def with_file_support(tool_type: str):
591
+ """
592
+ 装饰器:为工具函数添加文件输入支持
593
+
594
+ Args:
595
+ tool_type: 工具类型(single_var, multi_var_dict, regression, panel等)
596
+
597
+ Returns:
598
+ 装饰后的函数
599
+
600
+ 使用示例:
601
+ @FileInputHandler.with_file_support('regression')
602
+ async def my_regression_tool(y_data, x_data, file_content=None, file_format='auto'):
603
+ # 函数会自动处理file_content并填充y_data和x_data
604
+ pass
605
+ """
606
+ def decorator(func: Callable) -> Callable:
607
+ @wraps(func)
608
+ async def wrapper(*args, **kwargs):
609
+ # 提取文件相关参数
610
+ file_content = kwargs.get('file_content')
611
+ file_format = kwargs.get('file_format', 'auto')
612
+
613
+ if file_content is not None:
614
+ # 处理文件输入
615
+ processed = FileInputHandler.process_input(
616
+ file_content=file_content,
617
+ file_format=file_format,
618
+ tool_type=tool_type,
619
+ data_params=kwargs
620
+ )
621
+
622
+ # 更新kwargs
623
+ kwargs.update(processed)
624
+
625
+ # 调用原函数
626
+ return await func(*args, **kwargs)
627
+
628
+ return wrapper
629
+ return decorator
630
+
631
+
632
+ class FileInputMixin:
633
+ """
634
+ 文件输入混入类
635
+
636
+ 为类提供文件输入处理能力
637
+ """
638
+
639
+ def parse_file_input(
640
+ self,
641
+ file_content: Optional[str],
642
+ file_format: str = "auto"
643
+ ) -> Optional[Dict[str, Any]]:
644
+ """解析文件输入"""
645
+ if file_content is None:
646
+ return None
647
+ return FileParser.parse_file_content(file_content, file_format)
648
+
649
+ def convert_for_tool(
650
+ self,
651
+ parsed_data: Dict[str, Any],
652
+ tool_type: str
653
+ ) -> Dict[str, Any]:
654
+ """转换为工具格式"""
655
+ return FileParser.convert_to_tool_format(parsed_data, tool_type)
656
+
657
+ def get_recommendations(
658
+ self,
659
+ parsed_data: Dict[str, Any]
660
+ ) -> Dict[str, Any]:
661
+ """获取工具推荐"""
662
+ return FileParser.auto_detect_tool_params(parsed_data)
663
+
664
+
665
+ class UnifiedFileInput:
666
+ """
667
+ 统一文件输入接口
668
+
669
+ 所有工具通过此类统一处理文件输入
670
+ """
671
+
672
+ @staticmethod
673
+ async def handle(
674
+ ctx: Any,
675
+ file_content: Optional[str],
676
+ file_format: str,
677
+ tool_type: str,
678
+ original_params: Dict[str, Any]
679
+ ) -> Dict[str, Any]:
680
+ """
681
+ 统一处理文件输入
682
+
683
+ Args:
684
+ ctx: MCP上下文
685
+ file_content: 文件内容
686
+ file_format: 文件格式
687
+ tool_type: 工具类型
688
+ original_params: 原始参数
689
+
690
+ Returns:
691
+ 处理后的参数
692
+ """
693
+ if file_content is None:
694
+ return original_params
695
+
696
+ try:
697
+ # 记录日志
698
+ await ctx.info("检测到文件输入,开始解析...")
699
+
700
+ # 解析文件
701
+ parsed = FileParser.parse_file_content(file_content, file_format)
702
+
703
+ # 记录解析结果
704
+ await ctx.info(
705
+ f"文件解析成功:{parsed['n_variables']}个变量,"
706
+ f"{parsed['n_observations']}个观测,"
707
+ f"数据类型={parsed['data_type']}"
708
+ )
709
+
710
+ # 转换为工具格式
711
+ converted = FileParser.convert_to_tool_format(parsed, tool_type)
712
+
713
+ # 合并参数
714
+ result = {**original_params}
715
+ result.update(converted)
716
+
717
+ # 记录转换结果
718
+ if tool_type == 'regression':
719
+ await ctx.info(
720
+ f"数据已转换:因变量={converted.get('y_variable')},"
721
+ f"自变量={converted.get('feature_names')}"
722
+ )
723
+ elif tool_type == 'panel':
724
+ await ctx.info(
725
+ f"面板数据已识别:{len(set(converted.get('entity_ids', [])))}个实体,"
726
+ f"{len(set(converted.get('time_periods', [])))}个时间点"
727
+ )
728
+ else:
729
+ await ctx.info(f"数据已转换为{tool_type}格式")
730
+
731
+ return result
732
+
733
+ except Exception as e:
734
+ await ctx.error(f"文件解析失败: {str(e)}")
735
+ raise ValueError(f"文件解析失败: {str(e)}")
736
+
737
+
738
+ # ============================================================================
739
+ # 便捷函数和参数定义
740
+ # ============================================================================
741
+
543
742
  def parse_file_input(
544
743
  file_content: Optional[str] = None,
545
744
  file_format: str = "auto"
@@ -557,4 +756,74 @@ def parse_file_input(
557
756
  if file_content is None:
558
757
  return None
559
758
 
560
- return FileParser.parse_file_content(file_content, file_format)
759
+ return FileParser.parse_file_content(file_content, file_format)
760
+
761
+
762
+ async def process_file_for_tool(
763
+ ctx: Any,
764
+ file_content: Optional[str],
765
+ file_format: str,
766
+ tool_type: str,
767
+ **kwargs
768
+ ) -> Dict[str, Any]:
769
+ """
770
+ 为工具处理文件输入的便捷函数
771
+
772
+ 使用示例:
773
+ params = await process_file_for_tool(
774
+ ctx=ctx,
775
+ file_
776
+ content=file_content,
777
+ file_format=file_format,
778
+ tool_type='regression',
779
+ y_data=y_data,
780
+ x_data=x_data,
781
+ feature_names=feature_names
782
+ )
783
+ # params 现在包含处理后的所有参数
784
+ """
785
+ return await UnifiedFileInput.handle(
786
+ ctx=ctx,
787
+ file_content=file_content,
788
+ file_format=file_format,
789
+ tool_type=tool_type,
790
+ original_params=kwargs
791
+ )
792
+
793
+
794
+ def create_file_params(
795
+ description: str = "CSV或JSON文件内容"
796
+ ) -> Dict[str, Any]:
797
+ """
798
+ 创建标准的文件输入参数定义
799
+
800
+ Args:
801
+ description: 参数描述
802
+
803
+ Returns:
804
+ 参数定义字典,可直接用于Field()
805
+ """
806
+ return {
807
+ "file_content": {
808
+ "default": None,
809
+ "description": f"""{description}
810
+
811
+ 📁 支持格式:
812
+ - CSV: 带表头的列数据,自动检测分隔符
813
+ - JSON: {{"变量名": [数据], ...}} 或 [{{"变量1": 值, ...}}, ...]
814
+
815
+ 💡 使用方式:
816
+ - 提供文件内容字符串(可以是base64编码)
817
+ - 系统会自动解析并识别变量
818
+ - 优先使用file_content,如果提供则忽略其他数据参数"""
819
+ },
820
+ "file_format": {
821
+ "default": "auto",
822
+ "description": """文件格式
823
+
824
+ 可选值:
825
+ - "auto": 自动检测(默认)
826
+ - "csv": CSV格式
827
+ - "json": JSON格式"""
828
+ }
829
+ }
@@ -0,0 +1,60 @@
1
+ """
2
+ 机器学习集成模块 - 统一导出接口
3
+ 提供基于scikit-learn的机器学习算法,用于经济数据分析
4
+
5
+ 此模块作为统一入口,导出所有机器学习相关功能:
6
+ - ml_models: 数据模型定义
7
+ - ml_ensemble: 集成学习方法(随机森林、梯度提升树)
8
+ - ml_regularization: 正则化回归(Lasso、Ridge)
9
+ - ml_evaluation: 评估和比较功能
10
+ """
11
+
12
+ # 导入数据模型
13
+ from .ml_models import (
14
+ MLModelResult,
15
+ RandomForestResult,
16
+ GradientBoostingResult,
17
+ RegularizedRegressionResult,
18
+ CrossValidationResult,
19
+ FeatureImportanceResult
20
+ )
21
+
22
+ # 导入集成学习方法
23
+ from .ml_ensemble import (
24
+ random_forest_regression,
25
+ gradient_boosting_regression
26
+ )
27
+
28
+ # 导入正则化回归
29
+ from .ml_regularization import (
30
+ lasso_regression,
31
+ ridge_regression
32
+ )
33
+
34
+ # 导入评估和比较功能
35
+ from .ml_evaluation import (
36
+ cross_validation,
37
+ feature_importance_analysis,
38
+ compare_ml_models
39
+ )
40
+
41
+ # 导出所有公共接口
42
+ __all__ = [
43
+ # 数据模型
44
+ "MLModelResult",
45
+ "RandomForestResult",
46
+ "GradientBoostingResult",
47
+ "RegularizedRegressionResult",
48
+ "CrossValidationResult",
49
+ "FeatureImportanceResult",
50
+ # 集成学习
51
+ "random_forest_regression",
52
+ "gradient_boosting_regression",
53
+ # 正则化回归
54
+ "lasso_regression",
55
+ "ridge_regression",
56
+ # 评估和比较
57
+ "cross_validation",
58
+ "feature_importance_analysis",
59
+ "compare_ml_models"
60
+ ]