Project 3 Train a logistic classifier to predict income Please follow the procedures in the pseudo code below. Notice, you need to divide the data to two sets, a training and a test set. set.seed(100)...

1 answer below »
Copy and Paste Your Assignment Here


Project 3 Train a logistic classifier to predict income Please follow the procedures in the pseudo code below. Notice, you need to divide the data to two sets, a training and a test set. set.seed(100) 1. for (p in 0.05:0.95, by=0.05){ # select p% (you may start with 5%) 2. Randomly select p% of the dataset for training set and remaining will be used for the test set. For example, if we use 5% for training, remaining 95% for test. 3. Train the classifier and predict the income for each individual, class 1: > 50, and otherwise class 0. 4. Calculate the performance measure (assigned to you) for the predicted classes of the test set and save it. 5. } # Repeat from 1 for other training percentages. 6. Plot performance measure vs. p%. 7. Locate the p% that optimizes performance measure. Use the following fields in your feature set (including 13 features). Categorical: "workclass", "education", "marital.status", "occupation", "relationship", "race", "gender", "native.country" Continuous: "age", "education.num", "hours.per.week", "capital.gain", "capital.loss" Report deadline: Mon. Oct 18 at 4:00 pm. Presentations: Mon. Oct 18 ,age,workclass,education,education-num,marital-status,occupation,relationship,race,gender,capital-gain,capital-loss,hours-per-week,native-country,income 0,39, State-gov, Bachelors,13, Never-married, Adm-clerical, Not-in-family, White, Male,2174,0,40, United-States, <=50k 1,50,="" self-emp-not-inc,="" bachelors,13,="" married-civ-spouse,="" exec-managerial,="" husband,="" white,="" male,0,0,13,="" united-states,=""><=50k 2,38,="" private,="" hs-grad,9,="" divorced,="" handlers-cleaners,="" not-in-family,="" white,="" male,0,0,40,="" united-states,=""><=50k 3,53,="" private,="" 11th,7,="" married-civ-spouse,="" handlers-cleaners,="" husband,="" black,="" male,0,0,40,="" united-states,=""><=50k 4,28,="" private,="" bachelors,13,="" married-civ-spouse,="" prof-specialty,="" wife,="" black,="" female,0,0,40,="" cuba,=""><=50k 5,37,="" private,="" masters,14,="" married-civ-spouse,="" exec-managerial,="" wife,="" white,="" female,0,0,40,="" united-states,=""><=50k 6,49,="" private,="" 9th,5,="" married-spouse-absent,="" other-service,="" not-in-family,="" black,="" female,0,0,16,="" jamaica,=""><=50k 7,52,="" self-emp-not-inc,="" hs-grad,9,="" married-civ-spouse,="" exec-managerial,="" husband,="" white,="" male,0,0,45,="" united-states,="">50K 8,31, Private, Masters,14, Never-married, Prof-specialty, Not-in-family, White, Female,14084,0,50, United-States, >50K 9,42, Private, Bachelors,13, Married-civ-spouse, Exec-managerial, Husband, White, Male,5178,0,40, United-States, >50K 10,37, Private, Some-college,10, Married-civ-spouse, Exec-managerial, Husband, Black, Male,0,0,80, United-States, >50K 11,30, State-gov, Bachelors,13, Married-civ-spouse, Prof-specialty, Husband, Asian-Pac-Islander, Male,0,0,40, India, >50K 12,23, Private, Bachelors,13, Never-married, Adm-clerical, Own-child, White, Female,0,0,30, United-States, <=50k 13,32,="" private,="" assoc-acdm,12,="" never-married,="" sales,="" not-in-family,="" black,="" male,0,0,50,="" united-states,=""><=50k 14,40,="" private,="" assoc-voc,11,="" married-civ-spouse,="" craft-repair,="" husband,="" asian-pac-islander,="" male,0,0,40,="" ,="">50K 15,34, Private, 7th-8th,4, Married-civ-spouse, Transport-moving, Husband, Amer-Indian-Eskimo, Male,0,0,45, Mexico, <=50k 16,25,="" self-emp-not-inc,="" hs-grad,9,="" never-married,="" farming-fishing,="" own-child,="" white,="" male,0,0,35,="" united-states,=""><=50k 17,32,="" private,="" hs-grad,9,="" never-married,="" machine-op-inspct,="" unmarried,="" white,="" male,0,0,40,="" united-states,=""><=50k 18,38,="" private,="" 11th,7,="" married-civ-spouse,="" sales,="" husband,="" white,="" male,0,0,50,="" united-states,=""><=50k 19,43,="" self-emp-not-inc,="" masters,14,="" divorced,="" exec-managerial,="" unmarried,="" white,="" female,0,0,45,="" united-states,="">50K 20,40, Private, Doctorate,16, Married-civ-spouse, Prof-specialty, Husband, White, Male,0,0,60, United-States, >50K 21,54, Private, HS-grad,9, Separated, Other-service, Unmarried, Black, Female,0,0,20, United-States, <=50k 22,35,="" federal-gov,="" 9th,5,="" married-civ-spouse,="" farming-fishing,="" husband,="" black,="" male,0,0,40,="" united-states,=""><=50k 23,43,="" private,="" 11th,7,="" married-civ-spouse,="" transport-moving,="" husband,="" white,="" male,0,2042,40,="" united-states,=""><=50k 24,59,="" private,="" hs-grad,9,="" divorced,="" tech-support,="" unmarried,="" white,="" female,0,0,40,="" united-states,=""><=50k 25,56,="" local-gov,="" bachelors,13,="" married-civ-spouse,="" tech-support,="" husband,="" white,="" male,0,0,40,="" united-states,="">50K 26,19, Private, HS-grad,9, Never-married, Craft-repair, Own-child, White, Male,0,0,40, United-States, <=50k 27,54,="" ,="" some-college,10,="" married-civ-spouse,="" ,="" husband,="" asian-pac-islander,="" male,0,0,60,="" south,="">50K 28,39, Private, HS-grad,9, Divorced, Exec-managerial, Not-in-family, White, Male,0,0,80, United-States, <=50k 29,49,="" private,="" hs-grad,9,="" married-civ-spouse,="" craft-repair,="" husband,="" white,="" male,0,0,40,="" united-states,=""><=50k 30,23,="" local-gov,="" assoc-acdm,12,="" never-married,="" protective-serv,="" not-in-family,="" white,="" male,0,0,52,="" united-states,=""><=50k 31,20,="" private,="" some-college,10,="" never-married,="" sales,="" own-child,="" black,="" male,0,0,44,="" united-states,=""><=50k 32,45,="" private,="" bachelors,13,="" divorced,="" exec-managerial,="" own-child,="" white,="" male,0,1408,40,="" united-states,=""><=50k 33,30,="" federal-gov,="" some-college,10,="" married-civ-spouse,="" adm-clerical,="" own-child,="" white,="" male,0,0,40,="" united-states,=""><=50k 34,22,="" state-gov,="" some-college,10,="" married-civ-spouse,="" other-service,="" husband,="" black,="" male,0,0,15,="" united-states,=""><=50k 35,48,="" private,="" 11th,7,="" never-married,="" machine-op-inspct,="" unmarried,="" white,="" male,0,0,40,="" puerto-rico,=""><=50k 36,21,="" private,="" some-college,10,="" never-married,="" machine-op-inspct,="" own-child,="" white,="" male,0,0,40,="" united-states,=""><=50k 37,19,="" private,="" hs-grad,9,="" married-af-spouse,="" adm-clerical,="" wife,="" white,="" female,0,0,25,="" united-states,=""><=50k 38,31,="" private,="" some-college,10,="" married-civ-spouse,="" sales,="" husband,="" white,="" male,0,0,38,="" ,="">50K 39,48, Self-emp-not-inc, Assoc-acdm,12, Married-civ-spouse, Prof-specialty, Husband, White, Male,0,0,40, United-States, <=50k 40,31,="" private,="" 9th,5,="" married-civ-spouse,="" machine-op-inspct,="" husband,="" white,="" male,0,0,43,="" united-states,=""><=50k 41,53,="" self-emp-not-inc,="" bachelors,13,="" married-civ-spouse,="" prof-specialty,="" husband,="" white,="" male,0,0,40,="" united-states,=""><=50k 42,24,="" private,="" bachelors,13,="" married-civ-spouse,="" tech-support,="" husband,="" white,="" male,0,0,50,="" united-states,=""><=50k 43,49,="" private,="" hs-grad,9,="" separated,="" adm-clerical,="" unmarried,="" white,="" female,0,0,40,="" united-states,=""><=50k 44,25,="" private,="" hs-grad,9,="" never-married,="" handlers-cleaners,="" not-in-family,="" white,="" male,0,0,35,="" united-states,=""><=50k 45,57,="" federal-gov,="" bachelors,13,="" married-civ-spouse,="" prof-specialty,="" husband,="" black,="" male,0,0,40,="" united-states,="">50K 46,53, Private, HS-grad,9, Married-civ-spouse, Machine-op-inspct, Husband, White, Male,0,0,38, United-States, <=50k 47,44,="" private,="" masters,14,="" divorced,="" exec-managerial,="" unmarried,="" white,="" female,0,0,40,="" united-states,=""><=50k 48,41,="" state-gov,="" assoc-voc,11,="" married-civ-spouse,="" craft-repair,="" husband,="" white,="" male,0,0,40,="" united-states,=""><=50k 49,29,="" private,="" assoc-voc,11,="" never-married,="" prof-specialty,="" not-in-family,="" white,="" male,0,0,43,="" united-states,=""><=50k 50,25,="" private,="" some-college,10,="" married-civ-spouse,="" exec-managerial,="" wife,="" other,="" female,0,0,40,="" united-states,=""><=50k 51,18,="" private,="" hs-grad,9,="" never-married,="" other-service,="" own-child,="" white,="" female,0,0,30,="" ,=""><=50k 52,47,="" private,="" prof-school,15,="" married-civ-spouse,="" prof-specialty,="" wife,="" white,="" female,0,1902,60,="" honduras,="">50K 53,50, Federal-gov, Bachelors,13, Divorced, Exec-managerial, Not-in-family, White, Male,0,0,55, United-States, >50K 54,47, Self-emp-inc, HS-grad,9, Divorced, Exec-managerial, Not-in-family, White, Male,0,0,60, United-States, <=50k 55,43,="" private,="" some-college,10,="" married-civ-spouse,="" tech-support,="" husband,="" white,="" male,0,0,40,="" united-states,="">50K 56,46, Private, 5th-6th,3, Married-civ-spouse, Machine-op-inspct, Husband, White, Male,0,0,40, Mexico, <=50k 57,35,="" private,="" assoc-voc,11,="" married-civ-spouse,="" other-service,="" husband,="" white,="" male,0,0,40,="" puerto-rico,=""><=50k 58,41,="" private,="" hs-grad,9,="" married-civ-spouse,="" adm-clerical,="" husband,="" white,="" male,0,0,48,="" united-states,=""><=50k 59,30,="" private,="" hs-grad,9,="" married-civ-spouse,="" machine-op-inspct,="" husband,="" white,="" male,5013,0,40,="" united-states,=""><=50k 60,30,="" private,="" bachelors,13,="" married-civ-spouse,="" sales,="" husband,="" white,="" male,2407,0,40,="" united-states,=""><=50k 61,32,="" ,="" 7th-8th,4,="" married-spouse-absent,="" ,="" not-in-family,="" white,="" male,0,0,40,="" ,=""><=50k 62,48,="" private,="" hs-grad,9,="" married-civ-spouse,="" transport-moving,="" husband,="" white,="" male,0,0,40,="" united-states,=""><=50k 63,42,="" private,="" doctorate,16,="" married-civ-spouse,="" prof-specialty,="" husband,="" white,="" male,0,0,45,="" united-states,="">50K 64,29, Private, Some-college,10, Divorced, Tech-support, Not-in-family, White, Male,0,0,58, United-States, <=50k 65,36,="" private,="" hs-grad,9,="" married-civ-spouse,="" craft-repair,="" husband,="" white,="" male,0,0,40,="" united-states,=""><=50k 66,28,="" private,="" some-college,10,="" divorced,="" adm-clerical,="" not-in-family,="" white,="" female,0,0,40,="" united-states,=""><=50k 67,53,="" private,="" hs-grad,9,="" married-civ-spouse,="" adm-clerical,="" wife,="" white,="" female,0,0,40,="" united-states,="">50K 68,49, Self-emp-inc, Some-college,10, Married-civ-spouse, Exec-managerial, Husband, White, Male,0,0,50, United-States, >50K 69,25, ?, Some-college,10, Never-married, ?, Own-child, White, Male,0,0,40, United-States, <=50k 70,19,="" private,="" some-college,10,="" never-married,="" prof-specialty,="" own-child,="" white,="" male,0,0,32,="" united-states,=""><=50k 71,31,="" private,="" bachelors,13,="" separated,="" sales,="" own-child,="" black,="" female,0,0,40,="" united-states,=""><=50k>
Answered Same DayOct 18, 2021

Answer To: Project 3 Train a logistic classifier to predict income Please follow the procedures in the pseudo...

Mohd answered on Oct 19 2021
115 Votes
---
title: '-'
author: '-'
date: "10/18/2021"
output: word_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE,cache = TRUE,war
ning = FALSE,message = FALSE,dpi = 180,fig.width = 8,fig.height = 5)
```
```{r}
library(readr)
library(magrittr)
library(dplyr)
library(ggplot2)
library(rmarkdown)
library(MASS)
```
```{r}
library(readr)
adult <- read_csv("data/adult.csv")
```
Train a logistic classifier to predict income
Please follow the procedures in the pseudo code below.
Notice, you need to divide the data to two sets, a training and a test set.
set.seed(100)
1. for (p in 0.05:0.95, by=0.05){ # select p% (you may start with 5%)
2. Randomly select p% of the dataset for training set and remaining will be used for the test set.
For example, if we use 5% for training, remaining 95% for test.
3. Train the classifier and predict the income for each individual, class 1: > 50, and otherwise
class 0.
4. Calculate the performance measure (assigned to you) for the predicted classes of the test set
and save it.
5. } # Repeat from 1 for other training percentages.
6. Plot performance measure vs. p%.
7. Locate the p% that optimizes performance measure.
Use the following fields in your feature set (including 13 features).
Categorical:
"workclass", "education", "marital.status", "occupation", "relationship", "race", "gender",
"native.country"
Continuous:
"age", "education.num", "hours.per.week", "capital.gain", "capital.loss"
```{r}
summary(adult)
```
```{r}
adult_df<-adult%>%
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here