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))
class Person:
def __init__(self,name = "n/a",age=0,adress="none"):
self.__name = name
self.__age = age
self.__adress = adress
inputfile = "human.txt"
outputfile = "persons.txt"
myfile1 = open(inputfile,mode="r")
# myfile2 = open(outputfile,mode="w")
data = dict()
for num,line in enumerate(myfile1,1):
text_line = line.split(' ')
data['person '+ str(num)] = Person(name=text_line[0], age=int(text_line[2]), adress=text_line[3])
print(data)