0
0
SciPydata~10 mins

Interpolation for smoothing data in SciPy - Interactive Code Practice

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

Complete the code to import the interpolation function from scipy.

SciPy
from scipy.interpolate import [1]
Drag options to blanks, or click blank then click option'
Ainterp1d
Binterpolate
Csmooth
Dinterpolator
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'interpolate' which is the module, not the function.
Trying to import 'smooth' which does not exist in scipy.interpolate.
Using 'interpolator' which is not a valid function.
2fill in blank
medium

Complete the code to create an interpolation function for given x and y data.

SciPy
f = interp1d(x, y, kind=[1])
Drag options to blanks, or click blank then click option'
A'nearest'
B'linear'
C'average'
D'smooth'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'smooth' which is not a valid kind.
Using 'average' which is not a valid kind.
Confusing 'nearest' with smoothing, but it creates step-like interpolation.
3fill in blank
hard

Fix the error in the code to evaluate the interpolation function at new points.

SciPy
y_new = f([1])
Drag options to blanks, or click blank then click option'
Ax_new
By_new
Cx
Df
Attempts:
3 left
💡 Hint
Common Mistakes
Passing y_new which is undefined or wrong.
Passing x which is original data, not new points.
Passing the function f itself instead of input values.
4fill in blank
hard

Fill both blanks to create a smooth interpolation using cubic method and evaluate at new points.

SciPy
f = interp1d(x, y, kind=[1])
y_smooth = f([2])
Drag options to blanks, or click blank then click option'
A'cubic'
Bx_new
C'linear'
Dy_new
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'linear' instead of 'cubic' for smooth interpolation.
Passing y_new instead of x_new to the function.
Confusing the order of blanks.
5fill in blank
hard

Fill all three blanks to create a dictionary of smoothed values for words longer than 3 letters.

SciPy
smoothed = [1]: f([2]) for [3] in words if len([3]) > 3}
Drag options to blanks, or click blank then click option'
Aword
Bx_new
Dx
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names for key and loop variable.
Passing x or word to the function instead of x_new.
Not filtering words by length correctly.