首页 > > 详细

辅导Python编程、Python编程辅导、辅导留学生K Nearest neighbor (KNN) classifier 设计

In this assignment, you will develop several classification models to classify
noisy input images into the classes square or circle, as shown in Fig. 1

Figure 1: Samples of noisy images labelled as square (left) and circle (right).
Your classification models will use the training and testing sets (that are
available with this assignment) containing many image samples labelled as
square or circle. Your task is to write a Python code that can be run on a Jupyter
Notebook session, which will train and validate the following classification
models:
1) K Nearest neighbor (KNN) classifier
For the KNN classifier, you can only use standard Python libraries (e.g.,
numpy) in order to implement allaspects of the training and testing
algorithms. You will need to implement two functions: a) one to build a K-d tree
from the training set (this function takes the training samplesand labels as its
parameters), and b) another to test the KNN classifier and compute the
classification accuracy, where the parameters areK and the test images and
labels. Using matplotlib, plot a graph of the evolution of classification accuracy
for the training and testing sets as a function of K, where K=1 to 10. Clearly
identify the value of K, where generalization is best.
2) Decision tree classifier
For the decision tree classifier, you can only use standard Python
libraries (e.g., numpy) in order to implement all aspects of the training
and testing algorithms. Essentially you will need to implement two
functions: a) one to train the decision tree using the training samplesand
labels plus a pre-pruning parameter indicating the minimum
information content before stop splitting, and b) another to test the
decision tree and compute the classification accuracy (similarly to the KNN
classifier, the test function takes as one of its parameters the test images
and labels and returns the classification accuracy). Using matplotlib, plot a
graph of the evolution of classification accuracy for the training and testing
sets as a function of the information content, where information content =
0 to 0.5 bits. Clearly identify the value of information content, where
generalization is best.
3) Convolutional neural network (CNN) classifier
For the convolutional neural network, you are allowed to use Keras using
TensorFlow backend, similar to the example shown in the code provided. The
CNN structure is the lenet structure used in lecture. Using matplotlib, please
plot a graph of the evolution of accuracy for the training and testing sets as a
function of the number of epochs, where the max number of epochs is 200.
Clearly identify the value of information content, where generalization is best.
 

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

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