MCPcopy Create free account
hub / github.com/Chapter-7/Recommended-News / plot_envs

Function plot_envs

news2.py:126–139  ·  view source on GitHub ↗
(df, cols, r, c)

Source from the content-addressed store, hash-verified

124
125# 随机用户的点击环境分布
126def plot_envs(df, cols, r, c):
127 plt.figure(figsize=(10, 5), dpi=80)
128 i = 1
129 for col in cols:
130 plt.subplot(r, c, i)
131 i += 1
132 v = df[col].value_counts().reset_index().head(20)
133 v.columns = ['category', 'count']
134 fig = sns.barplot(x=v['category'], y=v['count'])
135 for item in fig.get_xticklabels():
136 item.set_rotation(90)
137 plt.title(col)
138 plt.tight_layout()
139 plt.show()
140
141sample_user_ids = np.random.choice(tst_click['user_id'].unique(), size=5, replace=False)
142sample_users = user_click_merge[user_click_merge['user_id'].isin(sample_user_ids)]

Callers 1

news2.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected