Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AutoCross使用实例 #246

Open
Dara-to-win opened this issue Sep 23, 2024 · 0 comments
Open

AutoCross使用实例 #246

Dara-to-win opened this issue Sep 23, 2024 · 0 comments

Comments

@Dara-to-win
Copy link

作者您好!请问可以在官方文档中增加AutoCross的使用实例吗?
from pyalink.alink import *
from pyalink.alink import AutoCrossBatchOp
import pandas as pd

初始化环境

useLocalEnv(1)

将 DataFrame 转换为 Alink 的 BatchOperator

train_data = BatchOperator.fromDataframe(train_data, schemaStr="id int, Time double, feat1 double, feat2 double, feat3 double, feat4 double, feat5 double, feat6 double, feat7 double, feat8 double, feat9 double, feat10 double, feat11 double, feat12 double, feat13 double, feat14 double, feat15 double, feat16 double, feat17 double, feat18 double, feat19 double, feat20 double, feat21 double, feat22 double, feat23 double, feat24 double, feat25 double, feat26 double, feat27 double, feat28 double, Transaction_Amount double, IsFraud int")

配置 AutoCross

auto_cross = AutoCrossBatchOp()
.setSelectedCols(["feat1", "feat2", "feat3", "feat4", "feat5", "feat6", "feat7", "feat8", "feat9", "feat10", "feat11", "feat12", "feat13", "feat14", "feat15", "feat16", "feat17", "feat18", "feat19", "feat20", "feat21", "feat22", "feat23", "feat24", "feat25", "feat26", "feat27", "feat28"])
.setLabelCol("IsFraud")
.setOutputCol("crossed_features")

训练 AutoCross 模型

model = auto_cross.fit(train_data)

使用模型进行特征交叉

result = model.transform(train_data)

打印结果

result.print()


ImportError Traceback (most recent call last)
Cell In[6], line 2
1 from pyalink.alink import *
----> 2 from pyalink.alink import AutoCrossBatchOp
3 import pandas as pd
5 # 初始化环境

ImportError: cannot import name 'AutoCrossBatchOp' from 'pyalink.alink' (D:\Anaconda\envs\pyalink\lib\site-packages\pyalink\alink_init_.py)

我使用的是如下版本的pyalink.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant