首页 > > 详细

ECMM422编程语言辅导、Python编程设计调试、辅导Python程序辅导Python程序|解析Haskell程序

ECMM422 Machine Learning
Course Assessment 1
This course assessment (CA1) represents 40% of the overall module assessment.
This is an individual exercise and your attention is drawn to the College and University
guidelines on collaboration and plagiarism, which are available from the College website.
Note:
.
do not change the name of this notebook, i.e. the notebook file has to be named: ca1.ipynb
.
do not remove/delete any cell
.
do not add any cell (you can work on a draft notebook and only copy the function
implementations here)
.
do not add you name or student code in the notebook or in the file name
Evaluation criteria:
Each question asks for one or more functions to be implemented.
Each question is awarded a number of marks.
A (hidden) unit test is going to evaluate if all desired properties of the required function(s) are
met.
If the test passes all the associated marks are awarded, if it fails 0 marks are awarded. The large
number of questions allows a fine grading.
Notes:
In the rest of the notebook, the term data matrix refers to a two dimensional numpy array
where instances are encoded as rows, e.g. a data matrix with 100 rows and 4 columns is to be
interpreted as a collection of 100 instances each with four features.
When a required function can be implemented directly by a library function it is intended that
the candidate should write her own implementation of the function, e.g. a function to compute
the accuracy or the cross validation.
Some questions are just a check-point, i.e. it is for you to see that you are correctly
implementing all functions. Since those check-points use functions that you have already
implemented and that have already been marked, those questions are not going to be marked
(i.e. they appear as having marks 0).
In [ ]: %matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
2021/3/2 1
localhost:8888/nbconvert/html/Downloads/1.ipynb?download=false 2/16
Question 1 [marks 6]
a) Make a function data_matrix = make_data_classification(mean, std,
n_centres, inner_std, n_samples, random_seed=42) to create a data matrix
according to the following rules:
.
mean is a n-dimensional vector (say [1,1], but the function should allow vectors of any
dimension)
.
n_centres is the number of centres (say 3)
.
std is the standard deviation (say 1)
.
the centres are sampled from a Normal distribution with mean mean and standard
deviation std
.
from each centre sample n_samples from a Normal distribution with the centre as the
mean and standard deviation inner_std so if mean=[1,1] n_centres=3 and
n_samples=10 then the data matrix will be a 30 rows x 2 columns numpy array.
b) Make a function data_matrix, targets = make_data_regression(mean, std,
n_centres, inner_std, n_samples_list, random_seed=42) to create a data matrix
and a target vector according to the following rules:
.
the data matrix is constructed in the same way as in make_data_classification
.
the targets are the Euclidean distance between the sample and the centre of the generating
Normal distribution
See Question 3 for a graphical example of the expected output.
Question 2 [marks 2]
import scipy as sp
# unit test utilities: you can ignore these function
def is_approximately_equal(test,target,eps=1e-2):
return np.mean(np.fabs(np.array(test) - np.array(target)))

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!