首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
代写DTS304TC、代做Java/c++程序语言
项目预算:
开发周期:
发布时间:
要求地区:
XJTLU Entrepreneur College (Taicang) Cover Sheet
Module code and Title DTS304TC Machine Learning
School Title School of AI and Advanced Computing
Assignment Title Assessment Task 1
Submission Deadline 23:59, 24th March (Sunday), 2024
(China Time, GMT + 8)
Final Word Count N/A
If you agree to let the university use your work anonymously for teaching and
learning purposes, please type “yes” here.
I certify that I have read and understood the University’s Policy for dealing with Plagiarism, Collusion
and the Fabrication of Data (available on Learning Mall Online). With reference to this policy I certify
that:
? My work does not contain any instances of plagiarism and/or collusion.
My work does not contain any fabricated data.
By uploading my assignment onto Learning Mall Online, I formally declare that all of the
above information is true to the best of my knowledge and belief.
Scoring – For Tutor Use
Student ID
Stage of Marking Marker
Code
Learning Outcomes Achieved (F/P/M/D)
(please modify as appropriate)
Final
Score
A B C
1
st Marker – red pen
Moderation
– green pen
IM
Initials
The original mark has been accepted by the moderator (please circle
as appropriate):
Y / N
Data entry and score calculation have been checked by another tutor
(please circle):
Y
2
nd Marker if
needed – green pen
For Academic Office Use Possible Academic Infringement (please tick as appropriate)
Date
Received
Days
late
Late
Penalty
? Category A
Total Academic Infringement Penalty (A,B,
C, D, E, Please modify where necessary)
_____________________
? Category B
? Category C
? Category D
? Category E
DTS304TC Machine Learning
Coursework – Assessment Task 1
Submission deadline: TBD
Percentage in final mark: 50%
Learning outcomes assessed:
A. Demonstrate a solid understanding of the theoretical issues related to problems that machine learning
algorithms try to address.
B. Demonstrate understanding of properties of existing ML algorithms and new ones.
C. Apply ML algorithms for specific problems.
Individual/Group: Individual
Length: The assessment has a total of 4 questions which gives 100 marks. The submitted file must be in
pdf format.
Late policy: 5% of the total marks available for the assessment shall be deducted from the assessment
mark for each working day after the submission date, up to a maximum of five working days
Risks:
? Please read the coursework instructions and requirements carefully. Not following these instructions
and requirements may result in loss of marks.
? The formal procedure for submitting coursework at XJTLU is strictly followed. Submission link on
Learning Mall will be provided in due course. The submission timestamp on Learning Mall will be
used to check late submission.
__________________________________________________________________
Question 1: Coding Exercise - Heart Disease Classification with Machine Learning (50 Marks)
In this coding assessment, you are presented with the challenge of analyzing a dataset that contains
patient demographics and health indicators to predict heart disease classifications. This entails solving a
multi-class classification problem with five distinct categories, incorporating both categorical and
numerical attributes.
Your initial task is to demonstrate proficiency in encoding categorical features and imputing missing
values to prepare the dataset for training a basic classifier. Beyond these foundational techniques, you are
invited to showcase your advanced skills. This may include hyperparameter tuning using sophisticated
algorithms like the Asynchronous Successive Halving Algorithm (ASHA). You are also encouraged to
implement strategies for outlier detection and handling, model ensembling, and addressing class
imbalance to enhance your model's performance.
Moreover, an external test set without ground truth labels has been provided. Your classifier's
performance will be evaluated based on this set, underscoring the importance of building a model with
strong generalization capabilities.
The competencies you develop during this practical project are not only essential for successfully
completing this assessment but are also highly valuable for your future pursuits in the field of data science.
Throughout this project, you are encouraged to utilize code that was covered during our Lab sessions, as
well as other online resources for assistance. Please ensure that you provide proper citations and links to
any external resources you employ in your work. However, the use of Generative AI for content
generation (such as ChatGPT) is not permitted on all assessed coursework in this module.
Project Steps:
a) Feature Preprocessing (8 Marks)
You are required to demonstrate four key preprocessing steps: loading the dataset, encoding
categorical features, handling missing values, and dividing the dataset into training, validation,
and test sets.
It is crucial to consistently apply the same feature preprocessing steps—including encoding
categorical features, handling missing values, and any other additional preprocessing or custom
modifications you implement—across the training, validation, internal testing, and the externally
provided testing datasets. For efficient processing, you may want to consider utilizing the
sklearn.pipeline and sklearn.preprocessing library functions.
b) Training Classifiers (10 Marks)
Train a logistic regression classifier with parameter tuned using grid search, and a random forest
classifier with parameters tuned using Async Successive Halving Algorithm (ASHA) with
ray[tune] libraries. You should optimize the model's AUC score during the hyperparameter tuning
process.
You should aim to optimize a composite score, which is the average of the classification accuracy
and the macro-averaged F1 score. This objective encourages a balance between achieving high
accuracy overall and ensuring that the classifier performs well across all classes in a balanced
manner, which is especially important in multi-class classification scenarios where class
imbalance might be a concern.
To clarify, your optimization goal is to maximize a composite accuracy metric defined as follows:
accuracy = 0.5 * (f1_score(gt, pred, average='macro') + accuracy_score(gt, pred))
In this formula, f1_score and accuracy_score refer to functions provided by the scikit-learn
library, with f1_score being calculated with the 'macro' average to treat all classes equally.
Ensure that you perform model adjustments, including hyperparameter tuning, on the validation
set rather than the testing set to promote the best generalization of your model.
We have included an illustrative example of how to implement the ASHA using the ray[tune]
library. Please refer to the notebook DTS304TC_ASHA_with_Ray_Tune_Example.ipynb located
in our project data folder for details.
c) Additional Tweaking and External Test Set Benchmark (19 Marks)
You are encouraged to explore a variety of advanced techniques to improve your model's
predictive power.
1. Utilizing different classifiers, for example, XGBoost.
2. Implementing methods for outlier detection and treatment.
3. Creating model ensembles with varied validation splits.
4. Addressing issues of class imbalance.
5. Applying feature engineering strategies, such as creating composite attributes.
6. Implementing alternative validation splitting strategies, like cross-validation or stratified
sampling, to enhance model tuning.
7. Additional innovative and valid methods not previously discussed.
You will be awarded 3 marks for successfully applying any one of these methods. Should you
incorporate two or more of the aforementioned techniques, a total of 6 marks will be awarded.
Please include code comments that explain how you have implemented these additional
techniques. Your code and accompanying commentary should explicitly state the rationale behind
the selection of these supplementary strategies, as well as the underlying principles guiding your
implementation. Moreover, it should detail any changes in performance, including improvements,
if any, resulting from the application of these strategies. An additional 4 marks will be awarded
for a clear and comprehensive explanation. To facilitate a streamlined review and grading
process, please ensure that your comments and relevant code are placed within a separate code
block in your Jupyter notebook, in a manner that is readily accessible for our evaluation.
Additionally, utilize the entire dataset and the previously determined optimal hyperparameters
and classification pipeline to retrain your top-performing classifier. Then, apply this model to the
features in 'dts304tc_a1_heart_disease_dataset_external_test.csv', which lacks true labels, to
produce a set of predictive probability scores. Save these probabilistic scores in a table with two
columns: the first column for patient IDs and the second for the output classification labels.
Export this table to a file named external_test_results_[your_student_id].csv. Submit this file for
evaluation. In the external evaluation conducted by us, your scores will be benchmarked against
the performance of models developed by your classmates. You will receive four marks for
successfully completing the prescribed classifier retraining and submission process. Additionally,
your classifier's benchmark ranking—based on its performance relative to models developed by
your peers—will be assigned five marks, contingent upon your standing in the ranking.
d) Result Analysis (8 Marks)
For your best-performing model, compute critical performance metrics such as precision, recall,
specificity, and the F1 score for each class. Additionally, generate the confusion matrix based on
your internal test set. Ensure that the code for calculating these performance metrics, as well as
the resulting statistics, are clearly displayed within your Jupyter notebook. For ease of review,
position these elements towards the end of your notebook to provide direct access to your
outcomes.
Conduct a feature importance analysis by utilizing the feature importance scoring capabilities
provided by your chosen classifier. What are the top three most important features for classifying
this medicial condition? If your best performing model does not offer feature importance scoring,
you may utilize an alternative model for this analysis. Present the results of the feature
importance analysis within your Jupyter notebook using print statements or code comments.
Place these relevant code and findings towards the end of the notebook to facilitate easy review of
your results.
e) Project Submission Instructions (5 Marks - Important, Please Read!)
Submit your Jupyter notebook in both .ipynb and .PDF formats. Ensure that in the PDF version,
all model execution results, as well as your code annotations and analyses, are clearly visible. It is
critical to maintain a well-organized structure in your Jupyter notebook, complemented by clear
commentary using clean code practices. Your submission's readability and navigability are
crucial; we cannot assign a score if we cannot understand or locate your code and results. You
will receive 5 points for clarity in code structure and quality of code comments.
To maintain the readability of your code when converting your Jupyter notebook to a PDF, ensure
that no single line of code extends beyond the printable page margin, thus preventing line
truncation. If necessary, utilize line continuation characters or implicit line continuation within
parentheses, brackets, or braces in Python to break up longer lines of code. After converting to
PDF, thoroughly review the document to confirm that all code is displayed completely and that
no line truncation has occurred.
If you have written supplementary code that is not contained within the Jupyter notebook, you
must submit that as well to guarantee that your Jupyter notebook functions correctly.
Nevertheless, our primary basis for grading will be the PDF version of your Jupyter notebook.
Please ensure that all necessary code is included so that the notebook can be executed seamlessly,
and your results are reproducible.
Submit the results of your external test as a file named external_test_[your_student_id].csv. This
CSV file must be correctly formatted: the first column must contain patient IDs, and the second
column must list your predicted classification labels. Any deviation from this format may result
in the file being unprocessable by our grading software, and therefore unable to be scored.
Project Material Access Instructions
To obtain the complete set of materials for our project, including the dataset, code, and Jupyter notebook
files, please use the links provided below:
(OneDrive Link): https://1drv.ms/u/s!AoRfWDkanfAYnvcrXTKMGhNzRztf0g?e=JDwmbR
(Baidu Drive Link): https://pan.baidu.com/s/1AXSRYO6ujTu1iNspdkIuUA?pwd=h4js
Download password: h4js
When prompted, use the following password to unlock the zip file: DTS304TC (please note that it is case?sensitive and should be entered in all capital letters).
Additionally, for ease of reference, the project's Jupyter notebooks have been appended to the end of this
document.
Please note that the primary library dependencies for this project include pandas, scikit-learn, xgboost,
and the ray library with the tune module enabled (ray[tune]).
Question 2: Ensemble Learning (18 marks):
Students are required not to use AI models, such as ChatGPT, for assistance with this question.
You should give clear calculation steps and explain the relevant concepts using your own words.
(a) Majority Voting with Independent Classifiers (8 Marks)
1. Given individual classifiers C1, C2, and C3 with statistically independent error rates of 40%, 35%,
and 35% respectively, calculate the accuracy of the majority voting ensemble composed of classifiers
C1, C2, and C3. Provide the steps you use to determine the ensemble's accuracy, assuming the
classifiers' decisions are statistically independent. (5 Marks)
(Hints: Calculate the ensemble 's accuracy by summing the probability that all classifiers are correct with
the probabilities of exactly two classifiers being correct while the third is incorrect)
2. Point out the similarities and differences between the majority voting ensemble method and Random
Forest, emphasizing the strategies employed by Random Forest to attain higher accuracy. (3 Marks)
(b) AdaBoost Algorithm (10 Marks)
Consider the process of creating an ensemble of decision stumps, referred to as ????, through the standard
AdaBoost method.
The diagram above shows several two-dimensional labeled points along with the initial decision stump
we've chosen. This stump gives out binary values and makes its decisions based on a single variable (the
cut-off). In the diagram, there's a tiny arrow perpendicular to the classifier's boundary that shows where
the classifier predicts a +1. Initially, every point has the same weight.
1. Identify all the points in the above diagram that will have their weights increased after adding the
initial decision stump (adjustments to AdaBoost sample weights after the initial stump is used) (2
marks)
2. On the same diagram, draw another decision stump that could be considered in the next round of
boosting. Include the boundary where it makes its decision and indicate which side will result in a +1
prediction. (2 marks)
3. Will the second basic classifier likely get a larger importance score in the group compared to the first
one? To put it another way, will ??2 > ??1? Just a short explanation is needed (Calculations are not
required). (3 marks)
4. Suppose you have trained two models on the same set of data: one with AdaBoost and another with a
Random Forest approach. The AdaBoost model does better on the training data than the Random
Forest model. However, when tested on new, unseen data, the Random Forest model performs better.
What could explain this difference in performance? What can be done to make the AdaBoost model
perform better? (3 marks)
Question 3: K-Means and GMM Clustering (7 marks)
Students are required not to use AI models, such as ChatGPT, for assistance with this question.
You should give clear analysis steps and explain the relevant concepts using your own words.
1. Reflect on the provided data for training and analyze the outcomes of K-Means and GMM techniques.
Can we anticipate identical centroids from these clustering methods? Please state your reasoning. (3
marks)
2. Determine which of the given cluster assignments could be a result of applying K-means clustering,
and which could originate from GMM clustering, providing an explanation for your reasoning. (4
marks)
Question 4 - Reinforcement Learning (25 marks)
Students are required not to use AI models, such as ChatGPT, for assistance with this question.
You should give clear analysis steps and explain the relevant concepts using your own words.
1. Describe the five key components of reinforcement learning using the graph below, explain each of
the components and their relationships. (10 marks.)
import gym
import numpy as np
env = gym.make('CartPole-v1')
state_space_size = env.observation_space.shape[0]
action_space_size = env.action_space.n
q_table = np.zeros((state_space_size, action_space_size))
learning_rate = 0.1
discount_factor = 0.99
epsilon = 0.1
num_episodes = 1000
# Q-learning algorithm
for episode in range(num_episodes):
state = env.reset()
done = False
while not done:
# Exploration-exploitation strategy
if np.random.uniform(0, 1) < epsilon:
action = env.action_space.sample() # Explore
else:
action = np.argmax(q_table[state, :]) # Exploit
# Take action and observe the next state and reward
next_state, reward, done, _ = env.step(action)
# Update Q-value using the Q-learning formula
q_table[state, action] = (1 - learning_rate) * q_table[state, action] + \
learning_rate * (reward + discount_factor * np.max(q_table[next_state, :]))
# Move to the next state
state = next_state
# Testing the learned policy
total_reward = 0
state = env.reset()
while True:
action = np.argmax(q_table[state, :])
state, reward, done, _ = env.step(action)
total_reward += reward
if done:
break
print(f"Total reward: {total_reward}")
2. The questions below refer to the above code example:
a) What is the significance of the exploration-exploitation strategy in reinforcement learning, and how is
it implemented in the code? (5 marks)
b) How would you change this code to use deep learning? You don’t need to write the code, only
describe the major changes you would make and explain the advantage of deep learning approaches
over the Q-table. (5 marks)
c) Describe the current reward function for Cartpole. Design a reward function of your own and explain
your reward function. (5 marks)
.ip… 1/2
# to student: this is an code snapshot showing how to use ray tune framework to
# you are responsible for completing the code, debugging and making sure it work
import sklearn.datasets
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import accuracy_score
from sklearn import metrics
import os
from ray.tune.schedulers import ASHAScheduler
from sklearn.model_selection import train_test_split
from ray import tune
from ray import train
def train_rf(config: dict, data=None):
# Initialize the RandomForestClassifier with the configuration
classifier = RandomForestClassifier(
n_estimators=config["n_estimators"],
max_depth=config["max_depth"],
min_samples_split=config["min_samples_split"],
min_samples_leaf=config["min_samples_leaf"],
class_weight="balanced",
random_state=42
)
# Fit the RandomForestClassifier on the training data
X_train = data[0]
y_train = data[1]
X_validation = data[2]
y_validation = data[3]
# To Be filled: Train your Random Forest Classifier here
# To Be filled: Evaluate the classifier on the validation set here and get e
# Send the accuracy to Ray Tune
train.report({'accuracy': accuracy})
# note that X_train, y_train, X_validation, y_validation are your training and v
tunable_function = tune.with_parameters(train_rf, data=[X_train, y_train, X_vali
def tune_random_forest(smoke_test=False):
# Define the search space for hyperparameters
search_space = {
"n_estimators": # setup your search space here
"max_depth": # setup your search space here
"min_samples_split": # setup your search space here
"min_samples_leaf": # setup your search space here
}
# Define the scheduler for early stopping
scheduler = ASHAScheduler(
max_t= # setup your ASHA parameter here,
grace_period=# setup your ASHA parameter here,
reduction_factor=# setup your ASHA parameter here
)
# Set up the tuner
tuner = tune.Tuner(
tunable_function,
In [ ]:
.ip… 2/2
tune_config=tune.TuneConfig(
metric="accuracy",
mode="max",
scheduler=scheduler,
num_samples=1 if smoke_test else 200,
),
param_space=search_space,
)
# Execute the tuning process
results = tuner.fit()
return results
# Run the tuning function
best_results = tune_random_forest(smoke_test=False)
best_trial = best_results.get_best_result(metric="accuracy", mode="max")
# Get the best trial's hyperparameters
best_params = best_trial.config
# Print the best hyperparameters
print("Best hyperparameters found were: ", best_params)
# Initialize a new RandomForestClassifier with the best hyperparameters
best_rf = RandomForestClassifier(**best_params, random_state=42)
# The remaining part of your code continues ....
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代做ceng0013 design of a pro...
2024-11-13
代做mech4880 refrigeration a...
2024-11-13
代做mcd1350: media studies a...
2024-11-13
代写fint b338f (autumn 2024)...
2024-11-13
代做engd3000 design of tunab...
2024-11-13
代做n1611 financial economet...
2024-11-13
代做econ 2331: economic and ...
2024-11-13
代做cs770/870 assignment 8代...
2024-11-13
代写amath 481/581 autumn qua...
2024-11-13
代做ccc8013 the process of s...
2024-11-13
代写csit040 – modern comput...
2024-11-13
代写econ 2070: introduc2on t...
2024-11-13
代写cct260, project 2 person...
2024-11-13
热点标签
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
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!