- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi guys, I am on Part 3: Model Analysis and I am getting this error when I run the code. I updated the first variable to true_classes and the second variables to predicted_classes, and then clicked Run. How do I solve this?
import matplotlib.pyplot as plt
%matplotlib inline
import scikitplot as skplt
[print(k, ":", v) for k,v in enumerate(class_labels)]
true_classes = [class_labels
predicted_classes = [class_labels
skplt.metrics.plot_confusion_matrix(
true_map_classes,
predicted_map_classes,
labels=class_labels,
x_tick_rotation=90,
figsize=(12,12))
I get this error:
TypeError Traceback (most recent call last) <ipython-input-7-7667dcf96029> in <module>
4
5 [print(k, ":", v) for k,v in enumerate(class_labels)]
----> 6 true_classes = [class_labels
7 predicted_classes = [class_labels
8
TypeError: list indices must be integers or slices, not str
- Tags:
- General Support
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thanks for reaching out to us.
Could you please try the below code snippet.
import matplotlib.pyplot as plt %matplotlib inline import scikitplot as skplt [print(k, ":", v) for k,v in enumerate(class_labels)] true_classes = [class_labelsfor x in true_classes] predicted_classes = [class_labels for x in predicted_classes] skplt.metrics.plot_confusion_matrix( true_classes, predicted_classes, labels=class_labels, x_tick_rotation=90, figsize=(12,12))
If you are again getting the same error, before running this code please run the jupyter cell which is just above this code snippet in part 3 of the course.
If you face any further issue please let us know.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, it finally worked. I just copy pasted the code above.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your confirmation. We are closing this thread. Feel free to open a new thread if you have any further issues.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page