小编Lê *_*ành的帖子

如何查询DynamoDB中一列的所有行?

我只是在短时间内使用 AWS DynamoDB。我想知道如何使用此语句获得相同的结果(没有 WHERE 子句):

SELECT column1 FROM DynamoTable;

我尝试过(但失败了):

 import boto3
 dynamodb = boto3.resource('dynamodb')
 table = dynamodb.Table('DynamoTable')
 from boto3.dynamodb.conditions import Key, Attr
 resp = table.query(KeyConditionExpression=Key('column1'))
Run Code Online (Sandbox Code Playgroud)

它需要Key().eq()Key().begin_with()...

resp = table.scan()已经尝试过了,但是响应数据的字段太多,而我只需要column1

谢谢。

python amazon-dynamodb boto3

3
推荐指数
2
解决办法
8605
查看次数

如何纠正 sklearn.naive_bayes 中的 sample_weight?

我执行Naive Bayessklearn不均衡的数据。我的数据有超过 16k 条记录和 6 个输出类别。

我试图用sample_weight计算出的模型来拟合模型sklearn.utils.class_weight

sample_weight收到这样的:

样本权重 = [11.77540107 1.82284768 0.64688602 2.47138047 0.38577435 1.21389195]

import numpy as np

data_set = np.loadtxt("./data/_vector21.csv", delimiter=",")

inp_vec = data_set[:, 1:22]
out_vec = data_set[:, 22:]
#
# # Split dataset into training set and test set
from sklearn.cross_validation import train_test_split
X_train, X_test, y_train, y_test = train_test_split(inp_vec, out_vec, test_size=0.2)    # 80% training and 20% test
#
# class weight
from keras.utils.np_utils import to_categorical
output_vec_categorical = …
Run Code Online (Sandbox Code Playgroud)

python machine-learning scikit-learn

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