小编tla*_*gan的帖子

如何使用 Pandas DF 绘制计数条形图,按一个分类列分组并按另一个分类着色

我有一个大致如下所示的数据框:

  Property   Name    industry
1  123     name1    industry 1
1  144     name1    industry 1
2  456     name2    industry 1
3  789     name3    industry 2
4  367     name4    industry 2
.  ...     ...      ... 
.  ...     ...      ... 
n  123     name1    industry 1
Run Code Online (Sandbox Code Playgroud)

我想制作一个条形图,绘制每个 Names 的行数,并根据它的行业为条形着色。我试过这样的事情:

ax = df['name'].value_counts().plot(kind='bar',
                                    figsize=(14,8),
                                    title="Number for each Owner Name")
ax.set_xlabel("Owner Names")
ax.set_ylabel("Frequency")
Run Code Online (Sandbox Code Playgroud)

我得到以下信息:

差不多好了

我的问题是如何根据数据框中的行业列为条形着色(并添加图例)。

谢谢!

python pandas

12
推荐指数
4
解决办法
5万
查看次数

如何卷曲 Amazon Sagemaker 终端节点

向 sage-maker 发出 POST 请求并接收 ML 推理的 curl 命令是什么?

amazon-web-services amazon-sagemaker

11
推荐指数
2
解决办法
5290
查看次数

使用 AWS SageMaker create-training-job 命令:键入错误

我正在尝试使用 AWS sagemaker cli 运行 create-training-job 命令。这是我的命令:

aws sagemaker create-training-job \
--training-job-name $(DEPLOYMENT_NAME)-$(BUILD_ID) \
--hyper-parameters file://sagemaker/hyperparameters.json \
--algorithm-specification TrainingImage=$(IMAGE_NAME),\
TrainingInputMode="File" \
--role-arn $(ROLE) \
--input-data-config ChannelName=training,DataSource={S3DataSource={S3DataType=S3Prefix,S3Uri=$(S3_INPUT),S3DataDistributionType=FullyReplicated}},ContentType=string,CompressionType=None,RecordWrapperType=None \
--output-data-config S3OutputPath=$(S3_OUTPUT) \
--resource-config file://sagemaker/train-resource-config.json \
--stopping-condition file://sagemaker/stopping-conditions.json 
Run Code Online (Sandbox Code Playgroud)

这是错误:

Parameter validation failed:
Invalid type for parameter InputDataConfig[0].DataSource.S3DataSource, value: S3DataType=S3Prefix, type: <type 'unicode'>, valid types: <type 'dict'>
Invalid type for parameter InputDataConfig[1].DataSource.S3DataSource, value: S3Uri=s3://hs-machine-learning-processed-production/inbound-autotag/data, type: <type 'unicode'>, valid types: <type 'dict'>
Invalid type for parameter InputDataConfig[2].DataSource.S3DataSource, value: S3DataDistributionType=FullyReplicated, type: <type 'unicode'>, valid types: <type …
Run Code Online (Sandbox Code Playgroud)

amazon-web-services amazon-sagemaker

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

我如何使用 AWS CLI 调用 SageMaker 终端节点(

我正在尝试使用 aws cli从SageMaker 示例笔记本调用 iris 端点。我尝试使用以下命令:

!aws sagemaker-runtime invoke-endpoint \
--endpoint-name sagemaker-tensorflow-py2-cpu-2018-03-19-21-27-52-956 \
--body "[6.4, 3.2, 4.5, 1.5]" \
--content-type "application/json" \
output.json
Run Code Online (Sandbox Code Playgroud)

我收到以下回复:

{
    "InvokedProductionVariant": "AllTraffic", 
    "ContentType": "*/*"
}
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

amazon-web-services amazon-sagemaker

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

Pandas数据帧将数组分成两列

我有一个如下所示的数据框:

       reviewerID        asin    reviewerName helpful  unixReviewTime  \
0  A1N4O8VOJZTDVB  B004A9SDD8  Annette Yancey  [1, 1]      1383350400   
Run Code Online (Sandbox Code Playgroud)

我想将"有用的"列分成两个不同的列,名称为"helpful_numerator"和"有用的分母",我无法弄明白.

任何帮助将非常感激!

python dataframe pandas

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

如何使用 Python SDK 调用 Amazon SageMaker 终端节点

我正在尝试使用这个非常简单的命令:

import boto3 client = boto3.client('sagemaker-runtime')

文档中列出

但我收到此错误:

UnknownServiceError: Unknown service: 'sagemaker-runtime'. Valid service names are: acm, etc..

我的目标是能够调用我在 Amazon SageMaker 中创建的终端节点。

我是在 Sagemaker 中的 Jupyter 笔记本上执行此操作的,所以我觉得这应该没问题。如何让它在此处以及 Sagemaker 环境之外运行?

amazon-web-services amazon-sagemaker

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