File "c:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\joblib\_parallel_backends.py", line 208, in apply_async
File "c:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\joblib\_parallel_backends.py", line 208, in apply_async
result = ImmediateResult(func)
result = ImmediateResult(func)
File "c:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\joblib\_parallel_backends.py", line 597, in __init__
File "c:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\joblib\_parallel_backends.py", line 597, in __init__
self.results = batch()
self.results = batch()
File "c:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\joblib\parallel.py", line 288, in __call__
File "c:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\joblib\parallel.py", line 288, in __call__
return [func(*args, **kwargs)
return [func(*args, **kwargs)
File "c:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\joblib\parallel.py", line 288, in <listcomp>
File "c:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\joblib\parallel.py", line 288, in <listcomp>
return [func(*args, **kwargs)
return [func(*args, **kwargs)
File "c:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\utils\parallel.py", line 123, in __call__
File "c:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\utils\parallel.py", line 123, in __call__
return self.function(*args, **kwargs)
return self.function(*args, **kwargs)
File "c:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\linear_model\_logistic.py", line 521, in _logistic_regression_path
File "c:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\linear_model\_logistic.py", line 521, in _logistic_regression_path
alpha = (1.0 / C) * (1 - l1_ratio)
alpha = (1.0 / C) * (1 - l1_ratio)
TypeError: unsupported operand type(s) for -: 'int' and 'NoneType'
TypeError: unsupported operand type(s) for -: 'int' and 'NoneType'
c:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\model_selection\_search.py:952: UserWarning: One or more of the test scores are non-finite: [ nan 0.87666667 0.92083333 nan nan 0.87416667
c:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\model_selection\_search.py:952: UserWarning: One or more of the test scores are non-finite: [ nan 0.87666667 0.92083333 nan nan 0.87416667
nan 0.87666667 0.864375 0.87645833 0.78208333 0.87854167
nan 0.87666667 0.864375 0.87645833 0.78208333 0.87854167
0.85645833 nan 0.87791667 0.90395833 0.87854167 nan
0.85645833 nan 0.87791667 0.90395833 0.87854167 nan
nan 0.87375 0.78208333 0.87666667 nan nan
nan 0.87375 0.78208333 0.87666667 nan nan
0.78208333 0.90270833 nan nan 0.85625 nan
0.78208333 0.90270833 nan nan 0.85625 nan
0.86583333 nan nan nan]
0.86583333 nan nan nan]
warnings.warn(
warnings.warn(
c:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\linear_model\_logistic.py:1173: FutureWarning: `penalty='none'`has been deprecated in 1.2 and will be removed in 1.4. To keep the past behaviour, set `penalty=None`.
c:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\linear_model\_logistic.py:1173: FutureWarning: `penalty='none'`has been deprecated in 1.2 and will be removed in 1.4. To keep the past behaviour, set `penalty=None`.
warnings.warn(
warnings.warn(
c:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\linear_model\_logistic.py:1181: UserWarning: Setting penalty=None will ignore the C and l1_ratio parameters
c:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\linear_model\_logistic.py:1181: UserWarning: Setting penalty=None will ignore the C and l1_ratio parameters
warnings.warn(
warnings.warn(
Best Parameters: {'solver': 'newton-cg', 'penalty': 'none', 'max_iter': 100, 'C': 0.005994842503189409}
Best Parameters: {'solver': 'newton-cg', 'penalty': 'none', 'max_iter': 100, 'C': 0.005994842503189409}
Best Score: 0.9225
Best Score: 0.9225
Accuracy: 0.9325
Accuracy: 0.9325
Confusion Matrix:
Confusion Matrix:
[[557 31]
[[557 31]
[ 50 562]]
[ 50 562]]
Classification Report:
Classification Report:
precision recall f1-score support
precision recall f1-score support
0 0.92 0.95 0.93 588
0 0.92 0.95 0.93 588
1 0.95 0.92 0.93 612
1 0.95 0.92 0.93 612
accuracy 0.93 1200
accuracy 0.93 1200
macro avg 0.93 0.93 0.93 1200
macro avg 0.93 0.93 0.93 1200
weighted avg 0.93 0.93 0.93 1200
weighted avg 0.93 0.93 0.93 1200
c:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\utils\optimize.py:210: ConvergenceWarning: newton-cg failed to converge. Increase the number of iterations.
c:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\utils\optimize.py:210: ConvergenceWarning: newton-cg failed to converge. Increase the number of iterations.
warnings.warn(
warnings.warn(
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
Predict
Predict
%% Cell type:code id: tags:
%% Cell type:code id: tags:
``` python
``` python
test_data=pd.read_csv('TestingDataBinary.csv')
test_data=pd.read_csv('TestingDataBinary.csv')
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
``` python
``` python
# Preprocessing
# Preprocessing
X_new=test_data
X_new=test_data
X_new.replace([np.inf,-np.inf],0,inplace=True)
X_new.replace([np.inf,-np.inf],0,inplace=True)
# Impute the missing values in the features data
# Impute the missing values in the features data
X_imputed_new=imputer.transform(X_new)
X_imputed_new=imputer.transform(X_new)
# Scale the features data
# Scale the features data
X_scaled_new=scaler.transform(X_imputed_new)
X_scaled_new=scaler.transform(X_imputed_new)
# Apply PCA transformation
# Apply PCA transformation
X_pca_new=pca.transform(X_scaled_new)
X_pca_new=pca.transform(X_scaled_new)
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
``` python
``` python
# Use the best estimator for predictions on the new data
# Use the best estimator for predictions on the new data
y_pred_new=best_model.predict(X_pca_new)
y_pred_new=best_model.predict(X_pca_new)
# Save the predictions to a new column in the DataFrame
# Save the predictions to a new column in the DataFrame