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
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] |
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
dataset = RetrieveByAttribute(api_key, attribute_list, city, start_date, end_date, frequency).retrieve_hist_data() |
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
dataset = HistoricalLocationWeather(api_key, city, start_date, end_date, frequency).retrieve_hist_data() |
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
attributes = DetermineListOfAttributes(api_key, verbose = True).retrieve_list_of_options() |
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
pip install WorldWeatherPy | |
from WorldWeatherPy import DetermineListOfAttributes | |
from WorldWeatherPy import HistoricalLocationWeather | |
from WorldWeatherPy import RetrieveByAttribute |
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
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 |
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
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: |
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
# now call the above function: | |
test_value = normalise_testing_values(testing_data['Volume'], training_mean, training_std) |
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
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). |
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
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. |
NewerOlder