# Resolved: Practice Exam - Question 1

Dear Professor Hristina

I am having difficulty getting the class prediction for question 1, I am writing the code as follows however I am not getting the right answer, could you explain to me how I should call the predict function to get the right classes for the model?

x_train, y_train = make_blobs(n_samples = [50]*4,

n_features = 2,

centers = [(-1, 1),(-2,5), (4, 0),(3,6)],

cluster_std = 2,

random_state = 365)

x_test, y_test = make_blobs(n_samples = [40]*4,

n_features = 2,

centers = [(-1, 1),(-2,5), (4, 0),(3,6)],

cluster_std = 2,

random_state = 365)

data = [x_train,y_train]

data = pd.DataFrame(data = x_train, columns = ['year', 'price'])

data['Target'] = y_train

data

clf = KNeighborsClassifier(n_neighbors = 5, weights = 'uniform')

clf.fit(x_train, y_train)

predictions = clf.predict(x_test)

prediction[0]

Hey Mani,

Thank you for reaching out and for engaging with the Machine Learning with KNN course!

Your code looks great! Make sure that you change the `n_neighbors`

and the `weights`

parameters in the following line of code

`clf = KNeighborsClassifier(n_neighbors = 5, weights = 'uniform')`

based on the model. First, change the parameters to **3 neighbors and uniform weights**, then, to **5 neighbors and uniform weights**, and lastly, to **5 neighbors and distance weights**. For each of these cases, you should get a prediction matching the correct answer.

Hope this helps! Let me know if you still encounter issues with this question.

Kind regards,

365 Hristina