Escrito por estudiantes que aprobaron Inmediatamente disponible después del pago Leer en línea o como PDF ¿Documento equivocado? Cámbialo gratis 4,6 TrustPilot
logo-home
Examen

Homework 1 Intro to Analytical Modeling

Puntuación
-
Vendido
-
Páginas
6
Grado
A+
Subido en
15-10-2024
Escrito en
2024/2025

Homework 1 Intro to Analytical Modeling

Institución
Intro To Analytics Modeling
Grado
Intro to Analytics Modeling

Vista previa del contenido

10/15/24, 9:15 Homew ork 1 Intro to Analytical
AM Modeling




Hw1

Gary

5/23/2021


Question 2.1

Digital Marketing in Ecommerce is a space where classification plays a huge role. For example, using website
traffic analytics data to determine if a consumer will add an item to the shopping cart. Some potential
predictos include: - New vs returner customer - Types of Phone - Number of pages visited - Time spent
on the site - Landing page


Question 2.2.1

library(kernlab)

# Import data
df =read.delim("credit_card_data.txt",header=F)
# Transform data into a matrix
data = as.matrix(df)

# Define a function that takes lambda as an argument and return the accuracy
# of the model
svm_with_c = fu n ction (c){
model = ksvm(data[,1:10],as.factor(data[,11]),type="C-svc",kernel="vanilladot",C=c,scaled=TRUE)
pred = predict(model,data[,1:10])
sum(pred == data[,11]) / nrow(data)
}

print(svm_with_c(10))


## Setting default kernel parameters
## [1] 0.8639144

print(svm_with_c(50))


## Setting default kernel parameters
## [1] 0.8639144

print(svm_with_c(1000))


## Setting default kernel parameters
## [1] 0.8623853


1




about:blan 1/
k 6

, 10/15/24, 9:15 Homew ork 1 Intro to Analytical
AM Modeling




# Seems like 50 is a good value for C

model = ksvm(data[,1:10],as.factor(data[,11]),type="C-svc",kernel="vanilladot",C=50,scaled=TRUE)


## Setting default kernel parameters

# calculate a1...am
a = colSums(model@xmatrix[[1]]*model@coef[[1]])
print(a)


## V1 V2 V3 V4 V5
## -0.0010523630 -0.0012025131 -0.0015382662 0.0028761998 1.0052764944
## V6 V7 V8 V9 V10
## -0.0024958086 0.0001810245 -0.0006514829 -0.0013757143 0.1064002847

# calculate a0
a0 = model@b

print(a0)


## [1] -0.08147145

# Get the prediction
pred = predict(model,data[,1:10])

# Calculate the accuracy
print(sum(pred == data[,11]) / nrow(data))


## [1] 0.8639144


2.2.3


# Import kknn package
library('kknn')

# Function that returns the model accuracy for a given k
knn_accuracy_given_k = fu nction (k){
all_pred= c()
fo r (i in 1:nrow(df)){
knn_model = kknn(V11~V1+V2+V3+V4+V5+V6+V7+V8+V9+V10,df[-i,],df[i,],k=k,scale=TRUE)
predicted = fitted(knn_model)
if(predicted>=0.5){
rounded = 1
} else { rounded = 0}

all_pred = c(all_pred, rounded)
}



2




about:blan 2/
k 6

Escuela, estudio y materia

Institución
Intro to Analytics Modeling
Grado
Intro to Analytics Modeling

Información del documento

Subido en
15 de octubre de 2024
Número de páginas
6
Escrito en
2024/2025
Tipo
Examen
Contiene
Preguntas y respuestas

Temas

$13.99
Accede al documento completo:

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Conoce al vendedor
Seller avatar
EXAMSHAVEN1

Conoce al vendedor

Seller avatar
EXAMSHAVEN1 Stanford University
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
2
Miembro desde
1 año
Número de seguidores
0
Documentos
924
Última venta
11 meses hace
A+ GRADE FOR NURSING EXAMS

Success is the sum of small efforts - repeated day in and day out. I am here to help in the precise way possible. Day in day out I will be updating you \\\'all with the latest exams not only in nursing but also in other areas. Don\\\'t forget to check out my store and recommend it to a friend. I will be uploading LATEST TESTBANKS TOO.

0.0

0 reseñas

5
0
4
0
3
0
2
0
1
0

Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes