Testing quality of predictions

Hi,

In the Machine Learning Fundamentals/Evaluating Model Performance
I just don’t understand where the 'new_listing" parameter of the function 'predict_price" comes from. It seems that in last section “Introduction to K-Nearest Neighbors”, the parameter new_listing was mannually assigned. However, in the script of this section, where did we get the “new_listing” parameter??? I am so confused and stuck here for 3 days. Could you please help? Thank you!

The code was here
train_df = dc_listings.iloc[0:2792]
test_df = dc_listings.iloc[2792:]

def predict_price(new_listing):
temp_df = train_df.copy()
temp_df[‘distance’] = temp_df[‘bathrooms’].apply(lambda x: np.abs(x - new_listing))
temp_df = temp_df.sort_values(‘distance’)
nearest_neighbors_prices = temp_df.iloc[0:5][‘price’]
predicted_price = nearest_neighbors_prices.mean()
print(new_listing)
return predicted_price

test_df[‘predicted_price’] = test_df[‘accommodates’].apply(predict_price)

test_df[‘predicted_price’] = test_df[‘bathrooms’].apply(predict_price)

Hi wtche,

New listing just represents an expected input into the function. It is not calling an existing variable from somewhere else, but just a placeholder for whatever target you give it.

Let me know if this is helpful. If you need more, please provide the link to the lesson.