[SOLVED] COEN240 Homework 1

24.99 $

Programming resource
Digital learning resource
Category:
βœ“ Practical programming resource
βœ“ Suitable for guided study and reference
βœ“ Tutor guidance available when needed

Description

Rate this product

Problem 1 You have a set of 𝑁 training inputs 𝐱𝑛 ∈ ℝ𝑀, 𝑛 = 1, 2, … , 𝑁, 𝑁 ≫ 𝑀. The target outputs of the training inputs are 𝑑𝑛 ∈ ℝ, 𝑛 = 1, 2, … , 𝑁. Build a linear regression model to predict the target value by 𝐰𝑇𝐱𝑛. Derive the closed-form solution for the weight vector 𝐰 ∈ ℝ𝑀 that minimizes the error functionΒ  𝐸(𝐰) =

{𝐰𝑇𝐱𝑛 βˆ’ 𝑑𝑛 }2.

Problem 2 The Pima Indians diabetes data set (pima-indians-diabetes.xlsx) is a data set used to diagnostically predict whether or not a patient has diabetes, based on certain diagnostic measurements included in the dataset. All patients here are females at least 21 years old of Pima Indian heritage. The dataset consists of M = 8 attributes and one target variable, Outcome (1 represents diabetes, 0 represents no diabetes). The 8 attributes include Pregnancies, Glucose, BloodPressure, BMI, insulin level, age, and so on. There are N=768 data samples.

Randomly select n samples from the β€œdiabetes” class and n samples from the β€œno diabetes” class, and use them as the training samples. The remaining data samples are the test samples. Build a linear regression model as described in Problem 1 with the training set, and test your model on the test samples to predict whether or not a test patient has diabetes or not. Assume the predicted outcome of a test sample is 𝑑̂, if 𝑑̂ β‰₯ 0.5 (closer to 1), classify it as β€œdiabetes”; if 𝑑̂ < 0.5 (closer to 0), classify it as β€œno diabetes”. Run 1000 independent experiments, and calculate the prediction accuracy rate as π‘‘β„Žπ‘’ π‘›π‘’π‘šπ‘π‘’π‘Ÿ π‘œπ‘“ π‘π‘œπ‘Ÿπ‘Ÿπ‘’π‘π‘‘ π‘π‘Ÿπ‘’π‘‘π‘–π‘π‘‘π‘–π‘œπ‘›π‘  %. Let n=40, 80, 120, 160, 200, plot the

π‘‘β„Žπ‘’ π‘‘π‘œπ‘‘π‘Žπ‘™ π‘›π‘’π‘šπ‘π‘’π‘Ÿ π‘œπ‘“ 𝑑𝑒𝑠𝑑 π‘π‘Žπ‘ π‘’π‘ 

accuracy rate versus n. Comment on the result. Attach the code at the end of the homework.

 

Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.