Skip to content

Instantly share code, notes, and snippets.

View David-Woroniuk's full-sized avatar

David David-Woroniuk

View GitHub Profile
Argument Description
api_key the API key obtained from https://www.worldweatheronline.com/developer/. (str)
attribute_list a list of weather attributes to collect. (list)
city a city for which to retrieve data. (str).
start_date a string in the format YYYY-MM-DD (str).
end_date a string in the format YYYY-MM-DD (str).
frequency the frequency of extracted data, measured in hours. (int)
verbose boolean determining printing during data extraction. (bool) [Default = True]
csv_directory an optional file directory to store the output. (os directory) [Default = None]
dataset = RetrieveByAttribute(api_key, attribute_list, city, start_date, end_date, frequency).retrieve_hist_data()
dataset = HistoricalLocationWeather(api_key, city, start_date, end_date, frequency).retrieve_hist_data()
attributes = DetermineListOfAttributes(api_key, verbose = True).retrieve_list_of_options()
pip install WorldWeatherPy
from WorldWeatherPy import DetermineListOfAttributes
from WorldWeatherPy import HistoricalLocationWeather
from WorldWeatherPy import RetrieveByAttribute
def plot_outliers(data):
'''
This function determines the position of the outliers within the time-series,
which are subsequently plotted.
Arguments:
data: the initial dataset (Pandas DataFrame).
Returns:
fig: a visual representation of the outliers present in the series, as
def generate_testing_loss(test_value):
'''
This function uses the model to predict anomalies within the test set.
Additionally, this function generates the 'anomalies' global variable,
containing the outliers identified by the RNN.
Arguments:
test_value: an array of testing values (numpy array).
Returns:
# now call the above function:
test_value = normalise_testing_values(testing_data['Volume'], training_mean, training_std)
def normalise_testing_values(data, training_mean, training_std):
'''
This function uses the training mean and standard deviation to normalise
the testing data, generating a numpy array of test values.
Arguments:
data: the data to be used in model testing (Pandas DataFrame column).
mean: the training set mean (float).
std: the training set standard deviation (float).
def reconstruction_error(x_train):
'''
This function calculates the reconstruction error and displays a histogram of
the training mean absolute error.
Arguments:
x_train: 3D data to be used in model training (numpy array).
Returns:
fig: a visual representation of the training MAE distribution.