The sklearn preprocessing
Recently, I was writing module of feature engineering, i found two excellently packages -- tsfresh and sklearn.
tsfresh has been specialized for data of time series, tsfresh mainly include two modules, feature extract, and feature select:
1 from tsfresh import feature_selection, feature_extraction
To limit the number of irrelevant features tsfresh deploys the fresh algorithms. The whole process consists of three steps.
Firstly. the algorithm characterizes time series with comprehensive and well-established feature mappings. the feature calculators used to derive the features are contained in tsfresh.feature_extraction.feature_calculators.
In a second step, each extracted feature vector is individually and evaluated with respect to its significance for predicting the target under investigation, those tests are contained in submodule tsfresh.feature_selection.significance_tests. the result of a significance test is a vector of p-value, quantifying the significance of each feature for predicting the target.
Finally, the vector of p-value is evaluated base on basis of the Benjamini-Yekutieli procedure in order to decide which feature could keep.
In summary, the tsfresh is a scalable and efficiency tool of feature engineering.
although the function of tsfresh was powerful, i choose sklearn.
I download data which is the heart disease data set. the data set target is binary and has a 13 dimension feature, I was just used MinMaxScaler to transform age,trestbps,chol three columns, the model had a choiced ensemble of AutoSklearnClassifer and ensemble of RandomForest. but bad performance for two models.
from sklearn.preprocessing import MinMaxScaler,StandardScaler from sklearn.ensemble import RandomForestClassifier from sklearn.model_selection import train_test_split from numpy import set_printoptions, inf set_printoptions(threshold=inf) import pandas as pd data = pd.read_csv("../data_set/heart.csv") X = data[data.columns[:data.shape[1] - 1]].values y = data[data.columns[-1]].values data = MinMaxScaler().fit_transform(X[:, [0, 3, 4, 7]]) X[:, [0, 3, 4, 7]] = data x_train, x_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=0) from autosklearn.classification import AutoSklearnClassifier model_auto = AutoSklearnClassifier(time_left_for_this_task=120, n_jobs=3, include_preprocessors=["no_preprocessing"], seed=3) model_auto.fit(x_train, y_train) from sklearn.metrics import accuracy_score y_pred = model_auto.predict(x_test) accuracy_score(y_test, y_pred) >>> 0.8021978021978022 from sklearn.ensemble import RandomForestClassifier model = RandomForestClassifier(n_estimators=500) y_pred_rf = model.predict(x_test) accuracy_score(y_test, y_pred_rf) >>> 0.8051648351648352
My personal web site which provides automl service, I upload this data set to my service, it gets a better score than my code: http://simple-code.cn/
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构