﻿ problem代写 Regression代写 SAX method代写 - 作业代写, 可视化编程

# problem代写 Regression代写 SAX method代写

2020-08-24 11:26 星期一 所属： 作业代写 浏览：16 ## Untitled

problem代写 Problem 1 – SAX method. Implement the SAX method in a programming language that you are comfortable with. Submit your code.

2018-11-16

### Problem 1 – SAX method problem代写

Implement the SAX method in a programming language that you are comfortable with. Submit your code. The input is a time series and the output is a string.

```data("economics")
glimpse(economics)

## Observations: 574
## Variables: 6
## \$ date     <date> 1967-07-01, 1967-08-01, 1967-09-01, 1967-10-01, 1967...
## \$ pce      <dbl> 507.4, 510.5, 516.3, 512.9, 518.1, 525.8, 531.5, 534....
## \$ pop      <int> 198712, 198911, 199113, 199311, 199498, 199657, 19980...
## \$ psavert  <dbl> 12.5, 12.5, 11.7, 12.5, 12.5, 12.1, 11.7, 12.2, 11.6,...
## \$ uempmed  <dbl> 4.5, 4.7, 4.6, 4.9, 4.7, 4.8, 5.1, 4.5, 4.1, 4.6, 4.4...
## \$ unemploy <int> 2944, 2945, 2958, 3143, 3066, 3018, 2878, 3001, 2877,...

changes <- diff(economics\$pce)
changes_SAX <- SAX(changes, alphabet = 5, PAA = 30)
changes_SAX

##   "b" "b" "b" "b" "b" "b" "b" "b" "c" "c" "c" "c" "c" "c" "c" "c" "c"
##  "c" "c" "d" "d" "c" "d" "e" "d" "b" "c" "d" "d" "d"```

The economics is a dateset with 478rows and 6 variables. We the first order difference of pec(personal consumption expenditures) as a time series to propose SAX method. The alphabet_size set to 5 and Piecewise Aggregate Approximation equals to 30

### Problem 2 – Regression problem代写

```train <-  read.csv('blogData_train.csv', header = F)

dim(train)

##  52397   281

dim(test)

##  214 281

# MSE function
MSE = function(y_hat, y) {
mse = mean( (y - y_hat)^2)
return(mse)
}

# Create model matrix for trainset and test set, basing on the dataset,we found the model matrix is really sparse.
train_x = model.Matrix(V281 ~ . - 1, data = train, sparse = F)
train_x_sparse = model.Matrix(V281 ~ . - 1, data = train, sparse = T)
train_y = train\$V281

test_x = model.Matrix(V281 ~ . - 1, data = test, sparse = F)
test_y = test\$V281

# LASSO to select variables

### using cv to select the best model
mdl_lasso = cv.glmnet(train_x_sparse, train_y, family = "gaussian", alpha = 1)
### calcluate our predict value on test set
pred_lasso = predict(mdl_lasso, newx = test_x)

# the MSE of LASSO regression
MSE(pred_lasso, test_y)

##  1768.295```

Using blogDate_test-2012.03.31.01_00.csv as train set, we propose a LASSO regression on it. Basing on CV method to select a best model. The MSE on test set is 1853.85.

### Problem 3 – Weka and Apriori problem代写

#### the top 10 rules found with confidence above 0.8

1. biscuits=t frozen foods=t fruit=t total=high 788 ==> bread and cake=t 723 <conf:(0.92)> lift:(1.27) lev:(0.03)  conv:(3.35)
2. baking needs=t biscuits=t fruit=t total=high 760 ==> bread and cake=t 696 <conf:(0.92)> lift:(1.27) lev:(0.03)  conv:(3.28)
3. baking needs=t frozen foods=t fruit=t total=high 770 ==> bread and cake=t 705 <conf:(0.92)> lift:(1.27) lev:(0.03)  conv:(3.27)
4. biscuits=t fruit=t vegetables=t total=high 815 ==> bread and cake=t 746 <conf:(0.92)> lift:(1.27) lev:(0.03)  conv:(3.26)
5. party snack foods=t fruit=t total=high 854 ==> bread and cake=t 779 <conf:(0.91)> lift:(1.27) lev:(0.04)  conv:(3.15)
6. biscuits=t frozen foods=t vegetables=t total=high 797 ==> bread and cake=t 725 <conf:(0.91)> lift:(1.26) lev:(0.03)  conv:(3.06)
7. baking needs=t biscuits=t vegetables=t total=high 772 ==> bread and cake=t 701 <conf:(0.91)> lift:(1.26) lev:(0.03)  conv:(3.01)
8. biscuits=t fruit=t total=high 954 ==> bread and cake=t 866 <conf:(0.91)> lift:(1.26) lev:(0.04)  conv:(3)
9. frozen foods=t fruit=t vegetables=t total=high 834 ==> bread and cake=t 757 <conf:(0.91)> lift:(1.26) lev:(0.03)  conv:(3)
10. frozen foods=t fruit=t total=high 969 ==> bread and cake=t 877 <conf:(0.91)> lift:(1.26) lev:(0.04)  conv:(2.92)

#### maximum minimum-support

```c <- seq(0.1, 0.9, by = 0.1)
max_minsupport <- c(.45, .45, .45, .45, .45, .45, .4, .3, .15)

plot(c,max_minsupport,type = 'l')``` 