答案 0 :(得分:0)
首先,它不是你的错,而gitkit的记录很少。 至于实现本身,首先需要复制粘贴代码(来自the docs):
import pandas as pd
train = pd.get_dummies(train_df)
test = pd.get_dummies(test_df)
# get the columns in train that are not in test
col_to_add = np.setdiff1d(train.columns, test.columns)
# add these columns to test, setting them equal to zero
for c in col_to_add:
test[c] = 0
# select and reorder the test columns using the train columns
test = test[train.columns]
}
然后你应该实现一个MyUIManger并注意方法:
get_dummies
因为这是您应该将所有UI输入发送到的对象。
关于MyUIManager的其余部分,遵循描述here的接口,您应该在调用这些函数时更改屏幕,并使用适当的请求将用户输入发送到requestHandler。
例如,当调用client.startSignIn()时,GitKitClient将调用MyUIManager.ShowStartSignIn方法,因此在该方法中,您应该显示相关屏幕并将输入发送到之前的RequestHandler。 以下内容:
public class MyLoginActivity extends Activity {
private GitkitClient client;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// If there is no signed in user, create a GitkitClient to start sign in flow.
SignInCallbacks callbacks = new SignInCallbacks() {
// Implement the onSignIn method of GitkitClient.SignInCallbacks interface.
@Override
public void onSignIn(IdToken idToken, GitkitUser gitkitUser) {
// Send the idToken to the server. The server should issue a session cookie/token
// for the app if the idToken is verified.
authenticate(idToken.getTokenString());
...
}
// Implement the onSignInFailed method of GitkitClient.SignInCallbacks interface.
@Override
public void onSignInFailed() {
// Handle the sign in failure.
...
}
}
// The example suppose all necessary configurations are set in the AndroidManifest.xml.
// You can also set or overwrite them by calling the corresponding setters on the
// GitkitClientBuilder.
client = GitkitClient.newBuilder(this, callbacks).setUiManager(new MyUiManger()).build();
// Start sign in flow.
client.startSignIn();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (client.handleActivityResult(requestCode, resultCode, data)) {
// result is handled by GitkitClient.
return;
}
// Otherwise, the result is not returned to GitkitClient and should be handled by the
// activity.
...
}
@Override
protected void onNewIntent(Intent intent) {
if (client.handleIntent(intent)) {
// intent is handled by the GitkitClient.
return;
}
// Otherwise, the intent is not for GitkitClient and should be handled by the activity.
...
}