# If you implemented all the steps correctly, your algorithm should converge in about 20 iterations. Let's plot the clusters to see it. We will assign a cluster label as the most probable cluster index. This can be found using matrix $\gamma$ computed on last E-step. # # In[19]: gamma = E_step(X, best_pi, best_mu, best_sigma) labels = gamma.argmax(1) plt.scatter(X[:, 0], X[:, 1], c=labels, s=30) plt.axis('equal') plt.show() # ### Authorization & Submission # To submit assignment parts to Cousera platform, please, enter your e-mail and your token into variables below. You can generate the token on this programming assignment page. <b>Note:</b> Token expires 30 minutes after generation. # In[ ]: STUDENT_EMAIL = # EMAIL HERE STUDENT_TOKEN = # TOKEN HERE grader.status() # If you want to submit these answers, run cell below # In[ ]: grader.submit(STUDENT_EMAIL, STUDENT_TOKEN)
filtered_trans = transactions[transactions.shop_id == shop_id] filtered_trans = filtered_trans[filtered_trans.date.str.endswith('12.2014')] filtered_trans = filtered_trans.groupby('date')['item_cnt_day'].sum() total_num_items_sold = filtered_trans.values days = filtered_trans.index.to_datetime() # Plot it plt.plot(days, total_num_items_sold) plt.ylabel('Num items') plt.xlabel('Day') plt.title("Daily revenue for shop_id = 25") plt.show() total_num_items_sold_var = filtered_trans.var() grader.submit_tag('total_num_items_sold_var', total_num_items_sold_var) # ## Authorization & Submission # To submit assignment to Cousera platform, please, enter your e-mail and token into the variables below. You can generate token on the programming assignment page. *Note:* Token expires 30 minutes after generation. # In[24]: STUDENT_EMAIL = '' STUDENT_TOKEN = '' grader.status() # In[25]: grader.submit(STUDENT_EMAIL, STUDENT_TOKEN) # Well done! :)
prepared_test_data = ######### YOUR CODE HERE ############# for line in open(prepared_test_data): q, *ex = line.strip().split('\t') ranks = rank_candidates(q, ex, starspace_embeddings, 100) ranked_candidates = [r[0] for r in ranks] starspace_ranks_results.append([ranked_candidates.index(i) + 1 for i in range(len(ranked_candidates))]) grader.submit_tag('StarSpaceRanks', matrix_to_string(starspace_ranks_results)) # Please, **don't remove** the file with these embeddings because you will need them in the final project. # ### Authorization & Submission # To submit assignment parts to Cousera platform, please, enter your e-mail and token into variables below. You can generate token on this programming assignment page. <b>Note:</b> Token expires 30 minutes after generation. # In[ ]: STUDENT_EMAIL = # EMAIL STUDENT_TOKEN = # TOKEN grader.status() # If you want to submit these answers, run cell below # In[ ]: grader.submit(STUDENT_EMAIL, STUDENT_TOKEN)