Skip to content

C1_W3_Lab02: some thing wrong about the function: plt_one_addpt_onclick() #61

@EggXiaolu

Description

@EggXiaolu

Describe the Error
When I was running:
addpt = plt_one_addpt_onclick(x_train, y_train, w_in, b_in, logistic=False)
the following error occurred:

AttributeError                            Traceback (most recent call last)
Cell In[4], [line 4](vscode-notebook-cell:?execution_count=4&line=4)
      2 b_in = 0
      3 plt.close('all') 
----> [4]addpt = plt_one_addpt_onclick( x_train,y_train, w_in, b_in, logistic=False)

File ~/Machine-Learning-Specialization-Coursera/C1 - Supervised Machine Learning - Regression and Classification/week3/Optional Labs/plt_one_addpt_onclick.py:66, in plt_one_addpt_onclick.__init__(self, x, y, w, b, logistic)
     64 self.bthresh = CheckButtons(axthresh, ('Toggle 0.5 threshold (after regression)',))
     65 self.bthresh.on_clicked(self.thresh)
---> [66]self.resize_sq(self.bthresh)

File ~/Machine-Learning-Specialization-Coursera/C1 - Supervised Machine Learning - Regression and Classification/week3/Optional Labs/plt_one_addpt_onclick.py:200, in plt_one_addpt_onclick.resize_sq(self, bcid)
    170 """ resizes the check box """
    171 # future reference
    172 # print(f"width  : {bcid.rectangles[0].get_width()}")
    173 # print(f"height : {bcid.rectangles[0].get_height()}")
   (...)    197 #             bcid._lines[0][0].set_ydata([ymax, ymin])
    198 #             bcid._lines[0][1].set_ydata([ymin, ymax])
--> [200] h = bcid.rectangles[0].get_height()
    201 bcid.rectangles[0].set_height(3 * h)
    203 ymax = bcid.rectangles[0].get_bbox().y1

AttributeError: 'CheckButtons' object has no attribute 'rectangles'

Expected behavior
it runs normally and outputs an interactive image.

Environment:

  • OS: Mac OS (15.6.1)
  • VS Code: 1.105.1
  • jupyter core: 5.8.1
  • Python: 3.13.2
  • matplotlib: 3.10.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions