myffe 1.0.0__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.
- myffe-1.0.0/LICENSE +21 -0
- myffe-1.0.0/PKG-INFO +525 -0
- myffe-1.0.0/README.md +484 -0
- myffe-1.0.0/myffe/FFE/__init__.py +88 -0
- myffe-1.0.0/myffe/__init__.py +200 -0
- myffe-1.0.0/myffe/core/FFE_config.py +349 -0
- myffe-1.0.0/myffe/core/FFE_console.py +659 -0
- myffe-1.0.0/myffe/core/__init__.py +2 -0
- myffe-1.0.0/myffe/core/master_judge.py +259 -0
- myffe-1.0.0/myffe/docs/param_structure.json +101 -0
- myffe-1.0.0/myffe/docs/param_structure_tree.txt +118 -0
- myffe-1.0.0/myffe/docs/predefined_routes.json +662 -0
- myffe-1.0.0/myffe/docs/predefined_routes_tree.txt +991 -0
- myffe-1.0.0/myffe/preprocessing/__init__.py +21 -0
- myffe-1.0.0/myffe/preprocessing/nan_preprocessing.py +844 -0
- myffe-1.0.0/myffe/preprocessing/normalized_preprocessing.py +166 -0
- myffe-1.0.0/myffe/preprocessing/outlier_preprocessing.py +923 -0
- myffe-1.0.0/myffe/preprocessing/relative_preprocessing.py +967 -0
- myffe-1.0.0/myffe/preprocessing/sample_preprocessing.py +791 -0
- myffe-1.0.0/myffe/preprocessing/specify_preprocessing.py +373 -0
- myffe-1.0.0/myffe/preprocessing/standard_preprocessing.py +399 -0
- myffe-1.0.0/myffe/preprocessing/str_preprocessing.py +1665 -0
- myffe-1.0.0/myffe/preprocessing/time_preprocessing.py +581 -0
- myffe-1.0.0/myffe/route/__init__.py +1 -0
- myffe-1.0.0/myffe/route/py_tools/__init__.py +1 -0
- myffe-1.0.0/myffe/route/py_tools/nan_py.py +212 -0
- myffe-1.0.0/myffe/route/py_tools/normalized_py.py +245 -0
- myffe-1.0.0/myffe/route/py_tools/outlier_py.py +258 -0
- myffe-1.0.0/myffe/route/py_tools/relative_py.py +133 -0
- myffe-1.0.0/myffe/route/py_tools/sample_py.py +443 -0
- myffe-1.0.0/myffe/route/py_tools/specify_py.py +202 -0
- myffe-1.0.0/myffe/route/py_tools/standard_py.py +238 -0
- myffe-1.0.0/myffe/route/py_tools/str_py.py +528 -0
- myffe-1.0.0/myffe/route/py_tools/time_py.py +208 -0
- myffe-1.0.0/myffe/route/src/__init__.py +1 -0
- myffe-1.0.0/myffe/route/src/auto_route.py +348 -0
- myffe-1.0.0/myffe/route/src/predefined_routes.py +1058 -0
- myffe-1.0.0/myffe/route/src/route_config.py +136 -0
- myffe-1.0.0/myffe/tools/Loggerv1_1.py +328 -0
- myffe-1.0.0/myffe/tools/__init__.py +8 -0
- myffe-1.0.0/myffe/tools/color_printer.py +71 -0
- myffe-1.0.0/myffe/tools/data_description.py +238 -0
- myffe-1.0.0/myffe/tools/data_inspector.py +58 -0
- myffe-1.0.0/myffe/tools/evaluation_decorator.py +57 -0
- myffe-1.0.0/myffe/tools/len_match.py +8 -0
- myffe-1.0.0/myffe/tools/param_utils.py +216 -0
- myffe-1.0.0/myffe/tools/system_validator.py +189 -0
- myffe-1.0.0/myffe/tools/unified_config_manager.py +218 -0
- myffe-1.0.0/myffe/tools/visualize_route.py +171 -0
- myffe-1.0.0/myffe/tools//344/272/244/344/272/222/345/274/217.py +177 -0
- myffe-1.0.0/myffe.egg-info/PKG-INFO +525 -0
- myffe-1.0.0/myffe.egg-info/SOURCES.txt +55 -0
- myffe-1.0.0/myffe.egg-info/dependency_links.txt +1 -0
- myffe-1.0.0/myffe.egg-info/requires.txt +4 -0
- myffe-1.0.0/myffe.egg-info/top_level.txt +1 -0
- myffe-1.0.0/setup.cfg +4 -0
- myffe-1.0.0/setup.py +51 -0
myffe-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 myffe
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
myffe-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,525 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: myffe
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Feature Engineering Framework - A comprehensive tool for data preprocessing and feature engineering
|
|
5
|
+
Home-page: https://github.com/yourusername/myffe
|
|
6
|
+
Author: Your Name
|
|
7
|
+
Author-email: your.email@example.com
|
|
8
|
+
Keywords: feature engineering,machine learning,data preprocessing,data cleaning,data science,python
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Intended Audience :: Developers
|
|
20
|
+
Classifier: Intended Audience :: Science/Research
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
|
+
Requires-Python: >=3.7
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: pandas>=1.3.0
|
|
27
|
+
Requires-Dist: numpy>=1.20.0
|
|
28
|
+
Requires-Dist: scikit-learn>=0.24.0
|
|
29
|
+
Requires-Dist: scipy>=1.6.0
|
|
30
|
+
Dynamic: author
|
|
31
|
+
Dynamic: author-email
|
|
32
|
+
Dynamic: classifier
|
|
33
|
+
Dynamic: description
|
|
34
|
+
Dynamic: description-content-type
|
|
35
|
+
Dynamic: home-page
|
|
36
|
+
Dynamic: keywords
|
|
37
|
+
Dynamic: license-file
|
|
38
|
+
Dynamic: requires-dist
|
|
39
|
+
Dynamic: requires-python
|
|
40
|
+
Dynamic: summary
|
|
41
|
+
|
|
42
|
+
# myffe - Feature Engineering Framework
|
|
43
|
+
|
|
44
|
+
myffe 是一个工业级的特征工程框架,提供完整的特征工程工具链,支持数据清洗、特征提取、样本处理等功能。
|
|
45
|
+
|
|
46
|
+
## 特性
|
|
47
|
+
|
|
48
|
+
- **模块化设计**:易于扩展和定制
|
|
49
|
+
- **多种预处理方法**:支持缺失值处理、异常值处理、标准化、归一化等
|
|
50
|
+
- **预定义路线**:提供 20+ 种预定义的特征工程路线
|
|
51
|
+
- **自动参数推荐**:智能推荐最佳预处理参数
|
|
52
|
+
- **工业级封装**:外部接口简洁易用
|
|
53
|
+
- **纯 Python 实现**:无需编译,跨平台兼容
|
|
54
|
+
- **完整的日志系统**:详细记录处理过程
|
|
55
|
+
- **数据评估功能**:评估数据质量和处理效果
|
|
56
|
+
- **可视化支持**:路线可视化和数据描述
|
|
57
|
+
|
|
58
|
+
## 安装
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
pip install myffe
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## 快速开始
|
|
65
|
+
|
|
66
|
+
### 简单使用
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
import pandas as pd
|
|
70
|
+
from myffe import process_data
|
|
71
|
+
|
|
72
|
+
# 读取数据
|
|
73
|
+
data = pd.read_csv('your_data.csv')
|
|
74
|
+
|
|
75
|
+
# 使用预定义路线 1(基础路线)处理数据
|
|
76
|
+
processed_data = process_data(data, data_label='label', route_number=1)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### 高级使用
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
from myffe import FFE
|
|
83
|
+
|
|
84
|
+
# 创建 FFE 实例
|
|
85
|
+
ffe = FFE()
|
|
86
|
+
|
|
87
|
+
# 创建流水线
|
|
88
|
+
console, tools = ffe.create_pipeline('label', route_number=3)
|
|
89
|
+
|
|
90
|
+
# 处理数据
|
|
91
|
+
console(tools, data, save_path='processed_data.csv')
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### 自动推荐路线
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
from myffe import FFE
|
|
98
|
+
|
|
99
|
+
ffe = FFE()
|
|
100
|
+
|
|
101
|
+
# 自动检测数据并推荐路线
|
|
102
|
+
recommended_route = ffe.auto_detect_route(data)
|
|
103
|
+
|
|
104
|
+
# 使用推荐的路线处理数据
|
|
105
|
+
console, tools = ffe.create_pipeline('label', route=recommended_route)
|
|
106
|
+
console(tools, data, save_path='processed_data.csv')
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## 预定义路线
|
|
110
|
+
|
|
111
|
+
myffe 提供 20+ 种预定义路线,适用于不同场景:
|
|
112
|
+
|
|
113
|
+
1. **基础路线** - 适合大多数数据集
|
|
114
|
+
2. **股票数据路线** - 专为股票数据优化
|
|
115
|
+
3. **文本数据路线** - 包含文本处理
|
|
116
|
+
4. **时间序列路线** - 强化时间特征提取
|
|
117
|
+
5. **完整路线** - 包含所有预处理步骤
|
|
118
|
+
6. **轻量级路线** - 快速处理小数据集
|
|
119
|
+
7. **异常检测路线** - 专注于异常值处理
|
|
120
|
+
8. **特征增强路线** - 强化特征工程
|
|
121
|
+
9. **分类数据路线** - 适合分类任务
|
|
122
|
+
10. **回归数据路线** - 适合回归任务
|
|
123
|
+
11. **中文文本路线** - 专为中文文本数据优化
|
|
124
|
+
12. **不平衡数据路线** - 处理类别不平衡的数据集
|
|
125
|
+
13. **高维数据路线** - 处理特征维度较高的数据集
|
|
126
|
+
14. **金融数据路线** - 专为金融数据优化
|
|
127
|
+
15. **医疗数据路线** - 适合医疗数据集的处理
|
|
128
|
+
16. **电商数据路线** - 专为电商数据优化
|
|
129
|
+
17. **社交媒体数据路线** - 处理社交媒体数据
|
|
130
|
+
18. **传感器数据路线** - 处理传感器数据
|
|
131
|
+
19. **多模态数据路线** - 处理包含多种类型数据的数据集
|
|
132
|
+
20. **实时数据路线** - 适合实时数据流处理
|
|
133
|
+
|
|
134
|
+
查看可用路线:
|
|
135
|
+
|
|
136
|
+
```python
|
|
137
|
+
from myffe import show_available_routes
|
|
138
|
+
show_available_routes()
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## 核心模块
|
|
142
|
+
|
|
143
|
+
### 1. 数据预处理 (preprocessing)
|
|
144
|
+
|
|
145
|
+
- **nan_preprocessing** - 缺失值处理
|
|
146
|
+
- 支持多种填充策略:均值、中位数、众数、固定值等
|
|
147
|
+
- 支持按列自定义填充方法
|
|
148
|
+
- 支持缺失值比例统计和可视化
|
|
149
|
+
|
|
150
|
+
- **outlier_preprocessing** - 异常值处理
|
|
151
|
+
- 支持多种异常值检测方法:IQR、Z-score、Isolation Forest等
|
|
152
|
+
- 支持异常值替换或删除
|
|
153
|
+
- 支持异常值统计和可视化
|
|
154
|
+
|
|
155
|
+
- **str_preprocessing** - 字符串处理
|
|
156
|
+
- 支持文本清洗、分词、编码
|
|
157
|
+
- 支持类别特征的one-hot编码
|
|
158
|
+
- 支持文本特征提取
|
|
159
|
+
|
|
160
|
+
- **time_preprocessing** - 时间特征提取
|
|
161
|
+
- 支持日期时间解析
|
|
162
|
+
- 支持时间特征衍生:年、月、日、时、分、秒等
|
|
163
|
+
- 支持时间差计算
|
|
164
|
+
|
|
165
|
+
- **standard_preprocessing** - 数据标准化
|
|
166
|
+
- 支持Z-score标准化
|
|
167
|
+
- 支持Min-Max标准化
|
|
168
|
+
- 支持Robust标准化
|
|
169
|
+
|
|
170
|
+
- **normalized_preprocessing** - 数据归一化
|
|
171
|
+
- 支持L1、L2归一化
|
|
172
|
+
- 支持MaxAbs归一化
|
|
173
|
+
|
|
174
|
+
- **sample_preprocessing** - 样本处理
|
|
175
|
+
- 支持数据采样
|
|
176
|
+
- 支持类别平衡处理
|
|
177
|
+
- 支持数据分割
|
|
178
|
+
|
|
179
|
+
- **relative_preprocessing** - 相对特征处理
|
|
180
|
+
- 支持特征间的相对计算
|
|
181
|
+
- 支持比例特征创建
|
|
182
|
+
|
|
183
|
+
- **specify_preprocessing** - 指定特征处理
|
|
184
|
+
- 支持自定义特征处理逻辑
|
|
185
|
+
- 支持特征选择和变换
|
|
186
|
+
|
|
187
|
+
### 2. 路线配置 (route)
|
|
188
|
+
|
|
189
|
+
- **predefined_routes** - 预定义路线
|
|
190
|
+
- 提供 20+ 种预定义的特征工程路线
|
|
191
|
+
- 支持路线参数获取和可视化
|
|
192
|
+
|
|
193
|
+
- **auto_route** - 自动路线推荐
|
|
194
|
+
- 基于数据特征自动推荐最佳处理路线
|
|
195
|
+
- 支持自定义推荐策略
|
|
196
|
+
|
|
197
|
+
- **route_config** - 路线配置
|
|
198
|
+
- 支持路线参数的配置和管理
|
|
199
|
+
- 支持路线的自定义和扩展
|
|
200
|
+
|
|
201
|
+
### 3. 工具 (tools)
|
|
202
|
+
|
|
203
|
+
- **data_description** - 数据描述
|
|
204
|
+
- 提供详细的数据统计信息
|
|
205
|
+
- 支持数据质量评估
|
|
206
|
+
- 支持数据分布可视化
|
|
207
|
+
|
|
208
|
+
- **data_inspector** - 数据检查
|
|
209
|
+
- 支持数据类型检查
|
|
210
|
+
- 支持缺失值检测
|
|
211
|
+
- 支持异常值检测
|
|
212
|
+
|
|
213
|
+
- **visualize_route** - 路线可视化
|
|
214
|
+
- 支持处理路线的可视化展示
|
|
215
|
+
- 支持处理流程的图形化表示
|
|
216
|
+
|
|
217
|
+
- **logger** - 日志系统
|
|
218
|
+
- 支持多级别日志
|
|
219
|
+
- 支持控制台和文件日志
|
|
220
|
+
- 支持处理过程的详细记录
|
|
221
|
+
|
|
222
|
+
- **color_printer** - 彩色打印
|
|
223
|
+
- 支持彩色输出
|
|
224
|
+
- 支持不同级别的信息展示
|
|
225
|
+
|
|
226
|
+
## 核心接口
|
|
227
|
+
|
|
228
|
+
### FFE 类
|
|
229
|
+
|
|
230
|
+
```python
|
|
231
|
+
class FFE:
|
|
232
|
+
def __init__(self, log_level='info'):
|
|
233
|
+
"""初始化FFE框架
|
|
234
|
+
|
|
235
|
+
Args:
|
|
236
|
+
log_level (str): 日志级别,可选值: 'debug', 'info', 'warning', 'error',默认为'info'
|
|
237
|
+
"""
|
|
238
|
+
|
|
239
|
+
def create_pipeline(self, data_label, route_number=None, route=None, **kwargs):
|
|
240
|
+
"""创建特征工程流水线
|
|
241
|
+
|
|
242
|
+
Args:
|
|
243
|
+
data_label (str): 标签列名称,指定数据中的目标变量列
|
|
244
|
+
route_number (int, optional): 预定义路线编号,1-20之间的整数,默认为None
|
|
245
|
+
route (dict, optional): 自定义路线参数字典,由auto_detect_route生成,默认为None
|
|
246
|
+
**kwargs: 其他参数,如batch_size等
|
|
247
|
+
|
|
248
|
+
Returns:
|
|
249
|
+
tuple: (console, tools) - 控制台实例和预处理工具字典
|
|
250
|
+
"""
|
|
251
|
+
|
|
252
|
+
def auto_detect_route(self, data, label_columns=None, drop_threshold=0.5):
|
|
253
|
+
"""自动检测数据并推荐特征工程路线
|
|
254
|
+
|
|
255
|
+
Args:
|
|
256
|
+
data (DataFrame): 输入数据,pandas DataFrame格式
|
|
257
|
+
label_columns (list, optional): 标签列名称列表,默认为None
|
|
258
|
+
drop_threshold (float, optional): 缺失值阈值,超过此阈值的列会被丢弃,默认为0.5
|
|
259
|
+
|
|
260
|
+
Returns:
|
|
261
|
+
dict: 推荐的特征工程参数字典
|
|
262
|
+
"""
|
|
263
|
+
|
|
264
|
+
def validate_system(self):
|
|
265
|
+
"""验证系统状态
|
|
266
|
+
|
|
267
|
+
Returns:
|
|
268
|
+
dict: 系统状态验证结果,包含各模块的状态信息
|
|
269
|
+
"""
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### 便捷函数
|
|
273
|
+
|
|
274
|
+
- **process_data(data, data_label, route_number=None, route=None, save_path='./processed_data.csv', **kwargs)**
|
|
275
|
+
- 便捷的数据处理函数,一站式完成数据预处理
|
|
276
|
+
- 参数:
|
|
277
|
+
- data (DataFrame): 输入数据,pandas DataFrame格式
|
|
278
|
+
- data_label (str): 标签列名称,指定数据中的目标变量列
|
|
279
|
+
- route_number (int, optional): 预定义路线编号,1-20之间的整数,默认为None
|
|
280
|
+
- route (dict, optional): 自定义路线参数字典,由auto_detect_route生成,默认为None
|
|
281
|
+
- save_path (str): 处理后数据的保存路径,默认为'./processed_data.csv'
|
|
282
|
+
- **kwargs: 其他参数,如batch_size等
|
|
283
|
+
- 返回:处理后的数据,pandas DataFrame格式
|
|
284
|
+
|
|
285
|
+
- **get_recommended_route(data, label_columns=None)**
|
|
286
|
+
- 获取推荐的特征工程路线
|
|
287
|
+
- 参数:
|
|
288
|
+
- data (DataFrame): 输入数据,pandas DataFrame格式
|
|
289
|
+
- label_columns (list, optional): 标签列名称列表,默认为None
|
|
290
|
+
- 返回:推荐的路线参数字典
|
|
291
|
+
|
|
292
|
+
- **show_available_routes()**
|
|
293
|
+
- 显示可用的预定义路线
|
|
294
|
+
- 返回:路线列表,包含所有可用的预定义路线编号和名称
|
|
295
|
+
|
|
296
|
+
- **get_route_params(route_number)**
|
|
297
|
+
- 获取指定路线的参数
|
|
298
|
+
- 参数:
|
|
299
|
+
- route_number (int): 路线编号,1-20之间的整数
|
|
300
|
+
- 返回:路线参数字典,包含该路线的所有预处理步骤和参数
|
|
301
|
+
|
|
302
|
+
- **describe_data(data)**
|
|
303
|
+
- 描述数据,生成详细的数据统计信息
|
|
304
|
+
- 参数:
|
|
305
|
+
- data (DataFrame): 输入数据,pandas DataFrame格式
|
|
306
|
+
- 返回:数据描述信息,包含数据基本信息、质量评估、分布情况等
|
|
307
|
+
|
|
308
|
+
- **evaluate_dataset(data, label_columns=None)**
|
|
309
|
+
- 评估数据集质量
|
|
310
|
+
- 参数:
|
|
311
|
+
- data (DataFrame): 输入数据,pandas DataFrame格式
|
|
312
|
+
- label_columns (list, optional): 标签列名称列表,默认为None
|
|
313
|
+
- 返回:评估指标字典,包含数据完整性、质量、特征质量等多个维度的评估结果
|
|
314
|
+
|
|
315
|
+
- **visualize_route(route)**
|
|
316
|
+
- 可视化路线,展示处理流程
|
|
317
|
+
- 参数:
|
|
318
|
+
- route (dict): 路线参数字典,由get_route_params或auto_detect_route生成
|
|
319
|
+
- 返回:可视化结果,展示路线的处理流程和参数
|
|
320
|
+
|
|
321
|
+
- **set_logging_mode(mode)**
|
|
322
|
+
- 设置全局日志模式
|
|
323
|
+
- 参数:
|
|
324
|
+
- mode (str): 日志模式,可选值: 'None', 'use', 'test'
|
|
325
|
+
- 返回:无
|
|
326
|
+
|
|
327
|
+
- **set_logging_enabled(enabled)**
|
|
328
|
+
- 控制控制台日志输出
|
|
329
|
+
- 参数:
|
|
330
|
+
- enabled (bool): 是否启用控制台输出,True为启用,False为禁用
|
|
331
|
+
- 返回:无
|
|
332
|
+
|
|
333
|
+
- **get_logging_status()**
|
|
334
|
+
- 获取当前日志状态
|
|
335
|
+
- 参数:无
|
|
336
|
+
- 返回:包含日志模式、控制台输出状态和日志文件路径的字典
|
|
337
|
+
|
|
338
|
+
## 使用示例
|
|
339
|
+
|
|
340
|
+
### 示例 1:基础数据处理
|
|
341
|
+
|
|
342
|
+
```python
|
|
343
|
+
import pandas as pd
|
|
344
|
+
from myffe import process_data
|
|
345
|
+
|
|
346
|
+
# 创建示例数据
|
|
347
|
+
data = pd.DataFrame({
|
|
348
|
+
'feature1': [1.0, 2.0, None, 4.0, 5.0],
|
|
349
|
+
'feature2': ['A', 'B', 'A', None, 'C'],
|
|
350
|
+
'label': [0, 1, 0, 1, 0]
|
|
351
|
+
})
|
|
352
|
+
|
|
353
|
+
# 处理数据
|
|
354
|
+
processed = process_data(data, data_label='label', route_number=1)
|
|
355
|
+
print(processed.head())
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
### 示例 2:自定义路线
|
|
359
|
+
|
|
360
|
+
```python
|
|
361
|
+
from myffe import FFE, get_route_params
|
|
362
|
+
|
|
363
|
+
# 获取路线 3 的参数
|
|
364
|
+
params = get_route_params(3)
|
|
365
|
+
|
|
366
|
+
# 创建 FFE 实例
|
|
367
|
+
ffe = FFE()
|
|
368
|
+
|
|
369
|
+
# 创建流水线
|
|
370
|
+
console, tools = ffe.create_pipeline('label', route=params)
|
|
371
|
+
|
|
372
|
+
# 处理数据
|
|
373
|
+
console(tools, data, save_path='output.csv')
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
### 示例 3:数据评估
|
|
377
|
+
|
|
378
|
+
```python
|
|
379
|
+
from myffe import FFE, evaluate_dataset, print_evaluation_result
|
|
380
|
+
|
|
381
|
+
ffe = FFE()
|
|
382
|
+
|
|
383
|
+
# 评估数据集
|
|
384
|
+
metrics = evaluate_dataset(data, label_columns=['label'])
|
|
385
|
+
print_evaluation_result(metrics)
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
### 示例 4:自动推荐路线
|
|
389
|
+
|
|
390
|
+
```python
|
|
391
|
+
from myffe import FFE, process_data
|
|
392
|
+
|
|
393
|
+
# 创建示例数据
|
|
394
|
+
import pandas as pd
|
|
395
|
+
import numpy as np
|
|
396
|
+
data = pd.DataFrame({
|
|
397
|
+
'feature1': np.random.randn(100),
|
|
398
|
+
'feature2': np.random.randint(0, 10, 100),
|
|
399
|
+
'feature3': np.random.choice(['A', 'B', 'C'], 100),
|
|
400
|
+
'feature4': np.random.rand(100),
|
|
401
|
+
'feature5': np.random.randn(100),
|
|
402
|
+
'label': np.random.randint(0, 2, 100)
|
|
403
|
+
})
|
|
404
|
+
# 添加一些缺失值
|
|
405
|
+
data['feature1'][::10] = np.nan
|
|
406
|
+
data['feature4'][::15] = np.nan
|
|
407
|
+
|
|
408
|
+
# 获取推荐路线
|
|
409
|
+
ffe = FFE()
|
|
410
|
+
recommended_route = ffe.auto_detect_route(data, label_columns=['label'])
|
|
411
|
+
print(f"推荐路线: {recommended_route}")
|
|
412
|
+
|
|
413
|
+
# 使用推荐路线处理数据
|
|
414
|
+
processed = process_data(data, data_label='label', route=recommended_route)
|
|
415
|
+
print(f"处理后数据形状: {processed.shape}")
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
### 示例 5:系统验证
|
|
419
|
+
|
|
420
|
+
```python
|
|
421
|
+
from myffe import FFE
|
|
422
|
+
|
|
423
|
+
ffe = FFE()
|
|
424
|
+
|
|
425
|
+
# 验证系统状态
|
|
426
|
+
status = ffe.validate_system()
|
|
427
|
+
print(f"系统状态: {status}")
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
## 日志系统
|
|
431
|
+
|
|
432
|
+
myffe 内置日志系统,支持多种日志模式和控制选项:
|
|
433
|
+
|
|
434
|
+
### 日志模式
|
|
435
|
+
|
|
436
|
+
- **None模式** - 不记录任何日志
|
|
437
|
+
- **use模式** - 生产环境模式,简洁的控制台输出
|
|
438
|
+
- **test模式** - 测试模式,详细的日志记录
|
|
439
|
+
|
|
440
|
+
### 日志控制函数
|
|
441
|
+
|
|
442
|
+
```python
|
|
443
|
+
from myffe import logger, set_logging_enabled, set_logging_mode, get_logging_status
|
|
444
|
+
|
|
445
|
+
# 设置日志模式
|
|
446
|
+
set_logging_mode('use') # 设置为生产环境模式
|
|
447
|
+
set_logging_mode('test') # 设置为测试模式
|
|
448
|
+
set_logging_mode('None') # 禁用日志
|
|
449
|
+
|
|
450
|
+
# 控制控制台输出
|
|
451
|
+
set_logging_enabled(True) # 启用控制台输出
|
|
452
|
+
set_logging_enabled(False) # 禁用控制台输出
|
|
453
|
+
|
|
454
|
+
# 获取当前日志状态
|
|
455
|
+
status = get_logging_status()
|
|
456
|
+
print(f"当前日志模式: {status['mode']}")
|
|
457
|
+
print(f"控制台输出: {status['console_enabled']}")
|
|
458
|
+
print(f"日志文件路径: {status['log_path']}")
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
### 日志文件
|
|
462
|
+
|
|
463
|
+
日志文件默认保存在 `D:\HP\pythonwork\MFM\save_logger\preprocessing.log`
|
|
464
|
+
|
|
465
|
+
### 示例:使用不同日志模式
|
|
466
|
+
|
|
467
|
+
```python
|
|
468
|
+
from myffe import FFE, process_data, set_logging_mode, set_logging_enabled
|
|
469
|
+
import pandas as pd
|
|
470
|
+
import numpy as np
|
|
471
|
+
|
|
472
|
+
# 创建示例数据
|
|
473
|
+
data = pd.DataFrame({
|
|
474
|
+
'feature1': np.random.randn(100),
|
|
475
|
+
'feature2': np.random.randint(0, 10, 100),
|
|
476
|
+
'label': np.random.randint(0, 2, 100)
|
|
477
|
+
})
|
|
478
|
+
|
|
479
|
+
# 测试 None 模式
|
|
480
|
+
print("\n=== 测试 None 模式 ===")
|
|
481
|
+
set_logging_mode('None')
|
|
482
|
+
result = process_data(data, 'label', route_number=1, save_path=None)
|
|
483
|
+
print("处理完成,无日志输出")
|
|
484
|
+
|
|
485
|
+
# 测试 use 模式
|
|
486
|
+
print("\n=== 测试 use 模式 ===")
|
|
487
|
+
set_logging_mode('use')
|
|
488
|
+
set_logging_enabled(True) # 启用控制台输出
|
|
489
|
+
result = process_data(data, 'label', route_number=1, save_path=None)
|
|
490
|
+
|
|
491
|
+
# 测试 test 模式
|
|
492
|
+
print("\n=== 测试 test 模式 ===")
|
|
493
|
+
set_logging_mode('test')
|
|
494
|
+
set_logging_enabled(True) # 启用控制台输出
|
|
495
|
+
result = process_data(data, 'label', route_number=1, save_path=None)
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
## 系统要求
|
|
499
|
+
|
|
500
|
+
- Python >= 3.7
|
|
501
|
+
- pandas >= 1.3.0
|
|
502
|
+
- numpy >= 1.20.0
|
|
503
|
+
- scikit-learn >= 0.24.0
|
|
504
|
+
- scipy >= 1.6.0
|
|
505
|
+
|
|
506
|
+
## 许可证
|
|
507
|
+
|
|
508
|
+
MIT License
|
|
509
|
+
|
|
510
|
+
## 贡献
|
|
511
|
+
|
|
512
|
+
欢迎贡献代码!请提交 Issue 或 Pull Request。
|
|
513
|
+
|
|
514
|
+
## 版本历史
|
|
515
|
+
|
|
516
|
+
- **1.0.0** - 正式发布版本,包含完整的特征工程工具链
|
|
517
|
+
- **3.3.4** - 修复日志系统,添加日志模式控制功能
|
|
518
|
+
- **3.3.2** - 修复导入路径和bug
|
|
519
|
+
- **3.3.1** - 优化自动路线推荐
|
|
520
|
+
- **3.3.0** - 初始版本
|
|
521
|
+
|
|
522
|
+
## 联系方式
|
|
523
|
+
|
|
524
|
+
- Email: your.email@example.com
|
|
525
|
+
- GitHub: https://github.com/yourusername/myffe
|