Along with Company, Cluster, show the Mean return and volatility for each company as…
- User
Along with Company, Cluster, show the Mean return and volatility for each company as well.
centroids = k_means.cluster_centers_ fig = plt.figure(figsize=(16,10)) ax = fig.add_subplot(111) scatter = ax.scatter(X.iloc[:,0],X.iloc[:,1], c = k_means.labels_, cmap ="rainbow", label = X.index) ax.set_title('k-Means') ax.set_xlabel('Mean Return') ax.set_ylabel('Volatility') plt.colorbar(scatter)
zip joins x and y coordinates in pairs
for x,y,name in zip(X.iloc[:,0],X.iloc[:,1],X.index):
label = name plt.annotate(label, # this is the text (x,y), # this is the point to label textcoords="offset points", # how to position the text xytext=(0,10), # distance from text to points (x,y) ha='center') # horizontal alignment can be left, right or centerplt.plot(centroids[:,0],centroids[:,1],'sg',markersize=11)
cluster_label = pd.concat([pd.DataFrame(X.index), pd.DataFrame(k_means.labels_)],axis = 1) cluster_label.columns =['Company','Cluster'] cluster_label.sort_values(by=['Cluster'])
Assistant
mean return volatility Company 1 Cluster 1 mean return 6.27, volatility 0.67 Company 2 Cluster 1 mean return 7.93, volatility 0.92 Company 1 Cluster 2 mean return 3.61, volatility 0.27 Company 2 Cluster 2 mean return 2.65, volatility 0.28
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.