代写CS909/CS429 Data Mining 2025 Assignment 1: Classification代写Python语言

CS909/CS429 Data Mining 2025 Assignment 1: Classification

Your mission, should you choose to accept it, is to craft a classic machine learning solution for an object recognition task. Picture this: each object is a 28x28 pixel image. You'll get these images as 'flattened' 784-dimensional vectors, each tagged with a label (+1 or -1).

Data Sources:

Training Data (Xtrain): Rows of images for you to train your model.

Training Labels (Ytrain): The label of each image.

Test Data (Xtest): More rows of images for you to test your model's savvy.

The training data (with labels) and test data (without labels) are available to you at the URL: https://github.com/foxtrotmike/CS909/tree/master/2025/A1 

You can load the data with np.loadtxt.

�� Submission Guide:

Whip up a SINGLE Python Notebook containing all your code and answers.

Make sure it includes:

1. A declaration (at the beginning of your submission) of whether you have used any AI tools like ChatGPT for your work and outline in 2 lines the intention behind its use. You are permitted to use such tools as long as you declare them keeping Warwick’s values and academic integrity as a priority.

2. All prediction metrics, presented neatly.

3. The output of every cell executed, so markers can verify your work.

4. A summary table of performance metrics to spotlight the star model.

5. Stick to these libraries: sklearn, numpy, pandas, scipy. If you explore beyond these, include installation code (!pip install xxx).

6. Submit your solution as a single Ipython Notebook through Tabula, complete with comments explaining your code.

7. Also, turn in a prediction file for the test data, formatted as prescribed.

�� Important:

No recycling old solutions, please! This year's dataset is a whole new game compared to previous years, demanding fresh answers.

Question No. 1: (Exploring data) [10% Marks]

Start by loading the training and test data. Once you have it ready, let's explore with these questions:

i. Dataset Overview

a. How many examples of each class are in the training set? And in the test set?

b. Does this distribution of positive and negative examples signify any potential issues in terms of design of the machine learning solution and its evaluation? If so, please explain.

ii. Visual Data Exploration

a. Pick 10 random objects from each class in the training data and display them using plt.matshow. Reshape the flattened 28x28 arrays for this. What patterns or characteristics do you notice?

b. Do the same for 10 random objects from the test set. Are there any peculiarities in the data that might challenge your classifier's ability to generalize?

iii. Choosing the Right Metric

Which performance metric would be best for this task (accuracy, AUC-ROC, AUC-PR, F1, Matthews correlation coefficient, mean squared error etc.)? Define each metric and discuss your reasoning for this choice.

iv. Benchmarking a Random Classifier

Imagine a classifier that produces a random prediction score in the range [-1,+1] for a given input example. What accuracy would you expect it to achieve on both the training and test datasets? Show this through a coding experiment.

v. Understanding AUC Metrics for Random Classifier

What would be the AUC-ROC and AUC-PR for a random classifier in this context? Again, support your answer with a code and discuss the consequences.

Question No. 2: (Nearest Neighbor Classifier) [10% Marks]

Perform. 5-fold stratified cross-validation (https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.StratifiedKFold.html) over the training dataset using a k-nearest neighbour (kNN) classifier and answer the following questions:

i. Start with a k = 5 nearest neighbour classifier. Define and calculate the accuracy, balanced accuracy, AUC-ROC, AUC-PR, F1 and Matthews Correlation Coefficient for each fold using this classifier? Show code to demonstrate the results. Calculate the average and standard deviation for each metric across all folds and show these in a single table. As the KNN classifier in sklearn does not support decision_function, be sure to understand and use the predict_proba function for AUC-ROC and AUC-PR calculations or plotting.

ii. Plot the ROC and PR curves for one fold. What are your observations about the ROC and PR curves? What  part of the ROC curve is more important for this problem and why?

Question No. 3:  [20% Marks] Cross-validation of SVM and RFs

Use 5-fold stratified cross-validation over training data to choose an optimal classifier between: SVMs (linear, polynomial kernels and Radial Basis Function Kernels) and Random Forest Classifiers. Be sure to tune the hyperparameters of each classifier type (C and kernel type and kernel hyper-parameters for SVMs, the number of trees, depth of trees etc. for the Random Forests etc). Report the cross validation results (mean and standard deviation of accuracy, balanced accuracy, AUC-ROC and AUC-PR across fold) of your best model. You may look into grid search as well as ways of pre-processing data (https://scikit-learn.org/stable/modules/preprocessing.html ) (e.g., mean-standard deviation or standard scaling or min-max scaling).

i. Write your strategy for selecting the optimal classifier. Show code to demonstrate the results for each classifier.

ii. Show the comparison of these classifiers in a single consolidated table.

iii. Plot the ROC curves of all classifiers on the same axes for easy comparison.

iv. Plot the PR curves of all classifier on the same axes for comparison.

v. Write your observations about the ROC and PR curves.

Question No. 4 [20% Marks] PCA

i. Reduce the number of dimensions of the training data using PCA to 2 and plot a scatter plot of the training data showing examples of each class in a different color. What are your observations about the data based on this plot?

ii. Reduce the number of dimensions of the training and test data together using PCA to 2 and plot a scatter plot of the training and test data showing examples of each set in a different color (or marker style). What are your observations about the data based on this plot?

iii. Plot the scree graph of PCA and find the number of dimensions that explain 95% variance in the training set.

iv. Reduce the number of dimensions of the data using PCA and perform. classification.  You may want to select different principal components for the classification (not necessarily the first few). What is the (optimal) cross-validation performance of a Kernelized SVM classification with PCA? Remember to perform. hyperparameter optimization!

Question No. 5 Optimal Pipeline [20% Marks]

Develop an optimal pipeline for classification based on your analysis (Q1-Q4). You are free to use any tools or approaches at your disposal. However, no external data sources may be used. Describe your pipeline and report your outputs over the test data set. (You are required to submit your prediction file together with the assignment in a zip folder). Your prediction file should be a single column file containing the prediction score of the corresponding example in Xtest (be sure to have the same order as the order of the test examples in Xtest!). Your prediction file should be named by your student ID, e.g., u100011.csv.

Question No. 6 Another classification problem [20% Marks]

Using the data given to you, consider an alternate classification problem in which the label of an example is based on whether it is a part of the training set (label = -1) or the test set (label = +1). Calculate the average and standard deviation of AUC-ROC using 5-fold stratified cross-validation for a classifier that is trained  to solve this prediction task.

i. What does the value of this AUC-ROC tell you about any differences between training and test sets? Show code for this analysis and clearly explain your conclusions with supporting evidence.

ii. How can you use this experiment to identify and eliminate any systematic differences between training and test sets?

iii. Add random noise and random rotations to training set examples and then check if the AUC-ROC of this predictor changes. Clearly write and explain your observations.

 


热门主题

课程名

mktg2509 csci 2600 38170 lng302 csse3010 phas3226 77938 arch1162 engn4536/engn6536 acx5903 comp151101 phl245 cse12 comp9312 stat3016/6016 phas0038 comp2140 6qqmb312 xjco3011 rest0005 ematm0051 5qqmn219 lubs5062m eee8155 cege0100 eap033 artd1109 mat246 etc3430 ecmm462 mis102 inft6800 ddes9903 comp6521 comp9517 comp3331/9331 comp4337 comp6008 comp9414 bu.231.790.81 man00150m csb352h math1041 eengm4100 isys1002 08 6057cem mktg3504 mthm036 mtrx1701 mth3241 eeee3086 cmp-7038b cmp-7000a ints4010 econ2151 infs5710 fins5516 fin3309 fins5510 gsoe9340 math2007 math2036 soee5010 mark3088 infs3605 elec9714 comp2271 ma214 comp2211 infs3604 600426 sit254 acct3091 bbt405 msin0116 com107/com113 mark5826 sit120 comp9021 eco2101 eeen40700 cs253 ece3114 ecmm447 chns3000 math377 itd102 comp9444 comp(2041|9044) econ0060 econ7230 mgt001371 ecs-323 cs6250 mgdi60012 mdia2012 comm221001 comm5000 ma1008 engl642 econ241 com333 math367 mis201 nbs-7041x meek16104 econ2003 comm1190 mbas902 comp-1027 dpst1091 comp7315 eppd1033 m06 ee3025 msci231 bb113/bbs1063 fc709 comp3425 comp9417 econ42915 cb9101 math1102e chme0017 fc307 mkt60104 5522usst litr1-uc6201.200 ee1102 cosc2803 math39512 omp9727 int2067/int5051 bsb151 mgt253 fc021 babs2202 mis2002s phya21 18-213 cege0012 mdia1002 math38032 mech5125 07 cisc102 mgx3110 cs240 11175 fin3020s eco3420 ictten622 comp9727 cpt111 de114102d mgm320h5s bafi1019 math21112 efim20036 mn-3503 fins5568 110.807 bcpm000028 info6030 bma0092 bcpm0054 math20212 ce335 cs365 cenv6141 ftec5580 math2010 ec3450 comm1170 ecmt1010 csci-ua.0480-003 econ12-200 ib3960 ectb60h3f cs247—assignment tk3163 ics3u ib3j80 comp20008 comp9334 eppd1063 acct2343 cct109 isys1055/3412 math350-real math2014 eec180 stat141b econ2101 msinm014/msing014/msing014b fit2004 comp643 bu1002 cm2030
联系我们
EMail: 99515681@qq.com
QQ: 99515681
留学生作业帮-留学生的知心伴侣!
工作时间:08:00-21:00
python代写
微信客服:codinghelp
站长地图