staran 0.2.4__py3-none-any.whl → 0.3.0__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.
staran/__init__.py CHANGED
@@ -154,18 +154,18 @@ SQL工具:
154
154
  from .tools import Date
155
155
  from .features import (
156
156
  TableSchema, FeatureGenerator, FeatureManager, FeatureTableManager,
157
- FeatureConfig, DatabaseType
157
+ FeatureConfig, DatabaseType, FeatureType, Field, FieldType
158
158
  )
159
- from .engines import SparkEngine, HiveEngine, create_engine
159
+ from .engines import SparkEngine, HiveEngine, TuringEngine, BaseEngine, create_engine, create_turing_engine
160
+
161
+ # 示例模块
162
+ from .examples import create_aum_example, run_aum_example
160
163
 
161
164
  # 图灵平台引擎 (可选导入,避免依赖问题)
162
165
  try:
163
- from .engines import TuringEngine, create_turing_engine
164
166
  from .features import quick_create_and_download
165
167
  _TURING_AVAILABLE = True
166
168
  except ImportError:
167
- TuringEngine = None
168
- create_turing_engine = None
169
169
  quick_create_and_download = None
170
170
  _TURING_AVAILABLE = False
171
171
 
@@ -179,12 +179,21 @@ __all__ = [
179
179
  'TableSchema',
180
180
  'FeatureGenerator',
181
181
  'FeatureConfig',
182
+ 'FeatureType',
183
+ 'Field',
184
+ 'FieldType',
182
185
  'FeatureManager',
183
186
  'FeatureTableManager',
184
187
  'DatabaseType',
188
+ 'BaseEngine',
185
189
  'SparkEngine',
186
190
  'HiveEngine',
191
+ 'TuringEngine',
187
192
  'create_engine',
193
+ 'create_turing_engine',
194
+ # 示例模块
195
+ 'create_aum_example',
196
+ 'run_aum_example',
188
197
  # 向后兼容
189
198
  'SQLManager',
190
199
  'SparkSQLGenerator'
@@ -193,15 +202,13 @@ __all__ = [
193
202
  # 如果图灵引擎可用,添加到导出列表
194
203
  if _TURING_AVAILABLE:
195
204
  __all__.extend([
196
- 'TuringEngine',
197
- 'create_turing_engine',
198
205
  'quick_create_and_download'
199
206
  ])
200
207
 
201
208
  # 包信息
202
- __version__ = '2.0.0'
209
+ __version__ = '0.2.4'
203
210
  __author__ = 'Staran Team'
204
- __description__ = 'Smart feature engineering toolkit with modular engine architecture'
211
+ __description__ = 'Smart feature engineering toolkit with modular engine architecture and examples'
205
212
  __license__ = 'MIT'
206
213
 
207
214
  # 便捷函数示例
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: staran
3
- Version: 0.2.4
3
+ Version: 0.3.0
4
4
  Summary: staran - 高性能Python工具库
5
5
  Home-page: https://github.com/starlxa/staran
6
6
  Author: StarAn
@@ -30,7 +30,7 @@ Dynamic: summary
30
30
 
31
31
  Staran是一个强大的特征工程和数据处理工具包,提供从数据到模型的完整解决方案。特别针对工银图灵平台优化,让特征工程和模型训练变得前所未有的简单。
32
32
 
33
- ## ✨ v0.2.4 新特性
33
+ ## ✨ v0.3.0 新特性
34
34
 
35
35
  - �️ **模块化引擎架构** - 独立的引擎模块,支持Spark、Hive、图灵平台
36
36
  - 🔧 **统一接口设计** - 所有引擎提供一致的SQL生成、执行和下载接口
@@ -315,7 +315,7 @@ tomorrow = date.add_days(1) # 202504 (智能处理)
315
315
 
316
316
  ```
317
317
  staran/
318
- ├── __init__.py # 主包入口,v0.2.4功能导出
318
+ ├── __init__.py # 主包入口,v0.3.0功能导出
319
319
  ├── engines/ # 🆕 模块化引擎架构
320
320
  │ ├── __init__.py # 引擎模块入口
321
321
  │ ├── base.py # BaseEngine抽象基类
@@ -327,11 +327,14 @@ staran/
327
327
  │ ├── manager.py # FeatureManager (使用引擎架构)
328
328
  │ ├── schema.py # 表结构定义
329
329
  │ └── generator.py # 特征生成器
330
+ ├── examples/ # 🆕 完整示例模块
331
+ │ ├── __init__.py # 示例模块入口
332
+ │ └── aum_longtail.py # AUM代发长尾模型示例
330
333
  ├── tools/
331
334
  │ ├── __init__.py # 工具模块
332
335
  │ └── date.py # Date类实现
333
336
  ├── setup.py # 安装配置
334
- ├── README.md # 本文档 v0.2.4
337
+ ├── README.md # 本文档 v0.3.0
335
338
  └── quick-upload.sh # 快速部署脚本
336
339
  ```
337
340
 
@@ -355,27 +358,26 @@ sql = turing.generate_sql("SELECT user_id, amount FROM users", {"table": "test"}
355
358
  print(f"SQL生成测试: {'success' if sql else 'failed'}")
356
359
  ```
357
360
 
358
- ### 特征工程测试
361
+ ### AUM示例测试
359
362
  ```python
360
- from staran import TableSchema, FeatureManager
363
+ from staran import create_aum_example
361
364
 
362
- # 定义表结构
363
- schema = TableSchema('user_stats')
364
- schema.add_primary_key('user_id', 'string')
365
- schema.add_date_field('date', 'date')
366
- schema.add_field('amount', 'decimal', aggregatable=True)
367
- schema.set_monthly_unique(True)
365
+ # 创建示例并查看摘要
366
+ example = create_aum_example("dwegdata03000")
367
+ example.print_summary()
368
368
 
369
- # 创建管理器(使用引擎架构)
370
- manager = FeatureManager(engine_type='spark', database='analytics_db')
369
+ # 快速运行(测试模式,不执行实际SQL)
370
+ print("🎯 AUM长尾模型示例已准备就绪")
371
+ print("📊 包含4张业务表的完整特征工程流程")
372
+ ```
371
373
 
372
- # 生成特征并查看摘要
373
- summary = manager.get_feature_summary(schema)
374
- print(f"生成特征数: {summary['total']}")
374
+ ### 一键运行示例
375
+ ```python
376
+ from staran import run_aum_example
375
377
 
376
- # 生成聚合特征SQL
377
- result = manager.generate_feature_by_type(schema, 'aggregation', 2025, 7)
378
- print("SQL长度:", len(result['sql']))
378
+ # 最简单的使用方式
379
+ results = run_aum_example("202507") # 指定特征月份
380
+ print(f" 处理完成: {len(results)} 个表")
379
381
  ```
380
382
 
381
383
  ### Date工具测试
@@ -408,21 +410,38 @@ print(f"✅ 继承关系: 继承自{turing.__class__.__bases__[0].__name__}")
408
410
  print("🚀 环境就绪!开始特征工程之旅")
409
411
  ```
410
412
 
411
- ### 2. 完整ML流程
413
+ ### 2. 运行AUM示例
412
414
  ```python
413
- # 使用新引擎架构进行特征工程
414
- from staran import FeatureManager
415
-
416
- # 创建基于Turing引擎的特征管理器
417
- manager = FeatureManager(engine_type='turing', database='production_analytics')
415
+ # 最简单的方式 - 一行代码完成复杂特征工程
416
+ from staran import run_aum_example
418
417
 
419
- # 执行SQL并下载结果
420
- result = manager.execute_and_download(
421
- sql="SELECT user_id, features FROM ml_features WHERE dt='2025-07-28'",
422
- output_path="file:///nfsHome/ml_pipeline/"
418
+ results = run_aum_example(
419
+ feature_date="202507", # 特征月份
420
+ database="dwegdata03000", # 数据库名
421
+ output_path="file:///nfsHome/aum_features" # 输出路径
423
422
  )
424
423
 
425
- print(f"✅ 成功!使用{manager.engine.__class__.__name__}完成数据处理")
424
+ print(f"✅ 成功!处理了4张表,生成了完整的特征数据集")
425
+ print("📂 数据已保存到 /nfsHome/aum_features/ 目录")
426
+ ```
427
+
428
+ ### 3. 自定义特征工程
429
+ ```python
430
+ # 如需更多控制,使用详细API
431
+ from staran import create_aum_example
432
+
433
+ example = create_aum_example("dwegdata03000")
434
+
435
+ # 查看会生成哪些特征
436
+ example.print_summary()
437
+
438
+ # 运行特征工程
439
+ results = example.run("202507")
440
+
441
+ # 查看结果
442
+ for table_type, result in results.items():
443
+ if 'table_name' in result:
444
+ print(f"{table_type}: {result['table_name']}")
426
445
  ```
427
446
 
428
447
  ## 📊 性能优势
@@ -437,10 +456,58 @@ print(f"✅ 成功!使用{manager.engine.__class__.__name__}完成数据处理
437
456
  - **批量处理**: 并行下载和增量处理
438
457
  - **错误恢复**: 自动重试和断点续传
439
458
 
459
+ ## 🎯 完整示例
460
+
461
+ ### AUM代发长尾模型 - 简化API
462
+ 位置:`staran.examples` 模块
463
+
464
+ 基于真实金融业务场景的完整特征工程示例,展示了新的引擎架构优势:
465
+
466
+ ```python
467
+ # 最简单的使用方式
468
+ from staran import run_aum_example
469
+
470
+ # 一键运行完整特征工程流程
471
+ results = run_aum_example(
472
+ feature_date="202507", # 可选,默认当前月
473
+ database="dwegdata03000",
474
+ output_path="file:///nfsHome/aum_longtail"
475
+ )
476
+
477
+ print(f"✅ 特征工程完成!处理了 {len(results)} 个表")
478
+ ```
479
+
480
+ **更多控制的方式:**
481
+ ```python
482
+ from staran import create_aum_example
483
+
484
+ # 创建示例实例
485
+ example = create_aum_example("dwegdata03000")
486
+
487
+ # 查看特征摘要
488
+ example.print_summary()
489
+
490
+ # 运行特征工程
491
+ results = example.run("202507")
492
+ ```
493
+
494
+ **示例特点:**
495
+ - 🏦 **真实业务场景** - 4张银行核心业务表的完整处理
496
+ - 🔧 **智能特征配置** - A表(源表+聚合),其他表(全特征:环比5个月+同比1年)
497
+ - 📊 **多维度特征** - 客户行为、资产配置、交易统计、境外交易等
498
+ - 🚀 **简化API** - 一行代码完成复杂特征工程
499
+ - 📋 **完整文档** - 每个字段都有详细的业务含义说明
500
+
501
+ **数据表说明:**
502
+ - **A表** (`bi_hlwj_dfcw_f1_f4_wy`): 客户行为特征 → 仅生成原始拷贝+聚合特征
503
+ - **B表** (`bi_hlwj_zi_chan_avg_wy`): 资产平均余额 → 生成全部特征(聚合+环比5个月+同比1年)
504
+ - **C表** (`bi_hlwj_zi_chang_month_total_zb`): 月度资产配置 → 生成全部特征
505
+ - **D表** (`bi_hlwj_realy_month_stat_wy`): 月度实际统计 → 生成全部特征
506
+
440
507
  ## 📄 许可证
441
508
 
442
509
  MIT License
443
510
 
444
511
  ---
445
512
 
446
- **Staran v0.2.4** - 模块化引擎架构,让机器学习特征工程变得前所未有的简单 🌟
513
+ **Staran v0.3.0** - 模块化引擎架构,让机器学习特征工程变得前所未有的简单 🌟
@@ -0,0 +1,8 @@
1
+ staran/__init__.py,sha256=ia3Hu8bJDy9_MMv1otR659qxvtxsEWQ-JceSLxdiY3g,6945
2
+ staran/tools/__init__.py,sha256=KtudrYnxKD9HZEL4H-mrWlKrmsI3rYjJrLeC9YDTpG4,1054
3
+ staran/tools/date.py,sha256=-QyEMWVx6czMuOIwcV7kR3gBMRVOwb5qevo7GEFSJKE,10488
4
+ staran-0.3.0.dist-info/licenses/LICENSE,sha256=2EmsBIyDCono4iVXNpv5_px9qt2b7hfPq1WuyGVMNP4,1361
5
+ staran-0.3.0.dist-info/METADATA,sha256=jaYgW3F7ZpDcoJSDG0VA9jhEEqAJ3wuSfhqRv9UFvKs,16573
6
+ staran-0.3.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
+ staran-0.3.0.dist-info/top_level.txt,sha256=NOUZtXSh5oSIEjHrC0lQ9WmoKtD010Q00dghWyag-Zs,7
8
+ staran-0.3.0.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- staran/__init__.py,sha256=wUE__5gRPVTm7Epdrc9cskI2VtgbmhCnGr63TE482dg,6768
2
- staran/tools/__init__.py,sha256=KtudrYnxKD9HZEL4H-mrWlKrmsI3rYjJrLeC9YDTpG4,1054
3
- staran/tools/date.py,sha256=-QyEMWVx6czMuOIwcV7kR3gBMRVOwb5qevo7GEFSJKE,10488
4
- staran-0.2.4.dist-info/licenses/LICENSE,sha256=2EmsBIyDCono4iVXNpv5_px9qt2b7hfPq1WuyGVMNP4,1361
5
- staran-0.2.4.dist-info/METADATA,sha256=4LPrB-WKoZ7AGGHon0uA1kZDDaHeX8zv1prSXuJYWwc,14510
6
- staran-0.2.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
- staran-0.2.4.dist-info/top_level.txt,sha256=NOUZtXSh5oSIEjHrC0lQ9WmoKtD010Q00dghWyag-Zs,7
8
- staran-0.2.4.dist-info/RECORD,,
File without changes