Skip to content
Advertisement

TypeError: plotImages() got an unexpected keyword argument ‘n_images’ Python

The error i got: TypeError: plotImages() got an unexpected keyword argument ‘n_images’

Please do let me know if you have an idea. This is the code:

categoriesList=["airplane","automobile","bird", "cat", "deer", "dog", "frog", "horse", "ship", "truck"]

import matplotlib.pyplot as plt
import random
def plotImages(x_test, images_arr, labels_arr, nx_images=8):
    fig, axes = plt.subplots(n_images, n_images, figsize=(9,9))
    axes = axes.flatten()
    
    for i in range(100):
        rand = random.randint(0, x_test.shape[0] -1)
        img = images_arr[rand]
        ax = axes[i]
    
        ax.imshow( img, cmap="Greys_r")
        ax.set_xticks(())
        ax.set_yticks(())
        
        predict_x=model2000.predict([[x_test[rand]]])
        label=categoriesList[predictions[0]]  
        
        if labels_arr[rand][predictions[0]] == 0:
            ax.set_title(label, fontsize=18 - n_images, color="red")
        else:
            ax.set_title(label, fontsize=18 - n_images) 
        
    plot = plt.tight_layout()
    return plot
  
display (plotImages(x_test, data_test_picture, y_test, n_images=10))


  

Advertisement

Answer

You defined the argument as nx_images in function definition, but doesn’t seem to use it anywhere in the code. Try changing it.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement