我正在使用Google Cloud Messaging在Android手机上接收推送通知.我成功了,一切似乎都运作良好.但是,Google建议检查Google Play服务是否已更新到上一版本(因为推送通知是一项新功能).
使用Nexus 7(4.4.4)并在活动开始时启用版本检查我需要更新我的Google Play服务,因为有更新的版本.但是,推送通知在没有更新的情况下完美运行.如果不是绝对必要,我不想要求我的用户更新Google Play服务.
我的问题:为了从GCM接收推送通知,我应该检查Google Play服务的最低版本是什么?
这是代码:
private boolean checkPlayServices() {
int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
if (resultCode != ConnectionResult.SUCCESS) {
if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
GooglePlayServicesUtil.getErrorDialog(resultCode, this,
PLAY_SERVICES_RESOLUTION_REQUEST).show();
} else {
Log.i(TAG, "This device is not supported.");
finish();
}
return false;
}
return true;
}
Run Code Online (Sandbox Code Playgroud)
备注:我不需要检查最新版本的Google Play服务,但支持推送通知的最低版本
编辑:由于评论,我做了一些澄清
android push-notification google-cloud-messaging google-play-services
我试图使用SciKit的Logistic回归来预测一组标签.我的数据实际上是不平衡的(有更多'0'而不是'1'标签)所以我必须在交叉验证步骤中使用F1得分指标来"平衡"结果.
[Input]
X_training, y_training, X_test, y_test = generate_datasets(df_X, df_y, 0.6)
logistic = LogisticRegressionCV(
Cs=50,
cv=4,
penalty='l2',
fit_intercept=True,
scoring='f1'
)
logistic.fit(X_training, y_training)
print('Predicted: %s' % str(logistic.predict(X_test)))
print('F1-score: %f'% f1_score(y_test, logistic.predict(X_test)))
print('Accuracy score: %f'% logistic.score(X_test, y_test))
[Output]
>> Predicted: [0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0]
>> Actual: [0 0 0 1 0 0 0 0 0 1 1 0 …Run Code Online (Sandbox Code Playgroud) python machine-learning scikit-learn cross-validation logistic-regression
我想使用Python中的标准工具(numpy,pandas,scipy.stats等)来计算线性回归模型的beta或标准化系数。
我的一个朋友告诉我,这是在R中使用以下命令完成的:
lm(scale(y) ~ scale(x))
Run Code Online (Sandbox Code Playgroud)
目前,我正在Python中像这样计算它:
from scipy.stats import linregress
from scipy.stats.mstats import zscore
(beta_coeff, intercept, rvalue, pvalue, stderr) = linregress(zscore(x), zscore(y))
print('The Beta Coeff is: %f' % beta_coeff)
Run Code Online (Sandbox Code Playgroud)
有没有更直接的函数可以在Python中计算该数字?