Description
1. Write an R function called simple learner that takes as input a data frame df (you may
assume that all columns of df are numeric, and the final column provides a class label of 1
or −1) and returns a list having two attributes w and b, where w = c+ − c− and b = w · c,
where c+ and c− are the respective centers of mass of the positive and negative datapoints, and
c = (c+ + c−)/2 is a point on the linear decision surface.
2. Write an R function called perceptron learner that takes as input a data frame df (you may
assume that all columns of df are numeric, and the final column provides a class label of 1 or
−1) and returns a list having two attributes w and b, where w and b are obtained by performing
the perceptron learning algorithm using the vectors from df.
3. Write an R function called classify that takes as input i) data frame df, and ii) linear decision
surface parameters w and b, and returns a vector v that provides the classifications of each of
the vectors of df. Thus each component of v is either 1 or -1, and the length of v equals the
number of vectors of df. Moreover, we assume that the number of columns of df is equal to
the dimension of w.
4. Use the data in file exercise-4.csv to build a data frame df, and provide the w and b values
that are returned by simple learner(df).
5. Repeat Exercise 4, but now provide the w and b values that are returned by perceptron learner(df).

