I'm currently reading a textbook studying machine learning and I came across a strange variable in the example code.
class Regression(object):
# __init__
# set_data
def regress(self, query_point):
"""
Calculates predicted value for house with particular parameters
:param query_point: pandas series with house parameters
:return: house value
"""
_, indexes = self.kdtree.query(query_point, self.k)
value = self.metric(self.values.iloc[indexes])
if np.isnan(value):
raise Exception('Unexpected result')
else:
return value
I notice the line _, indexes = self.kdtree.query(query_point, self.k), uses multiple assignment. Its first variable in an underscore. This variable is never used again in the method. This makes me think that the book just uses ' _ ' as a throw away variable. This is reinforced by further example code using ' _ ' as a for loop variable.
Does this follow any kind of known convention? Perhaps this is a convention handmedown from another language? I've never seen a bare underscore used a variable before and it really threw me off.