from sklearn.preprocessing import LabelEncoder import pandas as pd import seaborn as sns titanic = sns.load_dataset("titanic") em_town = titanic["embark_town"] em_town .head(10) print(em_town) enc = LabelEncoder() new_label = pd.Series(enc.fit_transform(em_town.astype('str'))) new_label.head(10) print(new_label)
特征工程(文本应用)
于 2024-03-13 21:06:21 首次发布