from sklearn.linear_model import LinearRegression
def get_trand(l):
data = [[i] for i in l]
x = [[i] for i in range(len(l))]
lr = LinearRegression().fit(x, data)
a = lr.coef_[0][0]
a = round(a, ndigits=1)
if a > 0:
return 'up'
elif a < 0:
return 'down'
else:
return 'flat'
l = [29, 21, 40, 23, 19, 50, 34, 10, 42, 59]
print(get_trand(l))