Starting from:
$35

$29

Programming Assignment #1

Question 3: In this question we will provide three files: training_samples.txt, training_labels.txt and testing_samples.txt. Write a program to predict the category of a testing sample with K-NN algorithm given training samples and the labels of the training samples. Select a good hyperparameter K. Note that you are expected to implement the K-NN algorithm by yourself. In other words, you are supposed to not directly use the well-implemented K-NN class or functions in packages or libraries, e.g. scikit-learn. But it is ok to use numpy and scipy.

File format:

    (1) training_samples.txt: N lines of float values separated by space. Each line is a training sample.

    (2) training_labels.txt: N lines where each line contains an integer.

    (3) testing_samples.txt: N lines containing the coordinates of the testing samples. The elements in each line are separated by space.


Question 4: In this question we will provide a file containing N lines. Each line includes two values x and y, representing a training point. You are supposed to write and run a program to fit a linear regression model y = wx+b with the given points and then plot the fitted line and training points in a figure. Note that you are expected to implement the linear regression algorithm by yourself. In other words, you are supposed to not directly use the implementation in packages or libraries, e.g. scikit-learn. But it is ok to use numpy and scipy for data processing and calculation, like matrix multiplication.

File format:

(1) 2D_points.txt: N lines of float value pairs separated by space. Each line is a training sample (x,y).

More products