<jupyter_start><jupyter_text>CSCI 5622 Fall 2017 HW2 <NAME>  1. Logistic Regression  1.1 Programming Question -- see source files  1.2 AnalysisWhat is the role of learning rate on the efficiency of convergence during training?Answer: A lower eta value (sucha as 0.0001) causes the program to need longer time to reach a it's best accuracy.But a too high value of eta (0.5) causes the accuracy not to converge.<jupyter_code>import matplotlib.pyplot as plt
import json
import numpy as np
plt.style.use('ggplot')
%matplotlib inline
from collections import defaultdict
import seaborn as sns
import pandas as pd
df = pd.read_csv('../hw2/hw2_1_out.csv')
x = np.arange(10)
eta_list = df['eta'].unique()
y_list = defaultdict(defaultdict)
for idx, eta in enumerate(eta_list):
    y_list[idx]['eta'] = eta
    y_list[idx]['train_acc'] = df[df['eta']==eta]['train_acc']
    y_list[idx]['test_acc'] = df[df['eta']==eta]['test_acc']

plt.clf()
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
sns.set_style("whitegrid")



for idx, y_n in y_list.items():
    line, = ax.plot(x, y_n['test_acc'] , lw=2, label=y_n['eta'])



ax.set_xlim(-1, len(x) + 1)
ax.set_ylim(0.90,1.00)

ax.set_xlabel('Epochs')
ax.set_ylabel('Test Accuracy')

#Now this is actually the code that you need, an easy fix your colors just cut and paste not you need ax.
colormap = plt.cm.gist_ncar #nipy_spectral, Set1,Paired  
colorst = [colormap(i) for i in np.linspace(0, 0.9,len(ax.collections))]       
for t,j1 in enumerate(ax.collections):
    j1.set_color(colorst[t])



plt.title('Q 1.2 Logistic Regression \n Test Accuracy for different values of eta')
plt.legend(bbox_to_anchor=(1.05, 1), loc=2)
plt.show()
plt.clf()
plt.close(fig)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13631090487238978, 'fraction_numerical': 0.029582366589327145, 'mean_word_length': 4.887372013651877, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '196459', 'license': 'MIT', 'n_tokens_mistral': 692, 'n_tokens_neox': 650, 'n_words': 185, 'path': 'fall_2017/hw1/McKean_Brian_HW2.ipynb', 'repo_name': 'bdmckean/MachineLearning', 'size': '1730'}