小编abk*_*abk的帖子

查找向量中值之间的中点

这是一个使用中点规则计算 AUC 的函数。使用 R 如何定义一个包含前一个向量值之间的中点的向量?或者如何将向量的值移至中点?

# define h (or delta x)
  h <- (b - a) / n
# define vector based on the limits of integration, a to b by increments of h
  xj <- seq.int(a, b, length.out = n + 1
# shift values of vector to their midpoints
Run Code Online (Sandbox Code Playgroud)

例如,将值 [0, 1, 2, 3] 转换为 [.25, 1.5, 2.5]

这个 for 循环有效,但我想知道是否有比这更优雅的解决方案:

for (i in 1:length(xj)) {
  xji[i] <- (xj[i] + xj[i + 1]) / 2
}
Run Code Online (Sandbox Code Playgroud)

r integral calculus auc

5
推荐指数
2
解决办法
3928
查看次数

403 使用 Sig v4 将数据从 AWS Lambda 索引到 Elasticsearch 时出错:“没有 [indices:data/write/bulk] 权限”

我的函数可以从本地 Jupyter 笔记本将单个文档和批量索引到我的 AWS Elasticsearch,但是当我部署到 Lambda 时,它不断返回此错误:

"errorMessage": "AuthorizationException(403, 'security_exception', 'no permissions for
[indices:data/write/bulk] and User [name=arn:aws:iam::xxxxxxxxxxxx:role/MyLambdaRole,
backend_roles=[arn:aws:iam::xxxxxxxxxxxx:role/MyLambdaRole], requestedTenant=null]')"
Run Code Online (Sandbox Code Playgroud)

我的 Elasticsearch 域(v7.7)配置如下:

Fine-grained access control: Enabled
Master user type: Internal user database
SAML authentication: Disabled
Amazon Cognito for authentication: Disabled
Require HTTPS: Enabled
Encryption at rest: Enabled
KMS master keyarn:aws:kms:us-east-1:xxxxxxxxxxxxx:key/<aws/es key>
Node-to-node encryption: Enabled
Run Code Online (Sandbox Code Playgroud)

域的访问策略包含:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "AWS": "*"
      },
      "Action": "es:*",
      "Resource": "*"
    }
  ]
}
Run Code Online (Sandbox Code Playgroud)

MyLambdaRole 的 IAM 策略包含:

... …
Run Code Online (Sandbox Code Playgroud)

amazon-web-services elasticsearch kibana boto3

4
推荐指数
1
解决办法
9315
查看次数