while working with find testing accuracy in logistic regressio9n using byspark i recieved an error mentioned below
from sklearn.metrics import confusion_matrix,accuracy_score,auc,precision_score,recall_score,roc_auc_score
print("Accuracy Score of the model",accuracy_score(predictions_lr['indexedLabel'],predictions_lr['prediction']))
print("ROC AUC Scoer of the model",roc_auc_score(predictions_lr['indexedLabel'],predictions_lr['prediction']))
print("Confusion Matrix of the model",confusion_matrix(predictions_lr['indexedLabel'],predictions_lr['prediction']))
print("Precision Score of the model",precision_score(predictions_lr['indexedLabel'],predictions_lr['prediction']))
print("Precision Score of the model",recall_score(predictions_lr['indexedLabel'],predictions_lr['prediction']))
Trackback:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-21-47e167ee8cb5> in <module>()
1 from sklearn.metrics import confusion_matrix,accuracy_score,auc,precision_score,recall_score,roc_auc_score
----> 2 print("Accuracy Score of the model",accuracy_score(predictions_lr['indexedLabel'],predictions_lr['prediction']))
3 print("ROC AUC Scoer of the model",roc_auc_score(accuracy['indexedLabel'],accuracy['prediction']))
4 print("Confusion Matrix of the model",confusion_matrix(accuracy['indexedLabel'],res_df_main['prediction']))
5 print("Precision Score of the model",precision_score(res_df_main['indexedLabel'],res_df_main['prediction']))
4 frames
/usr/local/lib/python3.6/dist-packages/sklearn/metrics/_classification.py in accuracy_score(y_true, y_pred, normalize, sample_weight)
183
184 # Compute accuracy for each possible representation
--> 185 y_type, y_true, y_pred = _check_targets(y_true, y_pred)
186 check_consistent_length(y_true, y_pred, sample_weight)
187 if y_type.startswith('multilabel'):
/usr/local/lib/python3.6/dist-packages/sklearn/metrics/_classification.py in _check_targets(y_true, y_pred)
78 y_pred : array or indicator matrix
79 """
---> 80 check_consistent_length(y_true, y_pred)
81 type_true = type_of_target(y_true)
82 type_pred = type_of_target(y_pred)
/usr/local/lib/python3.6/dist-packages/sklearn/utils/validation.py in check_consistent_length(*arrays)
206 """
207
--> 208 lengths = [_num_samples(X) for X in arrays if X is not None]
209 uniques = np.unique(lengths)
210 if len(uniques) > 1:
/usr/local/lib/python3.6/dist-packages/sklearn/utils/validation.py in <listcomp>(.0)
206 """
207
--> 208 lengths = [_num_samples(X) for X in arrays if X is not None]
209 uniques = np.unique(lengths)
210 if len(uniques) > 1:
/usr/local/lib/python3.6/dist-packages/sklearn/utils/validation.py in _num_samples(x)
148
149 if hasattr(x, 'shape') and x.shape is not None:
--> 150 if len(x.shape) == 0:
151 raise TypeError("Singleton array %r cannot be considered"
152 " a valid collection." % x)
TypeError: object of type 'Column' has no len()
since i'm new to python it's difficult to find .... any helpful suggestions are welcome..thanks
Aucun commentaire:
Enregistrer un commentaire