Question: write a function called task 1 ( data , filter _ value, type _ of _ card ) , wheredata contains all records from the

write a function called task1(data, filter_value, type_of_card), wheredata contains all records from the dataset and filter_value is an area name and type_of_card is the
name of the card provider. The function should return a list containing values from the following questions.
Return all results rounded to two decimal points.
Input:
cos_dist, var, median, corr, pca = task1(data, 'Port Lincoln ', 'ANZ ')
output:
[0.06,1337142.45,[5.75,7.21],-0.06,[0.73,0.81,0.7,0.93,0.72,...]]
i. cos_dist: Calculate cosine distance between normal and malicious transactions based on
IP_validity_score.
Formula:
=1
(,)=
Output:
print(cos_dist)=0.06
ii. var: Filter transactions based on certain geographical area e.g. Port Lincoln and calculate and display
the variance of transaction amount for a specific area. Note: use the Actual area column from the
dataset. Use sample variance formula for calculation.
Output:
print(var)=1337142.45
iii. median: Filter data based on Type_of_card and then calculate the median of
Authentication_score value for transactions that are in the lower 25th (inclusive) and upper
75th (inclusive) percentile.
Output:
print(median)=[5.75,7.21]
iv. corr: Filter malicious transactions where Actual and Origin places are different. Calculate
elementwise product between Authentication_score and IP_validation_score and then
perform correlation between the resultant vector and Amount column.
Output:
print(corr)=-0.06
v. pca: Create a N x 5 matrix where N is number of rows in the dataset and 5 is the number of
columns, we will call these features (Transaction_type, Entry_mode, Amount,
Authentication_score, and IP_validity_score)(before that you need to convert all

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!