赞
踩
Toad 是一个用于机器学习建模、预处理和特征工程的 Python 库。以下是 Toad 库版本 0.10 和 0.13 之间的主要区别,包括详细的变化、参数、方法和示例。
初始功能:
示例:
import toad import pandas as pd # 加载数据 data = pd.read_csv('data.csv') # 预处理:处理缺失值 data = toad.fillna(data) # 特征选择:移除高相关性特征 selected_features = toad.selection.select(data, target='target', corr=0.9) # 模型构建:逻辑回归 model = toad.models.LogisticRegression() model.fit(data[selected_features], data['target']) # 模型评估 score = model.score(data[selected_features], data['target']) print(f'模型评分: {score}')
增强的特征选择:
高级预处理:
新算法:
性能改进:
附加工具:
改进的文档:
错误修复和稳定性:
示例:
import toad from toad.transform import MinMaxScaler from toad.selection import select import pandas as pd # 加载数据 data = pd.read_csv('data.csv') # 预处理:处理缺失值 data = toad.fillna(data, strategy='mean') # 数值特征缩放 scaler = MinMaxScaler() data_scaled = scaler.fit_transform(data) # 特征选择:高级标准 selected_features = select(data_scaled, target='target', empty=0.9, iv=0.02, corr=0.9) # 模型构建:新算法(例如,XGBoost) from xgboost import XGBClassifier model = XGBClassifier() model.fit(data_scaled[selected_features], data_scaled['target']) # 模型评估 from sklearn.metrics import accuracy_score predictions = model.predict(data_scaled[selected_features]) accuracy = accuracy_score(data_scaled['target'], predictions) print(f'模型准确率: {accuracy}')
Toad 是一个用于机器学习建模、预处理和特征工程的 Python 库。以下是 Toad 库版本 0.10 和 0.13 之间的主要区别,包括详细的变化、参数、方法和示例。
Toad 0.10:
import toad
selected_features = toad.selection.select(data, target='target', corr=0.9)
Toad 0.13:
from toad.selection import select
selected_features = select(data, target='target', empty=0.9, iv=0.02, corr=0.9)
缺失值填补:
Toad 0.10:
import toad
data = toad.fillna(data)
Toad 0.13:
import toad
data = toad.fillna(data, strategy='mean')
数值特征缩放:
Toad 0.10:
scaler = toad.transform.MinMaxScaler()
data_scaled = scaler.fit_transform(data)
Toad 0.13:
from toad.transform import MinMaxScaler
scaler = MinMaxScaler()
data_scaled = scaler.fit_transform(data)
Toad 0.10:
import toad
model = toad.models.LogisticRegression()
model.fit(data[selected_features], data['target'])
score = model.score(data[selected_features], data['target'])
Toad 0.13:
from xgboost import XGBClassifier
model = XGBClassifier()
model.fit(data_scaled[selected_features], data_scaled['target'])
分箱功能:
Toad 0.10:
Toad 0.13:
toad.transform.WOETransformer
,用于将连续变量转换为分箱变量,并计算每个箱的 WOE(Weight of Evidence)值。from toad.transform import WOETransformer
transformer = WOETransformer()
data_binned = transformer.fit_transform(data, target='target')
特征工程:
Toad 0.10:
Toad 0.13:
from toad.feature_engineering import FeatureCombiner
combiner = FeatureCombiner()
data_combined = combiner.fit_transform(data)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。