Created
August 24, 2019 00:22
-
-
Save kperry2215/593626504507cf75978a31a447c23f59 to your computer and use it in GitHub Desktop.
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
#Add in a couple anomalous data points for detection by the algorithm | |
anomaly_dictionary={80: 3.1, | |
200: 3, | |
333: 1, | |
600: 2.6, | |
710: 2.1, | |
890: 2.3, | |
1100: 1, | |
1211: 2.6, | |
1309: 2.3} | |
#Set default for Artificially_Generated_Anomaly column to 0 | |
gasoline_price_df.loc[:,'Artificially_Generated_Anomaly']=0 | |
#Create fake anomaly values based on anomaly_dictionary | |
for index, anomaly_value in anomaly_dictionary.items(): | |
gasoline_price_df.loc[index,'Gasoline_Price']=anomaly_value | |
#Create a column to indicate Anomalies | |
gasoline_price_df.loc[index,'Artificially_Generated_Anomaly']=1 | |
#Re-visualize data with artificially generated anomalies | |
scatterplot_with_color_coding(gasoline_price_df['Date'], | |
gasoline_price_df['Gasoline_Price'], | |
gasoline_price_df['Artificially_Generated_Anomaly'], | |
'Date', | |
'Gasoline Price (Dollars Per Gallon)', | |
'Gasoline Prices, Color-Coded on Real/Artificially Generated Data Points') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment