from
statistics
import
mean, stdev
from
sklearn
import
preprocessing
from
sklearn.model_selection
import
StratifiedKFold
from
sklearn
import
linear_model
from
sklearn
import
datasets
cancer
=
datasets.load_breast_cancer()
x
=
cancer.data
y
=
cancer.target
scaler
=
preprocessing.MinMaxScaler()
x_scaled
=
scaler.fit_transform(x)
lr
=
linear_model.LogisticRegression()
skf
=
StratifiedKFold(n_splits
=
10
, shuffle
=
True
, random_state
=
1
)
lst_accu_stratified
=
[]
for
train_index, test_index
in
skf.split(x, y):
x_train_fold, x_test_fold
=
x_scaled[train_index], x_scaled[test_index]
y_train_fold, y_test_fold
=
y[train_index], y[test_index]
lr.fit(x_train_fold, y_train_fold)
lst_accu_stratified.append(lr.score(x_test_fold, y_test_fold))
print
(
'List of possible accuracy:'
, lst_accu_stratified)
print
(
'\nMaximum Accuracy That can be obtained from this model is:'
,
max
(lst_accu_stratified)
*
100
,
'%'
)
print
(
'\nMinimum Accuracy:'
,
min
(lst_accu_stratified)
*
100
,
'%'
)
print
(
'\nOverall Accuracy:'
,
mean(lst_accu_stratified)
*
100
,
'%'
)
print
(
'\nStandard Deviation is:'
, stdev(lst_accu_stratified))