image_output_1.png
from pandas import DataFrame

from sklearn.tree import DecisionTreeRegressor

import pandas as pd
from pandas import DataFrame
performance = {'id': [1, 2, 3, 4], 'date': ['19/12/2018', '20/12/2018', '21/12/2018', '22/12/2018'], 'time': [45, 50, 90, 50], 'km': [6.0, 5.5, 6.0, 4.0], 'rider_performance': [3, 4, 4, 4], 'horse_performance': [4, 4, 5, 5], 'avg_performance': [3.5, 4.0, 4.5, 4.5]}
df = DataFrame(performance, columns=['Id', 'date', 'time', 'km', 'rider_performance', 'horse_performance', 'avg_performance'])
df

time_graph = df.plot.bar(x="date", y="time", rot=0)
time_graph.set_xlabel("Date")
time_graph.set_ylabel("Time")

km_graph = df.plot.bar(x="date", y="km", rot=0)
km_graph.set_xlabel("Date")
km_graph.set_ylabel("Km")

rider_performance_graph = df.plot.bar(x="date", y="rider_performance", rot=0)
rider_performance_graph.set_xlabel("Date")
rider_performance_graph.set_ylabel("Rider perforamce")

horse_performance_graph = df.plot.bar(x="date", y="horse_performance", rot=0)
horse_performance_graph.set_xlabel("Date")
horse_performance_graph.set_ylabel("Horse perforamce")

avg_performance_graph = df.plot.bar(x="date", y="avg_performance", rot=0)
avg_performance_graph.set_xlabel("Date")
avg_performance_graph.set_ylabel("Average perforamce")

from sklearn.tree import DecisionTreeRegressor
y = df.horse_performance
features = ['time', 'km', 'rider_performance']
X = df[features]
horse_performance_model = DecisionTreeRegressor(random_state=1)
horse_performance_model.fit(X, y)
predictions = horse_performance_model.predict(X)
df

y2 = df.rider_performance
features2 = ['time', 'km', 'horse_performance']
X2 = df[features2]
rider_performance_model = DecisionTreeRegressor(random_state=1)
rider_performance_model.fit(X2, y2)
predictions2 = rider_performance_model.predict(X2)
df

y3 = df.km
features3 = ['time']
X3 = df[features3]
km_model = DecisionTreeRegressor(random_state=1)
km_model.fit(X3, y3)
predictions3 = km_model.predict(X3)
df

y4 = df.time
features4 = ['km']
X4 = df[features4]
time_model = DecisionTreeRegressor(random_state=1)
time_model.fit(X4, y4)
predictions4 = time_model.predict(X4)
df

y5 = df.km
features5 = ['time', 'rider_performance']
X5 = df[features5]
km_model2 = DecisionTreeRegressor(random_state=1)
km_model2.fit(X5, y5)
predictions5 = km_model2.predict(X5)
print(predictions5)
print(predictions3)
df