San Jose State University Credit Card Fraud Detection Programming Task


As discussed in Lesson 27, can use a supervised or unsupervised algorithm to detect credit card fraud. This assignment is for you to try it yourself if you are interested. Also, It can replace your lowest quiz score if the % score of this assignment is higher than that.  
Step 0: Clean Data
Obtain data from Kaggle (Links to an external site.). Remove all duplicates. For the attribute “class”, change 0 to -1 so that -1 represents normal and +1 represents fraud. After this, the resulting dataset should contain 473 fraud and 283253 normal transactions. 
Step 1: Scale Time & Amount
All other features were PCA transformed, except for Time & Amount. However, the ranges of these 2 features differ a lot. Therefore, the data under ‘Time’ and ‘Amount’ need to be scaled so that none of the features will weigh in a lot more. Choose an appropriate scaler (can refer to Compare the effect of different scalers on data with outliers (Links to an external site.)) to scale. 
Step 2: Re-sample Data
The data set is extremely unbalanced: only 0.17% of data entries are fraud transactions, which is expected since fraud should be abnormal. Partition data so that 20% of data is the testing data and 80% of data is the training data (make sure both parts have fraud transactions!). Optionally, you can apply 5-fold cross-validation (can refer to sklearn.model_selection.KFold (Links to an external site.)). For the training data ONLY,  choose appropriate resampling technique(s) (can refer to Under-sampling methods (Links to an external site.) and Over-sampling methods (Links to an external site.)) to resample the training data. DO NOT resample testing data.
Step 3: Train Model
Pick a model that can be used on this problem (can refer to Credit Card + EDA + (25+) Models For Beginners (Links to an external site.)). Train the model using the resampled training data.
Step 4: Analyze Result
Use your testing data to score your model. At least compute the Accuracy, Precision & Recall. Feel free to explore more scoring options (Links to an external site.).
Finally, choose 1 thing to adjust, and compare the results. That is, keep everything except…
Scaler in step 1, to check the effect of different scalers (or the same scaler with different parameters);
Or resampling method in step 2, to check the effect of different resampling methods (or the same method with different parameters);
Or the model in step 3, to check the effect of different models (or the same model with different parameters).
Adjusting & testing one of them is enough. If you do more, you may get some extra credits. Also, try to explain the reason for the different results you see.
Resources to Use
You probably want to write code in Python since those pre-written machine learning packages (scikit-learn (Links to an external site.), imbalanced-learn, etc (Links to an external site.).) are written in Python. A Jupyter notebook should be enough for you to write and run your code.

1 attachmentsSlide 1 of 1attachment_1attachment_1

Unformatted Attachment Preview

Extra Assignment 2
Step O Finished
0.5 pts
Full Marks
O pts
No Marks
0.5 pts
Step 1 Finished
1 pts
Full Marks
O pts
No Marks
1 pts
Step 2 Finished
2 pts 1 pts
Full Marks Testing data also resampled
0.5 pts
Only partitioned, no resampling
O pts
No Marks 2 pts
Step 3 Finished
1.5 pts
Full Marks
O pts
No Marks
1.5 pts
Step 4 Finished
3 pts
O pts
1 pts
No comparsion
Full Marks
No Marks
3 pts
All Required Files Submitted 2 pts
Full Marks
O pts
No Marks
2 pts
Total Points: 10

Purchase answer to see full

Program code

jupyter notebook

unsupervised algorithm

User generated content is uploaded by users for the purposes of learning and should be used following Studypool’s honor code & terms of service.

Reviews, comments, and love from our customers and community:

Article Writing

Keep doing what you do, I am really impressed by the work done.



PowerPoint Presentation

I am speechless…WoW! Thank you so much!

Stacy V.

Part-time student

Dissertation & Thesis

This was a very well-written paper. Great work fast.

M.H.H. Tony


Annotated Bibliography

I love working with this company. You always go above and beyond and exceed my expectations every time.

Francisca N.


Book Report / Review

I received my order wayyyyyyy sooner than I expected. Couldn’t ask for more.

Mary J.


Essay (Any Type)

On time, perfect paper

Prof. Kate (Ph.D)


Case Study

Awesome! Great papers, and early!

Kaylin Green


Proofreading & Editing

Thank you Dr. Rebecca for editing my essays! She completed my task literally in 3 hours. For sure will work with her again, she is great and follows all instructions

Rebecca L.


Critical Thinking / Review

Extremely thorough summary, understanding and examples found for social science readings, with edits made as needed and on time. Transparent

Arnold W.




Joshua W.


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>