Visualize regression coefficients
Now that you've fit the model, let's visualize its coefficients. This is an important part of machine learning because it gives you an idea for how the different features of a model affect the outcome.
The shifted time series DataFrame (prices_perc_shifted) and the regression model (model) are available in your workspace.
In this exercise, you will create a function that, given a set of coefficients and feature names, visualizes the coefficient values.
Den här övningen är en del av kursen
Machine Learning for Time Series Data in Python
Interaktiv övning med praktiskt arbete
Testa den här övningen genom att slutföra den här exempelkoden.
def visualize_coefficients(coefs, names, ax):
# Make a bar plot for the coefficients, including their names on the x-axis
ax.bar(____, ____)
ax.set(xlabel='Coefficient name', ylabel='Coefficient value')
# Set formatting so it looks nice
plt.setp(ax.get_xticklabels(), rotation=45, horizontalalignment='right')
return ax