1. Consider a dataset with attributes x, y, and z, where the decision attribute is z. Suppose that we have determined that there are two support vectors: the 2D point (-7, 10) which corresponds to an instance in the dataset that has x = -7, y = 10, and z = -1, and the 2D point (-6, 9) which corresponds to an instance in the dataset that has x = -6, y = 9, and z = 1.
The equations for the support vector machine are shown below where s1 = (-7 10 1) is the augmented support vector for (-7, 10), s2 = (-6 9 1) is the augmented support vector for (-6, 9), and α1 and α2 are the respective parameters for the support vectors that will be used to define the 2D hyperplane.
α1φ(s1) • φ(s1) + α2φ(s2) • φ(s1) = -1
α1φ(s1) • φ(s2) + α2φ(s2) • φ(s2) = 1
For φ, use φ(x y) = ( x+y 10-y )
a. Solve for each αi showing ALL of your work! (2 pts.)
b. Using your results from part a., define the discriminating 2D hyperplane for this dataset; that is, give an equation for the 2D hyperplane. Show your work! (2 pts.)
c. Using the support vector machine you have defined, predict the value for the decision attribute (z) for an instance that has x = 2 and y = 5. Show your work! (2 pts.)
2. Write a Python function which, given a dataframe, constructs (and returns) a Naïve Bayesian network.
You can assume that all of the attributes have nominal values and that the decision attribute is the last attribute in the dataframe.
Apply Laplace smoothing to the conditional probabilities of the attributes (as explained in class) using a value of λ = 1.
Output the conditional probability table for each node in the Bayesian network so that your work can be checked!
Test your function by running it on contact-lenses.csv AND hypothyroid.csv (both of which are posted on Canvas with this assignment). Note that you can check your work by running Classify -> weka -> Classifiers -> bayes -> NaiveBayesSimple in Weka.
ALSO demonstrate that you have successfully created these particular Bayesian networks by executing code that predict the following:
contact-lenses = soft, age = presbyopic, other attributes = None
class = negative, sex = U, other attributes = None
Note: You will NOT get full credit for your solution if you hard-code your code to work just for the specified test datasets!