Question: In this task, you are to write a function card _ statistics ( UQ _ card, details ) where UQ _ card ( list of
In this task, you are to write a function cardstatisticsUQcard, details where UQcard list of unique cards and details list of list for relevant card details are output from Task You will calculate the following statistics.
Calculate the absolute timestamp difference for consecutive transactions for each card for the last transaction you can compare it with the preceding one
Calculate the minimum, maximum, average and standard deviation of timestamp difference for transactions for each card.
Calculate the average and standard deviation of the amount for each card.
Count how many times the actual and origin places are different for each card for cards with normal transactions the total count should be lower compared to cards that have malicious transactions
Finally, cardstatistics function will return three lists: timedif a list containing timestamp differences for each transaction, labels a list containing associated label for each transaction in the same order as timedif data from the class column in the CSV file and stats a list containing card specific statistics items per card in the following, card numbers, average, minimum, maximum and standard deviation of timestamp, average and standard deviation of amount, and count.
The code must pass the following tests:
Test Expected
data readdataCreditCardcsv
preprocesseddata carddetailsdata
UQcard, details uniquecardpreprocesseddata
timedif, labels, stats cardstatisticsUQcard, details
printstats
data readdataCreditCardcsv
preprocesseddata carddetailsdata
UQcard, details uniquecardpreprocesseddata
timedif, labels, stats cardstatisticsUQcard, details
printtimedif
sample data from file:
TransactionID TimeStamp CardNumber Transactiontype Typeofcard Entrymode Amount Actual Origin Class
EFTPOS Mastercard Magnetic Stripe Warren Warren
EFTPOS AusWide Magnetic Stripe Tibooburra Tibooburra
ATM UniBank NFC Darwin Darwin
Internet AusWide Magnetic Stripe Bairnsdale Bairnsdale
ATM Visa Magnetic Stripe Williams Williams
EFTPOS AusWide Manual Bathurst Bathurst
Internet AusWide NFC Yarrawonga Yarrawonga
EFTPOS UniBank NFC BurnieDevonport BurnieDevonport
ATM American Express Chip Card Read Scone Scone
Internet American Express Magnetic Stripe Bowen Bowen
EFTPOS Mastercard Magnetic Stripe Bathurst Nowra
Internet UniBank Manual Tumut Tumut
EFTPOS American Express NFC Kununurra Kununurra
ATM AusWide Magnetic Stripe Forbes Forbes
ATM Discover NFC Esperance Esperance
ATM American Express Chip Card Read Muswellbrook Muswellbrook
ATM AusWide Magnetic Stripe Swansea Swansea
Internet UniBank Manual Dubbo Dubbo
EFTPOS Discover Magnetic Stripe Toodyay Toodyay
ATM Mastercard Magnetic Stripe Warracknabeal Warracknabeal
Internet Mastercard NFC Ulverstone Ulladulla
EFTPOS Discover Magnetic Stripe Pittsworth Pittsworth
EFTPOS Mastercard Chip Card Read Gladstone Gladstone
Internet AusWide Manual Streaky Bay Streaky Bay
ATM UniBank NFC Shepparton Shepparton
EFTPOS American Express Magnetic Stripe Emerald Emerald
ATM American Express NFC Lithgow Lithgow
EFTPOS Visa Magnetic Stripe Tumby Bay Tumby Bay
Internet American Express Chip Card Read Bowen Bowen
ATM ANZ Magnetic Stripe Ballarat Ballarat
EFTPOS ANZ Manual Geelong Hobart
Internet Visa Manual Moss Vale Moss Vale
ATM Visa NFC Bunbury Bunbury
ATM Visa Chip Card Read Wentworth Wentworth
ATM AusWide Manual Wallaroo Wallaroo
