<jupyter_start><jupyter_text>Import dataset, logistic regression, train_test_split from sklearn<jupyter_code>from sklearn.datasets import load_breast_cancer
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split<jupyter_output><empty_output><jupyter_text>Load cancer data into cancer<jupyter_code>cancer = load_breast_cancer()
# print the Description of cancer data
# cancer.data gives the training data and cancer.target gives the labels to training data such as 'malignant' or 'benign'
# cancer.feature_names gives the feature names i.e coloumns in dataset
# cancer.target_names gives the labels such as 'malignant' or 'benign'
#print(cancer.DESCR)
print(cancer.DESCR)<jupyter_output>Breast Cancer Wisconsin (Diagnostic) Database
=============================================

Notes
-----
Data Set Characteristics:
    :Number of Instances: 569

    :Number of Attributes: 30 numeric, predictive attributes and the class

    :Attribute Information:
        - radius (mean of distances from center to points on the perimeter)
        - texture (standard deviation of gray-scale values)
        - perimeter
        - area
        - smoothness (local variation in radius lengths)
        - compactness (perimeter^2 / area - 1.0)
        - concavity (severity of concave portions of the contour)
        - concave points (number of concave portions of the contour)
        - symmetry 
        - fractal dimension ("coastline approximation" - 1)

        The mean, standard error, and "worst" or largest (mean of the three
        largest values) of these features were computed for each image,
        resulting in 30 features.  For instance, field 3 is Mean Radius, field
        13 is [...]<jupyter_text>Split the train and test set using Sklearn train_test_split function<jupyter_code>X_train, X_test, y_train, y_test = train_test_split(cancer.data, cancer.target, stratify=cancer.target, random_state=42)<jupyter_output><empty_output><jupyter_text>Now train the model using LogisticRegression in Sklearn<jupyter_code>log_reg = LogisticRegression()
log_reg.fit(X_train, y_train)<jupyter_output><empty_output><jupyter_text>Now Evaluate Accuracy of the Model<jupyter_code>print('Accuracy on the training subset: {:.3f}'.format(log_reg.score(X_train, y_train)))
print('Accuracy on the test subset: {:.3f}'.format(log_reg.score(X_test, y_test)))<jupyter_output>Accuracy on the training subset: 0.953
Accuracy on the test subset: 0.958<jupyter_text>You can give your own Input as below and check if cancer is Malignant or Benign<jupyter_code>test_for_Malignant=[[20.57,17.77,132.9,1326,0.08474,0.07864,0.0869,0.07017,0.1812,0.05667,0.5435,0.7339,3.398,74.08,0.005225,0.01308,0.0186,0.0134,0.01389,0.003532,24.99,23.41,158.8,1956,0.1238,0.1866,0.2416,0.186,0.275,0.08902]]
test_for_benign=[[13.54, 14.36, 87.46, 566.3, 0.09779, 0.08129, 0.06664, 0.04781, 0.1885, 0.05766, 0.2699, 0.7886, 2.058, 23.56, 0.008462, 0.0146, 0.02387, 0.01315, 0.0198, 0.0023, 15.11, 19.26, 99.7, 711.2, 0.144, 0.1773, 0.239, 0.1288, 0.2977, 0.07259]]
prediction = log_reg.predict(test_for_benign)
if prediction[0] == 0:
    print("Malignant")
else:
    print("Benign")<jupyter_output>Benign
{'fraction_non_alphanumeric': 0.119477286869944, 'fraction_numerical': 0.10080896079651525, 'mean_word_length': 4.792792792792793, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 22, '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': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '81363', 'license': 'Apache-2.0', 'n_tokens_mistral': 1319, 'n_tokens_neox': 1094, 'n_words': 288, 'path': 'Breast Cancer detection using Logistic Regression ( Malignant or Benign).ipynb', 'repo_name': 'valivetiravichandra/Breast-Cancer-detection-using-Logistic-Regression', 'size': '3214'}