<jupyter_start><jupyter_text>Using Logistic Regression on Cancer Dataset<jupyter_code>from sklearn.datasets import load_breast_cancer
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
import matplotlib.pyplot as plt
%matplotlib inline

cancer = load_breast_cancer()

x_train, x_test, y_train, y_test = train_test_split(cancer.data, cancer.target, stratify=cancer.target, random_state=42)

log_reg = LogisticRegression()
log_reg.fit(x_train, y_train)
print('accuracy of training set is: {:.3f}'.format(log_reg.score(x_train, y_train)))
print('accuracy of test set is: {:.3f}'.format(log_reg.score(x_test, y_test)))
log_reg100 = LogisticRegression(C=100)
log_reg100.fit(x_train, y_train)
print('accuracy of training set is: {:.3f}'.format(log_reg100.score(x_train, y_train)))
print('accuracy of test set is: {:.3f}'.format(log_reg100.score(x_test, y_test)))
log_reg1000 = LogisticRegression(C=1000)
log_reg1000.fit(x_train, y_train)
print('accuracy of training set is: {:.3f}'.format(log_reg1000.score(x_train, y_train)))
print('accuracy of test set is: {:.3f}'.format(log_reg1000.score(x_test, y_test)))
log_reg001 = LogisticRegression(C=0.01)
log_reg001.fit(x_train, y_train)
print('accuracy of training set is: {:.3f}'.format(log_reg001.score(x_train, y_train)))
print('accuracy of test set is: {:.3f}'.format(log_reg001.score(x_test, y_test)))
import mglearn
mglearn.plots.plot_linear_regression_wave()
plt.plot(log_reg.coef_.T, 'o', label='C=1')
plt.plot(log_reg100.coef_.T, '^', label='C=100')
plt.plot(log_reg001.coef_.T, 'v', label='C=0.01')
plt.xticks(range(cancer.data.shape[1]), cancer.feature_names, rotation=90)
plt.hlines(0,0, cancer.data.shape[1])
#plt.ylim(-5,5)
plt.xlabel('Coefficient Index')
plt.ylabel('Coefficient Magnitude')
plt.legend()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15092290988056462, 'fraction_numerical': 0.043973941368078175, 'mean_word_length': 8.355329949238579, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '664914', 'license': 'MIT', 'n_tokens_mistral': 787, 'n_tokens_neox': 715, 'n_words': 127, 'path': 'scikit_test_LogisticRegression.ipynb', 'repo_name': 'Ankit5678/Workflow_Jupyter', 'size': '1842'}