小编the*_*mmy的帖子

如何使用 joblib.dump 在 s3 上保存 sklearn 模型?

我有一个 sklearn 模型,我想使用 joblib.dump 将泡菜文件保存在我的 s3 存储桶中

joblib.dump(model, 'model.pkl')以前在本地保存模型,但不知道如何将其保存到s3存储桶。

s3_resource = boto3.resource('s3')
s3_resource.Bucket('my-bucket').Object("model.pkl").put(Body=joblib.dump(model, 'model.pkl'))
Run Code Online (Sandbox Code Playgroud)

我希望腌制文件在我的 s3 存储桶上。

python amazon-s3 amazon-web-services scikit-learn joblib

10
推荐指数
2
解决办法
5835
查看次数

Plotly:如何使用下拉菜单按年、月和日对数据进行子集化?

我正在尝试绘制三个图形(日、月、年),并让用户可以选择使用下拉菜单选择他们想要查看的图形。当我为 (day, month) 做它时,它完美地工作(以月份显示为默认图表),但是当我添加(year)时,则(day, month)不显示(在这种情况下,我想要 year成为默认图形)。

这是工作代码:

# Plot Day
temp_day = pd.DataFrame(df.day.value_counts())
temp_day.reset_index(inplace=True)
temp_day.columns = ['day', 'tweet_count']
temp_day.sort_values(by=['day'], inplace=True)
temp_day.reset_index(inplace=True, drop=True)

trace_day = go.Scatter(
                    x=temp_day.day.values,
                    y=temp_day.tweet_count.values,
                    text = [f"{humanize.naturaldate(day)}: {count} tweets" for day,count in zip(temp_day.day.values,temp_day.tweet_count.values)],
                    hoverinfo='text',
                    mode='lines', 
                    line = {
                        'color': my_color,
                        'width': 1.2
                    },
                    visible=False,
                    name="Day"
                )

# Plot Month
temp_month = pd.DataFrame(df.YYYYMM.value_counts())
temp_month.reset_index(inplace=True)
temp_month.columns = ['YYYYMM', 'tweet_count']
temp_month['YYYYMM'] = temp_month['YYYYMM'].dt.strftime('%Y-%m')
temp_month.sort_values(by=['YYYYMM'], inplace=True)
temp_month.reset_index(inplace=True, drop=True)

trace_month = go.Scatter(
                    x=temp_month.YYYYMM.values,
                    y=temp_month.tweet_count.values,
                    mode='lines', 
                    line = {
                        'color': my_color,
                        'width': 1.2 …
Run Code Online (Sandbox Code Playgroud)

python drop-down-menu plotly

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