Last active
December 20, 2022 06:35
-
-
Save mohneesh7/b51a668ffb49f426cdb36b89cb0319e9 to your computer and use it in GitHub Desktop.
savgol_filter
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
import pandas as pd | |
import plotly.graph_objects as go | |
from scipy.signal import savgol_filter | |
data = pd.read_csv('DOGE-USD.csv', index_col=0, parse_dates=True) | |
data.head() | |
# Savitzky-Golay filter | |
y_filtered = savgol_filter(data.High, 11, 2) | |
y_filtered_7_3 = savgol_filter(data.High, 7, 3) | |
f = go.Figure() | |
f.add_trace(go.Scatter(x=data.index, y=y_filtered, name="High Smoothed (11, 2)")) | |
f.add_trace(go.Scatter(x=data.index, y=y_filtered_7_3, name="High Smoothed (7, 3)")) | |
f.add_trace(go.Scatter(x=data.index, y=data.High, name="High Unsmoothed")) | |
f.update_layout( | |
title="DOGE-USD", | |
xaxis_title="Date-Time axis", | |
yaxis_title="USD", | |
legend_title="Legend", | |
font=dict( | |
family="Courier New, monospace", | |
size=18, | |
color="RebeccaPurple" | |
) | |
) | |
f.show()ow() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment