0
0
ML Pythonprogramming~10 mins

Residual analysis in ML Python - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to calculate residuals from actual and predicted values.

ML Python
residuals = actual - [1]
Drag options to blanks, or click blank then click option'
Amedian
Bactual
Cmean
Dpredicted
Attempts:
3 left
2fill in blank
medium

Complete the code to plot residuals against predicted values using matplotlib.

ML Python
plt.scatter([1], residuals)
plt.axhline(y=0, color='r', linestyle='--')
plt.xlabel('Predicted Values')
plt.ylabel('Residuals')
plt.show()
Drag options to blanks, or click blank then click option'
Aactual
Bpredicted
Cresiduals
Dmean
Attempts:
3 left
3fill in blank
hard

Fix the error in the code to compute residuals correctly.

ML Python
residuals = [1] - predicted
Drag options to blanks, or click blank then click option'
Aactual
Bmean
Cpredicted
Dmedian
Attempts:
3 left
4fill in blank
hard

Fill both blanks to create a dictionary of residuals for each data point where residual is positive.

ML Python
positive_residuals = {i: residuals[i] for i in range(len(residuals)) if residuals[i] [1] 0 and residuals[i] [2] 0}
Drag options to blanks, or click blank then click option'
A>
B<
C==
D!=
Attempts:
3 left
5fill in blank
hard

Fill all three blanks to compute mean squared error (MSE) from residuals.

ML Python
mse = sum([1]**2 for [2] in residuals) / [3]
Drag options to blanks, or click blank then click option'
Aresidual
Bresiduals
Clen(residuals)
Drange(len(residuals))
Attempts:
3 left