This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
custom_title = title + ' – sparse data' + ' - with lowess smoothing: loose (20% bins) and looser (60% bins)' | |
lowess_tight = lowess(sparse_data, sparse_input, frac = .20) | |
lowess_loose = lowess(sparse_data, sparse_input, frac = .60) | |
lowess_list = [(lowess_tight[:,0], lowess_tight[:,1]), (lowess_loose[:,0], lowess_loose[:,1]) ] | |
graph(sparse_input, sparse_data, custom_title, scatter=True, solid_line=False, line_viz = lowess_list) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ground truth linear interpolation | |
title_suffix = 'smooth data' + ' - linear interpolation only' | |
graph(in_array, curve, title_suffix, scatter=False, solid_line=True) | |
# two LOWESS curves | |
custom_title = title + ' – noisy data' + ' with lowess smoothing: tight (12% bins) and looser (20% bins)' | |
from statsmodels.nonparametric.smoothers_lowess import lowess | |
lowess_tight = lowess(noisy_data, in_array, frac = .12) | |
lowess_loose = lowess(noisy_data, in_array, frac = .2) | |
lowess_list = [(lowess_tight[:,0], lowess_tight[:,1]), (lowess_loose[:,0], lowess_loose[:,1]) ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
custom_title = title + ' – noisy data' + ' - with lowess curve (Seaborn lmplot)' | |
import seaborn as sns | |
import pandas as pd | |
plt.figure(figsize=figure_proportions) | |
plot_df = pd.DataFrame({'time': in_array, 'altitude': noisy_data}) | |
g=sns.lmplot(x='time', y='altitude', data=plot_df, \ | |
lowess=True, scatter_kws={'color': 'green'}, line_kws={'color': 'green'},\ | |
height = figure_proportions[1]*.8, aspect = figure_proportions[0]/figure_proportions[1]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
increments = [2, 3, 5, 9] | |
sparse_data_series = pd.Series(sparse_data) | |
mvg_avg_list = [ (sparse_input, sparse_data_series.rolling(inc).mean()) for inc in increments ] | |
title_suffix = ' - sparse data'+ ' - moving average' | |
graph(sparse_input, sparse_data, title_suffix, scatter=True, solid_line=True, line_viz = mvg_avg_list) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sampling_increment = 9 | |
sparse_input = in_array[::sampling_increment] | |
sparse_data = curve[::sampling_increment] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
title_suffix = ' - sparse data' | |
graph(sparse_input, sparse_data, title_suffix, scatter=True, solid_line=False, line_viz = None) | |
z = np.polyfit(sparse_input, sparse_data, 3) | |
p = np.poly1d(z) | |
xp = np.linspace(x_min, x_max, 100) | |
title_suffix = ' - sparse data'+ ' - 3rd dgr polynomial regression' | |
graph(sparse_input, sparse_data, title_suffix, scatter=True, solid_line=False, line_viz = [(xp, p(xp))]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
title_suffix = ' - sparse data' | |
graph(sparse_input, sparse_data, title_suffix, scatter=True, solid_line=False, line_viz = None) | |
m, b = np.polyfit(sparse_input, sparse_data, 1) | |
title_suffix = ' - sparse data'+ ' - with linear regression' | |
graph(sparse_input, sparse_data, title_suffix, scatter=True, solid_line=False, line_viz = [(in_array, m*x+b)]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
title_suffix = ' - sparse data' | |
graph(sparse_input, sparse_data, title_suffix, scatter=True, solid_line=False, line_viz = None) | |
title_suffix = ' - sparse data'+ ' - with linear interpolation' | |
graph(sparse_input, sparse_data, title_suffix, scatter=True, solid_line=True, line_viz = None) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sampling_increment = 15 | |
sparse_input = in_array[::sampling_increment] | |
sparse_data = curve[::sampling_increment] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
title_suffix = ' noisy data '+ ' - with B-Spline' | |
x_interp = np.linspace(x_min, x_max, 100) | |
BSpline = scipy.interpolate.make_interp_spline(in_array, noisy_data, 2) | |
y_BSpline = BSpline(x_interp) | |
graph(x_interp, y_BSpline, title_suffix, scatter=True, solid_line=True, line_viz = None) |
NewerOlder