OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

arrange values and labels on plots xticks

  • Thread starter Thread starter Atharv Patil
  • Start date Start date
A

Atharv Patil

Guest
Code:
plt.plot(neighbors, train_scores, label="Train Score")
plt.plot(neighbors, test_scores, label="Test Score")
plt.xticks(np.arange(1,21,1))
plt.xlabel("Number of Neighbors")
plt.ylabel("Score")
plt.legend()
plt.show()

`print(f"Maximum KNN score on the test data is: {max(test_scores)*100:.2f}%")`

it gives me a Type error

Code:
TypeError                                 Traceback (most recent call last)
Cell In[62], line 5
      3 plt.plot(neighbors, train_scores, label="Train Score")
      4 plt.plot(neighbors, test_scores, label="Test Score")
----> 5 plt.xticks(np.arange(1,21,1))
      6 plt.xlabel("Number of Neighbors")
      7 plt.ylabel("Score")

TypeError: 'int' object is not callable

I tried looking if mistakly i have use x_ticks as s varialble but it is not the case
<pre><code>plt.plot(neighbors, train_scores, label="Train Score")
plt.plot(neighbors, test_scores, label="Test Score")
plt.xticks(np.arange(1,21,1))
plt.xlabel("Number of Neighbors")
plt.ylabel("Score")
plt.legend()
plt.show()

`print(f"Maximum KNN score on the test data is: {max(test_scores)*100:.2f}%")`
</code></pre>
<p><strong>it gives me a Type error</strong></p>
<pre><code>TypeError Traceback (most recent call last)
Cell In[62], line 5
3 plt.plot(neighbors, train_scores, label="Train Score")
4 plt.plot(neighbors, test_scores, label="Test Score")
----> 5 plt.xticks(np.arange(1,21,1))
6 plt.xlabel("Number of Neighbors")
7 plt.ylabel("Score")
</code></pre>
<p>TypeError: 'int' object is not callable</p>
<p>I tried looking if mistakly i have use x_ticks as s varialble but it is not the case</p>
 

Latest posts

D
Replies
0
Views
1
Dhanushka Amarakoon
D
S
Replies
0
Views
1
Shikhar Ambashta
S
Top