<jupyter_start><jupyter_text>Cross Validation Classification Accuracy<jupyter_code>import pandas as pd
from sklearn import model_selection
from sklearn.linear_model import LogisticRegression<jupyter_output><empty_output><jupyter_text>**Dataset** Pregnancies - Number of times pregnant Glucose - Plasma glucose concentration a 2 hours in an oral glucose tolerance testBloodPressure - Diastolic blood pressure (mm Hg)SkinThickness - Triceps skin fold thickness (mm)Insulin - 2-Hour serum insulin (mu U/ml)BMI - Body mass index (weight in kg/(height in m)^2)DiabetesPedigree - FunctionDiabetes pedigree functionAge - Age (years)Outcome - Class variable (0 or 1)<jupyter_code>dataframe = pd.read_csv('Pima_India_Diabetes.csv')#, names=names)
array = dataframe.values
X = array[:,0:8]
Y = array[:,8]
seed = 7
kfold = model_selection.KFold(n_splits=10, random_state=seed)
myModel = LogisticRegression()
scoring = 'accuracy'
results = model_selection.cross_val_score(myModel, X, Y, cv=kfold, scoring=scoring)
print(("Accuracy: %.3f (SD:%.3f)") % (results.mean()*100, results.std()))<jupyter_output>Accuracy: 76.951 (SD:0.048)<jupyter_text>Confusion Matrix<jupyter_code>from sklearn.metrics import confusion_matrix
from sklearn.metrics import classification_report
X_train, X_test, Y_train, Y_test = model_selection.train_test_split(X, Y, test_size=.3, random_state=seed)
model = LogisticRegression()
model.fit(X_train, Y_train)
predicted = model.predict(X_test)
cm = confusion_matrix(Y_test, predicted)
print(cm)
print('Accuracy: %.2f' % (cm.diagonal().sum()*100/cm.sum()))
report = classification_report(Y_test, predicted)
print(report)<jupyter_output>precision    recall  f1-score   support

        0.0       0.77      0.88      0.83       147
        1.0       0.73      0.55      0.63        84

avg / total       0.76      0.76      0.75       231<jupyter_text>AUC<jupyter_code>#AUC - Area Under the Curve
scoring = 'roc_auc'
results = model_selection.cross_val_score(model, X, Y, cv=kfold, scoring=scoring)
print("AUC: %.3f (%.3f)" % (results.mean(), results.std()))<jupyter_output>AUC: 0.823 (0.041)
{'fraction_non_alphanumeric': 0.12, 'fraction_numerical': 0.0380952380952381, 'mean_word_length': 5.107558139534884, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '619833', 'license': 'Apache-2.0', 'n_tokens_mistral': 793, 'n_tokens_neox': 721, 'n_words': 167, 'path': 'Model_Evaluation-Diabetes.ipynb', 'repo_name': 'rakeshamman369/Classification-Model-Performance-master', 'size': '2100'}