MCPcopy Create free account
hub / github.com/conflow-dev/ConFlow / create_avazu_dataset

Function create_avazu_dataset

model_demo/DeepCrossing/utils.py:39–57  ·  view source on GitHub ↗
(file_path, embed_dim=8, test_size=0.2)

Source from the content-addressed store, hash-verified

37
38
39def create_avazu_dataset(file_path, embed_dim=8, test_size=0.2):
40 data = pd.read_csv(file_path)
41
42 sparse_features = ['feat_' + str(i) for i in range(1, 23)]
43
44 #缺失值填充
45 data[sparse_features] = data[sparse_features].fillna('-1')
46
47 #LabelEncoding编码
48 for col in sparse_features:
49 data[col] = LabelEncoder().fit_transform(data[col]).astype(int)
50
51 feature_columns = [[sparseFeature(feat, data[feat].nunique(), embed_dim) for feat in sparse_features]]
52
53 X = data.drop(['label'], axis=1).values
54 y = data['label']
55 X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=test_size)
56
57 return feature_columns, (X_train, y_train), (X_test, y_test)

Callers

nothing calls this directly

Calls 1

sparseFeatureFunction · 0.85

Tested by

no test coverage detected