Topic Marketing Campaign of a Bank

A certain Bank is conducting a marketing campaign to offer a specific Term Deposit to a large demography of targeted clients. The data provided in this exercise is related with direct marketing campaigns (phone calls) of the Bank. The classification goal is to predict if the targeted person will subscribe to the Term Deposit offered by the Bank. The Bank also wants to identify the top three variables that may affect the subscription chances of the targeted person, and they also want to know how to increase the chances for the person to subscribe to the Term Deposit.


Analysis of Marketing Data

Import the CSV data file assign2_MarketingData.csv for analysis, and quickly check the structure of the data.

marketData <- read.csv("assign2_MarketingData.csv", header = TRUE)
str(marketData)
## 'data.frame':    30000 obs. of  21 variables:
##  $ Age          : int  33 28 48 24 45 33 31 31 39 37 ...
##  $ Job          : Factor w/ 12 levels "admin","blue-collar",..: 7 8 5 9 1 1 8 8 1 1 ...
##  $ Marital      : Factor w/ 4 levels "divorced","married",..: 3 2 2 3 3 1 1 2 2 2 ...
##  $ Education    : Factor w/ 8 levels "basic4y","basic6y",..: 7 4 7 4 7 7 4 8 6 4 ...
##  $ Default      : Factor w/ 3 levels "no","unknown",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ Housing      : Factor w/ 3 levels "no","unknown",..: 2 3 3 1 2 1 3 3 1 3 ...
##  $ Loan         : Factor w/ 3 levels "no","unknown",..: 2 1 3 1 2 1 3 1 1 1 ...
##  $ Contact      : Factor w/ 2 levels "cellular","telephone": 2 1 2 1 1 2 1 1 1 2 ...
##  $ Month        : Factor w/ 10 levels "apr","aug","dec",..: 5 7 4 5 8 7 2 5 2 4 ...
##  $ Day          : Factor w/ 5 levels "fri","mon","thu",..: 1 1 3 4 4 1 4 4 1 3 ...
##  $ Duration     : int  38 237 154 253 133 279 242 98 306 29 ...
##  $ Campaign     : int  5 4 1 1 3 1 3 3 3 14 ...
##  $ PrevDays     : int  999 999 999 999 999 999 999 999 999 999 ...
##  $ Previous     : int  0 0 0 0 1 0 0 0 0 0 ...
##  $ PrevOutcome  : Factor w/ 3 levels "failure","nonexistent",..: 2 2 2 2 1 2 2 2 2 2 ...
##  $ EmpVarRate   : num  1.4 -1.8 1.4 -2.9 -3.4 1.1 1.4 -2.9 1.4 1.4 ...
##  $ ConPriceIndex: num  94.5 92.9 93.9 93 92.6 ...
##  $ ConConfIndex : num  -41.8 -46.2 -42.7 -40.8 -30.1 -36.4 -36.1 -40.8 -36.1 -42.7 ...
##  $ EuriborRate  : num  4.959 1.313 4.962 1.262 0.715 ...
##  $ NumEmp       : num  5228 5099 5228 5076 5018 ...
##  $ Subscribed   : Factor w/ 2 levels "no","yes": 1 1 1 1 1 1 1 1 1 1 ...

The following table summarizes the variables in the dataset. Check the data description carefully.

Variable Description Type
Age Age of the person Personal Profile
Job Job Profile of the person Personal Profile
Marital Marital Status of the person Personal Profile
Education Highest Educational Qualification of the person Personal Profile
Default Does the person have Credit in Default? Financial Profile
Housing Does the person have a Housing Loan? Financial Profile
Loan Does the person have a Personal Loan? Financial Profile
Contact Type of Contact Number for Communication Personal Profile
Month Month of Year for the last contact with the person Campaign Data
Day Day of Week for the last contact with the person Campaign Data
Duration The duration of contact during the Last Contact Campaign Data
Campaign Number of contacts with the person during this Campaign Campaign Data
PrevDays Number of days from the last contact during the Previous Campaign Campaign Data
Previous Number of contacts with the person before this Campaign Campaign Data
PrevOutcome Outcome of previous Marketing Campaign for the person Campaign Data
EmpVarRate Employment Variation Rate in the person’s locality Demographic Info
ConPriceIndex Consumer Price Index (monthly) in the person’s locality Demographic Info
ConConfIndex Consumer Confidence Index (monthly) in the person’s locality Demographic Info
EuriborRate Euro Interbank Offered Rate (Euribor) for 3 months Demographic Info
NumEmp Number of Employees (quarterly) in the person’s locality Demographic Info
Subscribed Whether the person has Subscribed to a Term Deposit Response/Target

Value unknown in any categorical variable means the data is not available. Duration = 0 means no communication during the last contact, or may be that there was no previous contact at all. PrevDays = 999 means there was no previous contact with the person. The goal is to predict the response variable Subscribed for each person – that is, whether a person would subscribe to the Term Deposit being sold by the Bank.

Plotting Subscribed against Personal Profile variables

plot(marketData$Subscribed, marketData$Age, xlab="Subscribed", ylab="Age")

plot(marketData$Subscribed, marketData$Job, xlab="Subscribed", ylab="Job")

plot(marketData$Subscribed, marketData$Marital, xlab="Subscribed", ylab="Marital")

plot(marketData$Subscribed, marketData$Education, xlab="Subscribed", ylab="Education")

The Age of a person do not seem to affect their decision on whether to subscribe to the Term Deposit being sold by the Bank. The median is almost the same.

The other y axis seem to be too long to be shown. let us try flipping the axis around to get meaningful plots.

plot(marketData$Job, marketData$Subscribed, xlab="Job", ylab="Subscribed")

plot(marketData$Marital, marketData$Subscribed, xlab="Marital", ylab="Subscribed")

plot(marketData$Education, marketData$Subscribed, xlab="Education", ylab="Subscribed")

The Job of a person do seem to affect their decision on whether to subscribe to the Term Deposit being sold by the Bank. As seen from the graph above, there is a few jobs that appear to affect the subscribed rate.

Seems that one of the Marital status is absent in the graph. This is probably due to the small number of unknowns. The Marital status of a person do not seem to affect their decision on whether to subscribe to the Term Deposit being sold by the Bank.

The Education of a person do not seem to affect their decision on whether to subscribe to the Term Deposit being sold by the Bank. As seen from the graph above, it is quite evenly distributed(flat across the subscription)

Plotting Subscribed against Financial Profile variables

plot(marketData$Subscribed, marketData$Default, xlab="Subscribed", ylab="Default")

plot(marketData$Subscribed, marketData$Housing, xlab="Subscribed", ylab="Housing")

plot(marketData$Subscribed, marketData$Loan, xlab="Subscribed", ylab="Loan")

Seems that one of the Default is absent in the graph. This is probably due to the small number of unknowns. The Default status of a person seem to affect their decision on whether to subscribe to the Term Deposit being sold by the Bank. If a person is a defaulter, he is less likely to subscribe. Likewise, if he is not a defaulter, he is likely to subscribe.

The Housing of a person do not seem to affect their decision on whether to subscribe to the Term Deposit being sold by the Bank. As seen from the graph above, it is quite evenly distributed(flat across the subscription)

The Loan of a person do not seem to affect their decision on whether to subscribe to the Term Deposit being sold by the Bank. As seen from the graph above, it is quite evenly distributed(flat across the subscription)

Plotting Subscribed against Campaign Data variables

plot(marketData$Subscribed, marketData$Month, xlab="Subscribed", ylab="Month")

plot(marketData$Subscribed, marketData$Day, xlab="Subscribed", ylab="Day")

plot(marketData$Subscribed, marketData$Duration, xlab="Subscribed", ylab="Duration")

plot(marketData$Subscribed, marketData$Campaign, xlab="Subscribed", ylab="Campaign")

plot(marketData$Subscribed, marketData$PrevDays, xlab="Subscribed", ylab="PrevDays")

plot(marketData$Subscribed, marketData$Previous, xlab="Subscribed", ylab="Previous")

plot(marketData$Subscribed, marketData$PrevOutcome, xlab="Subscribed", ylab="PrevOutcome")

The Month of a campaign is indeterminate as the axis is too large. Attempt to flip the axis.

The Day of a campaign do not seem to affect their decision on whether to subscribe to the Term Deposit being sold by the Bank. As seen from the graph above, it is quite evenly distributed(flat across the subscription)

The Duration of a campaign do seem to affect their decision on whether to subscribe to the Term Deposit being sold by the Bank. As seen from the graph above, if the duration is longer, there is a higer subscribed rate.

The number of contacts with the person during this Campaign do not seem to affect their decision on whether to subscribe to the Term Deposit being sold by the Bank. As seen from the graph above, it is quite flat across the subscription

The number of days from the last contact during the Previous Campaign do not seem to affect their decision on whether to subscribe to the Term Deposit being sold by the Bank. As seen from the graph above, it is quite flat across the subscription. However, this could be the lack of data as well as the excessive number of subscribers who have never been contacted before. This varible is not reliable.

The number of contacts with the person before this Campaign do not seem to affect their decision on whether to subscribe to the Term Deposit being sold by the Bank. As seen from the graph above, it is quite flat across the subscription. However, this could be the lack of data as well as the lack of past campaigns. This varible is not very reliable.

The PrevOutcome of a campaign do affect their decision on whether to subscribe to the Term Deposit being sold by the Bank. As seen from the graph above, it is not evenly distributed(flat across the subscription). A person who subscribed in the previous campaign is likely to subscribe again in the current campaign. Therefore, PrevOutcome is an important variable

plot(marketData$Month, marketData$Subscribed, xlab="Month", ylab="Subscribed")

The Month of a campaign do affect their decision on whether to subscribe to the Term Deposit being sold by the Bank. As seen from the graph above, it is not evenly distributed(flat across the subscription). This is an important variable.

Plotting Subscribed against Demographic Info variables

plot(marketData$Subscribed, marketData$EmpVarRate, xlab="Subscribed", ylab="EmpVarRate")

plot(marketData$Subscribed, marketData$ConPriceIndex, xlab="Subscribed", ylab="ConPriceIndex")

plot(marketData$Subscribed, marketData$ConConfIndex, xlab="Subscribed", ylab="ConConfIndex")

plot(marketData$Subscribed, marketData$EuriborRate, xlab="Subscribed", ylab="EuriborRate")

plot(marketData$Subscribed, marketData$NumEmp, xlab="Subscribed", ylab="NumEmp")

The Employment Variation Rate in the person’s locality do seem to affect their decision on whether to subscribe to the Term Deposit being sold by the Bank. As seen from the graph above, a person’s locality rate that is negative would most likely subscribe.

The Consumer Price Index (monthly) in the person’s locality do seem to affect their decision on whether to subscribe to the Term Deposit being sold by the Bank. As seen from the graph above, a person with lower CPI is more likely to subscribe.

The Consumer Confidence Index (monthly) in the person’s locality do not seem to affect their decision on whether to subscribe to the Term Deposit being sold by the Bank. As seen from the graph above, it is quite flat. However, it is strange as the CPI should affect the subscribed rate as we are talking about financial stability. A person with lower financial stability should be less likely to subscribe. This could be due to the fact that the CPI provided are all negaive in values.

The Euro Interbank Offered Rate (Euribor) for 3 months do affect their decision on whether to subscribe to the Term Deposit being sold by the Bank. As seen from the graph above, a lower rate in the Euro bank will encourage customers to subscribe to this bank instead to secure more profits for themselves. This could also be due to the Euro bank being a close substitute to this bank.

The Number of Employees (quarterly) in the person’s locality do seem to affect their decision on whether to subscribe to the Term Deposit being sold by the Bank. As seen from the graph above, a locality with more employed persons would subscribe more. This could be due to the fact that only people with salaries have the option of investing it in the form of bank subscribion.


Problem 1

Build an optimal tree-based classification model for Subscribed vs the Personal Profile and Financial Profile of a person. Check the relevant accuracy parameters of your model, and use it to predict Subscribed in the assign2_MarketingPred.csv.

Building tree-based classificaiton model

Install the tree package if you have not, import tree library. Construct the full model tree: decision tree of Subscribed vs all the variables of the Personal Profile and Financial Profile of a person. Display and print the entire tree structure.

# install.packages("tree")
library("tree")
marketDataQ1 <- marketData[-c(9:20)]
treefitQ1 <- tree(Subscribed ~ ., data = marketDataQ1)
plot(treefitQ1)
text(treefitQ1, pretty = FALSE, all = TRUE)

treefitQ1
## node), split, n, deviance, yval, (yprob)
##       * denotes terminal node
## 
## 1) root 30000 21190.0 no ( 0.88677 0.11323 )  
##   2) Contact: cellular 19094 16030.0 no ( 0.85163 0.14837 )  
##     4) Age < 59.5 18380 14720.0 no ( 0.86246 0.13754 )  
##       8) Default: unknown,yes 3098  1300.0 no ( 0.94609 0.05391 ) *
##       9) Default: no 15282 13160.0 no ( 0.84550 0.15450 ) *
##     5) Age > 59.5 714   974.6 no ( 0.57283 0.42717 ) *
##   3) Contact: telephone 10906  4439.0 no ( 0.94829 0.05171 ) *
summary(treefitQ1)
## 
## Classification tree:
## tree(formula = Subscribed ~ ., data = marketDataQ1)
## Variables actually used in tree construction:
## [1] "Contact" "Age"     "Default"
## Number of terminal nodes:  4 
## Residual mean deviance:  0.6624 = 19870 / 30000 
## Misclassification error rate: 0.1132 = 3397 / 30000

Obtain Accuracy parameter

The following table summarizes the full model tree of Subscribed vs all the variables of the Personal Profile and Financial Profile of a person.

Type Model complexity Relevant variables Misclassification error rate
Full Model 8 leaf nodes NumEmp, Duration, PrevDays, Month 0.09753 = 2926 / 30000

Verify the Misclassification error rate by predicting with MarketingPred data.

predDataQ1 <- predict(treefitQ1, marketDataQ1, type = "class")
summary(predDataQ1)
##    no   yes 
## 30000     0
table(marketData$Subscribed, predDataQ1)
##      predDataQ1
##          no   yes
##   no  26603     0
##   yes  3397     0

(951+1975) / (27627+2373) = 0.0975333. The Misclassification error rate is very similar.

Optimise tree-based classificaiton model by having it be Cross Validated

Starting with the largest tree

ltreeFitQ1 <- tree(Subscribed ~ ., data = marketDataQ1, 
                 split = "deviance",
                 method = "recursive.partition",
                 control = tree.control(nobs = nrow(marketDataQ1),
                                        mincut = 6,
                                        mindev = 0))
plot(ltreeFitQ1)
## Warning in node * 2L: NAs produced by integer overflow

This is too large to be useful. Implement 10-fold Cross-Validation

cvTreeQ1 <- cv.tree(ltreeFitQ1, FUN = prune.tree, K = 10) 
cbind(cvTreeQ1$size, cvTreeQ1$dev)
##         [,1]     [,2]
##    [1,] 2206 19945.92
##    [2,] 2199 19945.92
##    [3,] 2198 19945.92
##    [4,] 2197 19945.92
##    [5,] 2195 19945.92
##    [6,] 2194 19945.92
##    [7,] 2192 19945.92
##    [8,] 2191 19945.92
##    [9,] 2190 19945.92
##   [10,] 2189 19945.92
##   [11,] 2187 19945.92
##   [12,] 2185 19945.92
##   [13,] 2184 19945.92
##   [14,] 2181 19945.92
##   [15,] 2180 19945.92
##   [16,] 2169 19945.92
##   [17,] 2168 19945.92
##   [18,] 2167 19945.92
##   [19,] 2166 19945.92
##   [20,] 2162 19945.92
##   [21,] 2161 19945.92
##   [22,] 2159 19945.92
##   [23,] 2158 19945.92
##   [24,] 2157 19945.92
##   [25,] 2153 19945.92
##   [26,] 2152 19945.92
##   [27,] 2151 19945.92
##   [28,] 2150 19945.92
##   [29,] 2145 19945.92
##   [30,] 2139 19945.92
##   [31,] 2138 19945.92
##   [32,] 2137 19945.92
##   [33,] 2135 19945.92
##   [34,] 2132 19945.92
##   [35,] 2131 19945.92
##   [36,] 2130 19945.92
##   [37,] 2129 19945.92
##   [38,] 2128 19945.92
##   [39,] 2121 19945.92
##   [40,] 2119 19945.92
##   [41,] 2118 19945.92
##   [42,] 2117 19945.92
##   [43,] 2114 19945.92
##   [44,] 2113 19945.92
##   [45,] 2112 19945.92
##   [46,] 2111 19945.92
##   [47,] 2110 19945.92
##   [48,] 2109 19945.92
##   [49,] 2108 19945.92
##   [50,] 2106 19945.92
##   [51,] 2104 19945.92
##   [52,] 2103 19945.92
##   [53,] 2101 19945.92
##   [54,] 2100 19945.92
##   [55,] 2099 19945.92
##   [56,] 2096 19945.92
##   [57,] 2095 19945.92
##   [58,] 2094 19945.92
##   [59,] 2093 19945.92
##   [60,] 2092 19945.92
##   [61,] 2091 19945.92
##   [62,] 2090 19945.92
##   [63,] 2089 19945.92
##   [64,] 2082 19945.92
##   [65,] 2081 19945.92
##   [66,] 2079 19945.92
##   [67,] 2078 19945.92
##   [68,] 2076 19945.92
##   [69,] 2075 19945.92
##   [70,] 2074 19945.92
##   [71,] 2072 19945.92
##   [72,] 2071 19945.92
##   [73,] 2068 19945.92
##   [74,] 2067 19945.92
##   [75,] 2066 19945.92
##   [76,] 2065 19945.92
##   [77,] 2063 19945.92
##   [78,] 2062 19945.92
##   [79,] 2060 19945.92
##   [80,] 2059 19945.92
##   [81,] 2058 19945.92
##   [82,] 2057 19945.92
##   [83,] 2056 19945.92
##   [84,] 2055 19945.92
##   [85,] 2054 19945.92
##   [86,] 2051 19945.92
##   [87,] 2050 19945.92
##   [88,] 2048 19945.92
##   [89,] 2046 19945.92
##   [90,] 2045 19945.92
##   [91,] 2044 19945.92
##   [92,] 2043 19945.92
##   [93,] 2042 19945.92
##   [94,] 2040 19945.92
##   [95,] 2039 19945.92
##   [96,] 2038 19945.92
##   [97,] 2037 19945.92
##   [98,] 2036 19945.92
##   [99,] 2034 19945.92
##  [100,] 2033 19945.92
##  [101,] 2032 19945.92
##  [102,] 2030 19945.92
##  [103,] 2029 19945.92
##  [104,] 2027 19945.92
##  [105,] 2026 19945.92
##  [106,] 2025 19945.92
##  [107,] 2024 19945.92
##  [108,] 2021 19945.92
##  [109,] 2020 19945.92
##  [110,] 2019 19945.92
##  [111,] 2018 19945.92
##  [112,] 2017 19945.92
##  [113,] 2015 19945.92
##  [114,] 2012 19945.92
##  [115,] 2011 19945.92
##  [116,] 2010 19945.92
##  [117,] 2009 19945.92
##  [118,] 2008 19945.92
##  [119,] 2006 19945.92
##  [120,] 2004 19945.92
##  [121,] 2003 19945.92
##  [122,] 2001 19945.92
##  [123,] 1998 19945.92
##  [124,] 1996 19945.92
##  [125,] 1995 19945.92
##  [126,] 1993 19945.92
##  [127,] 1992 19945.92
##  [128,] 1991 19945.92
##  [129,] 1990 19945.92
##  [130,] 1988 19945.92
##  [131,] 1987 19945.92
##  [132,] 1984 19945.92
##  [133,] 1982 19945.92
##  [134,] 1980 19945.92
##  [135,] 1979 19945.92
##  [136,] 1977 19945.92
##  [137,] 1975 19945.92
##  [138,] 1973 19945.92
##  [139,] 1972 19945.92
##  [140,] 1971 19945.92
##  [141,] 1970 19945.92
##  [142,] 1969 19945.92
##  [143,] 1967 19945.92
##  [144,] 1966 19945.92
##  [145,] 1965 19945.92
##  [146,] 1964 19945.92
##  [147,] 1963 19945.92
##  [148,] 1962 19945.92
##  [149,] 1961 19945.92
##  [150,] 1959 19945.92
##  [151,] 1958 19945.92
##  [152,] 1956 19945.92
##  [153,] 1955 19945.92
##  [154,] 1954 19945.92
##  [155,] 1952 19945.92
##  [156,] 1950 19945.92
##  [157,] 1949 19945.92
##  [158,] 1948 19945.92
##  [159,] 1947 19945.92
##  [160,] 1946 19945.92
##  [161,] 1945 19945.92
##  [162,] 1941 19945.92
##  [163,] 1940 19945.92
##  [164,] 1938 19945.92
##  [165,] 1936 19945.92
##  [166,] 1934 19945.92
##  [167,] 1933 19945.92
##  [168,] 1932 19945.92
##  [169,] 1931 19945.92
##  [170,] 1929 19945.92
##  [171,] 1928 19945.92
##  [172,] 1926 19945.92
##  [173,] 1925 19945.92
##  [174,] 1924 19945.92
##  [175,] 1923 19945.92
##  [176,] 1922 19945.92
##  [177,] 1920 19945.92
##  [178,] 1919 19945.92
##  [179,] 1917 19945.92
##  [180,] 1916 19945.92
##  [181,] 1915 19945.92
##  [182,] 1914 19945.92
##  [183,] 1912 19945.92
##  [184,] 1911 19945.92
##  [185,] 1909 19945.92
##  [186,] 1908 19945.92
##  [187,] 1907 19945.92
##  [188,] 1906 19945.92
##  [189,] 1905 19945.92
##  [190,] 1904 19945.92
##  [191,] 1903 19945.92
##  [192,] 1902 19945.92
##  [193,] 1899 19945.92
##  [194,] 1896 19945.92
##  [195,] 1895 19945.92
##  [196,] 1894 19945.92
##  [197,] 1893 19945.92
##  [198,] 1892 19945.92
##  [199,] 1891 19945.92
##  [200,] 1890 19945.92
##  [201,] 1889 19945.92
##  [202,] 1888 19945.92
##  [203,] 1887 19945.92
##  [204,] 1886 19945.92
##  [205,] 1885 19945.92
##  [206,] 1883 19945.92
##  [207,] 1881 19945.92
##  [208,] 1880 19945.92
##  [209,] 1879 19945.92
##  [210,] 1877 19945.92
##  [211,] 1876 19945.92
##  [212,] 1875 19945.92
##  [213,] 1874 19945.92
##  [214,] 1872 19945.92
##  [215,] 1871 19945.92
##  [216,] 1869 19945.92
##  [217,] 1867 19945.92
##  [218,] 1863 19945.92
##  [219,] 1862 19945.92
##  [220,] 1861 19945.92
##  [221,] 1860 19945.92
##  [222,] 1859 19945.92
##  [223,] 1856 19945.92
##  [224,] 1855 19945.92
##  [225,] 1854 19945.92
##  [226,] 1852 19945.92
##  [227,] 1850 19945.92
##  [228,] 1847 19945.92
##  [229,] 1846 19945.92
##  [230,] 1845 19945.92
##  [231,] 1844 19945.92
##  [232,] 1843 19945.92
##  [233,] 1842 19945.92
##  [234,] 1841 19945.92
##  [235,] 1840 19945.92
##  [236,] 1839 19945.92
##  [237,] 1838 19945.92
##  [238,] 1836 19945.92
##  [239,] 1835 19945.92
##  [240,] 1834 19945.92
##  [241,] 1833 19945.92
##  [242,] 1832 19945.92
##  [243,] 1830 19945.92
##  [244,] 1828 19945.92
##  [245,] 1825 19945.92
##  [246,] 1823 19945.92
##  [247,] 1821 19945.92
##  [248,] 1818 19945.92
##  [249,] 1817 19945.92
##  [250,] 1816 19945.92
##  [251,] 1813 19945.92
##  [252,] 1812 19945.92
##  [253,] 1811 19945.92
##  [254,] 1810 19945.92
##  [255,] 1809 19945.92
##  [256,] 1808 19945.92
##  [257,] 1807 19945.92
##  [258,] 1805 19945.92
##  [259,] 1804 19945.92
##  [260,] 1803 19945.92
##  [261,] 1800 19945.92
##  [262,] 1796 19945.92
##  [263,] 1795 19945.92
##  [264,] 1787 19945.92
##  [265,] 1783 19945.92
##  [266,] 1782 19945.92
##  [267,] 1780 19945.92
##  [268,] 1772 19945.92
##  [269,] 1771 19945.92
##  [270,] 1770 19945.92
##  [271,] 1767 19945.92
##  [272,] 1766 19945.92
##  [273,] 1763 19945.92
##  [274,] 1762 19945.92
##  [275,] 1760 19945.92
##  [276,] 1759 19945.92
##  [277,] 1758 19945.92
##  [278,] 1756 19945.92
##  [279,] 1755 19945.92
##  [280,] 1754 19945.92
##  [281,] 1753 19945.92
##  [282,] 1751 19945.92
##  [283,] 1750 19945.92
##  [284,] 1749 19945.92
##  [285,] 1747 19945.92
##  [286,] 1745 19945.92
##  [287,] 1742 19945.92
##  [288,] 1740 19945.92
##  [289,] 1738 19945.92
##  [290,] 1735 19945.92
##  [291,] 1733 19945.92
##  [292,] 1732 19945.92
##  [293,] 1731 19945.92
##  [294,] 1729 19945.92
##  [295,] 1725 19945.92
##  [296,] 1724 19945.92
##  [297,] 1723 19945.92
##  [298,] 1720 19945.92
##  [299,] 1717 19945.92
##  [300,] 1716 19945.92
##  [301,] 1715 19945.92
##  [302,] 1713 19945.92
##  [303,] 1712 19945.92
##  [304,] 1711 19945.92
##  [305,] 1710 19945.92
##  [306,] 1708 19945.92
##  [307,] 1707 19945.92
##  [308,] 1706 19945.92
##  [309,] 1705 19945.92
##  [310,] 1704 19945.92
##  [311,] 1702 19945.92
##  [312,] 1701 19945.92
##  [313,] 1700 19945.92
##  [314,] 1695 19945.92
##  [315,] 1693 19945.92
##  [316,] 1692 19945.92
##  [317,] 1691 19945.92
##  [318,] 1690 19945.92
##  [319,] 1689 19945.92
##  [320,] 1687 19945.92
##  [321,] 1686 19945.92
##  [322,] 1685 19945.92
##  [323,] 1684 19945.92
##  [324,] 1681 19945.92
##  [325,] 1679 19945.92
##  [326,] 1677 19945.92
##  [327,] 1675 19945.92
##  [328,] 1674 19945.92
##  [329,] 1673 19945.92
##  [330,] 1672 19945.92
##  [331,] 1671 19945.92
##  [332,] 1668 19945.92
##  [333,] 1667 19945.92
##  [334,] 1666 19945.92
##  [335,] 1665 19945.92
##  [336,] 1663 19945.92
##  [337,] 1661 19945.92
##  [338,] 1656 19945.92
##  [339,] 1653 19945.92
##  [340,] 1652 19945.92
##  [341,] 1650 19945.92
##  [342,] 1648 19945.92
##  [343,] 1647 19945.92
##  [344,] 1646 19945.92
##  [345,] 1645 19945.92
##  [346,] 1644 19945.92
##  [347,] 1643 19945.92
##  [348,] 1642 19945.92
##  [349,] 1638 19945.92
##  [350,] 1637 19945.92
##  [351,] 1636 19945.92
##  [352,] 1633 19945.92
##  [353,] 1631 19945.92
##  [354,] 1629 19945.92
##  [355,] 1626 19945.92
##  [356,] 1625 19945.92
##  [357,] 1623 19945.92
##  [358,] 1622 19945.92
##  [359,] 1619 19945.92
##  [360,] 1618 19945.92
##  [361,] 1617 19945.92
##  [362,] 1615 19945.92
##  [363,] 1611 19945.92
##  [364,] 1609 19945.92
##  [365,] 1608 19945.92
##  [366,] 1605 19945.92
##  [367,] 1604 19945.92
##  [368,] 1603 19945.92
##  [369,] 1602 19945.92
##  [370,] 1600 19945.92
##  [371,] 1599 19945.92
##  [372,] 1597 19945.92
##  [373,] 1595 19945.92
##  [374,] 1594 19945.92
##  [375,] 1588 19945.92
##  [376,] 1585 19945.92
##  [377,] 1584 19945.92
##  [378,] 1582 19945.92
##  [379,] 1580 19945.92
##  [380,] 1577 19945.92
##  [381,] 1575 19945.92
##  [382,] 1573 19945.92
##  [383,] 1572 19945.92
##  [384,] 1571 19945.92
##  [385,] 1569 19945.92
##  [386,] 1568 19945.92
##  [387,] 1566 19945.92
##  [388,] 1564 19945.92
##  [389,] 1562 19945.92
##  [390,] 1561 19945.92
##  [391,] 1558 19945.92
##  [392,] 1555 19945.92
##  [393,] 1553 19945.92
##  [394,] 1550 19945.92
##  [395,] 1547 19945.92
##  [396,] 1545 19945.92
##  [397,] 1542 19945.92
##  [398,] 1541 19945.92
##  [399,] 1539 19945.92
##  [400,] 1537 19945.92
##  [401,] 1534 19945.92
##  [402,] 1533 19945.92
##  [403,] 1531 19945.92
##  [404,] 1529 19945.92
##  [405,] 1528 19945.92
##  [406,] 1521 19945.92
##  [407,] 1520 19945.92
##  [408,] 1513 19945.92
##  [409,] 1510 19945.92
##  [410,] 1508 19945.92
##  [411,] 1506 19945.92
##  [412,] 1503 19945.92
##  [413,] 1502 19945.92
##  [414,] 1501 19945.92
##  [415,] 1500 19945.92
##  [416,] 1497 19945.92
##  [417,] 1496 19945.92
##  [418,] 1495 19945.92
##  [419,] 1491 19945.92
##  [420,] 1488 19945.92
##  [421,] 1486 19945.92
##  [422,] 1484 19945.92
##  [423,] 1481 19945.92
##  [424,] 1479 19945.92
##  [425,] 1477 19945.92
##  [426,] 1474 19945.92
##  [427,] 1469 19945.92
##  [428,] 1468 19945.92
##  [429,] 1466 19945.92
##  [430,] 1465 19945.92
##  [431,] 1459 19945.92
##  [432,] 1456 19945.92
##  [433,] 1455 19945.92
##  [434,] 1453 19945.92
##  [435,] 1451 19945.92
##  [436,] 1450 19945.92
##  [437,] 1448 19945.92
##  [438,] 1446 19945.92
##  [439,] 1443 19945.92
##  [440,] 1441 19945.92
##  [441,] 1440 19945.92
##  [442,] 1436 19945.92
##  [443,] 1433 19945.92
##  [444,] 1432 19945.92
##  [445,] 1427 19945.92
##  [446,] 1424 19945.92
##  [447,] 1423 19945.92
##  [448,] 1422 19945.92
##  [449,] 1420 19945.92
##  [450,] 1416 19945.92
##  [451,] 1412 19945.92
##  [452,] 1406 19945.92
##  [453,] 1405 19945.92
##  [454,] 1402 19945.92
##  [455,] 1400 19945.92
##  [456,] 1395 19945.92
##  [457,] 1394 19945.92
##  [458,] 1393 19945.92
##  [459,] 1392 19945.92
##  [460,] 1391 19945.92
##  [461,] 1390 19945.92
##  [462,] 1388 19945.92
##  [463,] 1385 19945.92
##  [464,] 1382 19945.92
##  [465,] 1380 19945.92
##  [466,] 1378 19945.92
##  [467,] 1377 19945.92
##  [468,] 1376 19945.92
##  [469,] 1371 19945.92
##  [470,] 1370 19945.92
##  [471,] 1367 19945.92
##  [472,] 1366 19945.92
##  [473,] 1365 19945.92
##  [474,] 1363 19945.92
##  [475,] 1360 19945.92
##  [476,] 1359 19945.92
##  [477,] 1356 19945.92
##  [478,] 1351 19945.92
##  [479,] 1348 19945.92
##  [480,] 1347 19945.92
##  [481,] 1345 19945.92
##  [482,] 1343 19945.92
##  [483,] 1342 19945.92
##  [484,] 1340 19945.92
##  [485,] 1338 19945.92
##  [486,] 1334 19945.92
##  [487,] 1330 19945.92
##  [488,] 1329 19945.92
##  [489,] 1327 19945.92
##  [490,] 1326 19945.92
##  [491,] 1325 19945.92
##  [492,] 1323 19945.92
##  [493,] 1321 19945.92
##  [494,] 1320 19945.92
##  [495,] 1319 19945.92
##  [496,] 1314 19945.92
##  [497,] 1311 19945.92
##  [498,] 1307 19945.92
##  [499,] 1305 19945.92
##  [500,] 1303 19945.92
##  [501,] 1302 19945.92
##  [502,] 1300 19945.92
##  [503,] 1295 19945.92
##  [504,] 1290 19945.92
##  [505,] 1288 19945.92
##  [506,] 1284 19945.92
##  [507,] 1283 19945.92
##  [508,] 1282 19945.92
##  [509,] 1275 19945.92
##  [510,] 1274 19945.92
##  [511,] 1272 19945.92
##  [512,] 1270 19945.92
##  [513,] 1266 19945.92
##  [514,] 1265 19945.92
##  [515,] 1264 19945.92
##  [516,] 1263 19945.92
##  [517,] 1260 19945.92
##  [518,] 1258 19945.92
##  [519,] 1254 19945.92
##  [520,] 1253 19945.92
##  [521,] 1251 19945.92
##  [522,] 1250 19945.92
##  [523,] 1249 19945.92
##  [524,] 1248 19945.92
##  [525,] 1247 19945.92
##  [526,] 1234 19945.92
##  [527,] 1233 19945.92
##  [528,] 1228 19945.92
##  [529,] 1226 19945.92
##  [530,] 1224 19945.92
##  [531,] 1220 19945.92
##  [532,] 1219 19945.92
##  [533,] 1218 19945.92
##  [534,] 1216 19945.92
##  [535,] 1212 19945.92
##  [536,] 1211 19945.92
##  [537,] 1207 19945.92
##  [538,] 1206 19945.92
##  [539,] 1205 19945.92
##  [540,] 1204 19945.92
##  [541,] 1200 19945.92
##  [542,] 1199 19945.92
##  [543,] 1197 19945.92
##  [544,] 1196 19945.92
##  [545,] 1195 19945.92
##  [546,] 1193 19945.92
##  [547,] 1192 19945.92
##  [548,] 1190 19945.92
##  [549,] 1189 19945.92
##  [550,] 1186 19945.92
##  [551,] 1185 19945.92
##  [552,] 1184 19945.92
##  [553,] 1182 19945.92
##  [554,] 1178 19945.92
##  [555,] 1177 19945.92
##  [556,] 1176 19945.92
##  [557,] 1175 19945.92
##  [558,] 1172 19945.92
##  [559,] 1171 19945.92
##  [560,] 1169 19945.92
##  [561,] 1167 19945.92
##  [562,] 1166 19945.92
##  [563,] 1164 19945.92
##  [564,] 1163 19945.92
##  [565,] 1161 19945.92
##  [566,] 1160 19945.92
##  [567,] 1159 19945.92
##  [568,] 1158 19945.92
##  [569,] 1154 19945.92
##  [570,] 1153 19945.92
##  [571,] 1152 19945.92
##  [572,] 1151 19945.92
##  [573,] 1150 19945.92
##  [574,] 1140 19945.92
##  [575,] 1139 19945.92
##  [576,] 1138 19945.92
##  [577,] 1137 19945.92
##  [578,] 1134 19945.92
##  [579,] 1131 19945.92
##  [580,] 1129 19945.92
##  [581,] 1127 19945.92
##  [582,] 1126 19945.92
##  [583,] 1122 19945.92
##  [584,] 1120 19945.92
##  [585,] 1115 19945.92
##  [586,] 1113 19945.92
##  [587,] 1112 19945.92
##  [588,] 1106 19945.92
##  [589,] 1105 19945.92
##  [590,] 1104 19945.92
##  [591,] 1103 19945.92
##  [592,] 1101 19945.92
##  [593,] 1099 19945.92
##  [594,] 1098 19945.92
##  [595,] 1096 19945.92
##  [596,] 1095 19945.92
##  [597,] 1093 19945.92
##  [598,] 1091 19945.92
##  [599,] 1090 19945.92
##  [600,] 1088 19945.92
##  [601,] 1077 19945.92
##  [602,] 1070 19945.92
##  [603,] 1068 19945.92
##  [604,] 1067 19945.92
##  [605,] 1063 19945.92
##  [606,] 1061 19945.92
##  [607,] 1059 19945.92
##  [608,] 1058 19945.92
##  [609,] 1057 19945.92
##  [610,] 1056 19945.92
##  [611,] 1047 19945.92
##  [612,] 1040 19945.92
##  [613,] 1039 19945.92
##  [614,] 1038 19945.92
##  [615,] 1037 19945.92
##  [616,] 1035 19945.92
##  [617,] 1034 19945.92
##  [618,] 1032 19945.92
##  [619,] 1030 19945.92
##  [620,] 1028 19945.92
##  [621,] 1026 19945.92
##  [622,] 1025 19945.92
##  [623,] 1024 19945.92
##  [624,] 1022 19945.92
##  [625,] 1021 19945.92
##  [626,] 1018 19945.92
##  [627,] 1013 19945.92
##  [628,] 1011 19945.92
##  [629,] 1007 19945.92
##  [630,] 1003 19945.92
##  [631,]  998 19945.92
##  [632,]  995 19945.92
##  [633,]  994 19945.92
##  [634,]  993 19945.92
##  [635,]  992 19945.92
##  [636,]  991 19945.92
##  [637,]  990 19945.92
##  [638,]  989 19945.92
##  [639,]  986 19945.92
##  [640,]  985 19945.92
##  [641,]  983 19945.92
##  [642,]  981 19945.92
##  [643,]  979 19945.92
##  [644,]  978 19945.92
##  [645,]  977 19945.92
##  [646,]  976 19945.92
##  [647,]  974 19945.92
##  [648,]  973 19945.92
##  [649,]  971 19945.92
##  [650,]  963 19945.92
##  [651,]  958 19945.92
##  [652,]  952 19945.92
##  [653,]  950 19945.92
##  [654,]  949 19945.92
##  [655,]  944 19945.92
##  [656,]  942 19945.92
##  [657,]  940 19945.92
##  [658,]  939 19945.92
##  [659,]  937 19945.92
##  [660,]  936 19945.92
##  [661,]  933 19945.92
##  [662,]  929 19945.92
##  [663,]  927 19945.92
##  [664,]  921 19945.92
##  [665,]  919 19945.92
##  [666,]  918 19945.92
##  [667,]  914 19945.92
##  [668,]  913 19945.92
##  [669,]  908 19945.92
##  [670,]  905 19945.92
##  [671,]  898 19945.92
##  [672,]  897 19945.92
##  [673,]  896 19945.92
##  [674,]  893 19945.92
##  [675,]  888 19945.92
##  [676,]  885 19945.92
##  [677,]  883 19945.92
##  [678,]  881 19945.92
##  [679,]  880 19945.92
##  [680,]  879 19945.92
##  [681,]  876 19945.92
##  [682,]  875 19945.92
##  [683,]  874 19945.92
##  [684,]  864 19945.92
##  [685,]  862 19945.92
##  [686,]  861 19945.92
##  [687,]  859 19945.92
##  [688,]  855 19945.92
##  [689,]  853 19945.92
##  [690,]  850 19945.92
##  [691,]  849 19945.92
##  [692,]  847 19945.92
##  [693,]  846 19945.92
##  [694,]  841 19945.92
##  [695,]  839 19945.92
##  [696,]  838 19945.92
##  [697,]  837 19945.92
##  [698,]  834 19945.92
##  [699,]  829 19945.92
##  [700,]  827 19945.92
##  [701,]  826 19945.92
##  [702,]  824 19945.92
##  [703,]  823 19945.92
##  [704,]  822 19945.92
##  [705,]  821 19945.92
##  [706,]  820 19945.92
##  [707,]  819 19945.92
##  [708,]  818 19945.92
##  [709,]  817 19945.92
##  [710,]  813 19945.92
##  [711,]  811 19945.92
##  [712,]  809 19945.92
##  [713,]  808 19945.92
##  [714,]  807 19945.92
##  [715,]  806 19945.92
##  [716,]  795 19945.92
##  [717,]  788 19945.92
##  [718,]  787 19945.92
##  [719,]  785 19945.92
##  [720,]  784 19945.92
##  [721,]  782 19945.92
##  [722,]  781 19945.92
##  [723,]  780 19945.92
##  [724,]  775 19945.92
##  [725,]  774 19945.92
##  [726,]  773 19945.92
##  [727,]  771 19945.92
##  [728,]  770 19945.92
##  [729,]  769 19945.92
##  [730,]  768 19945.92
##  [731,]  767 19945.92
##  [732,]  766 19945.92
##  [733,]  753 19945.92
##  [734,]  752 19945.92
##  [735,]  751 19945.92
##  [736,]  749 19945.92
##  [737,]  744 19945.92
##  [738,]  735 19945.92
##  [739,]  734 19945.92
##  [740,]  733 19945.92
##  [741,]  728 19945.92
##  [742,]  727 19945.92
##  [743,]  726 19945.92
##  [744,]  722 19945.92
##  [745,]  711 19945.92
##  [746,]  710 19945.92
##  [747,]  708 19945.92
##  [748,]  707 19945.92
##  [749,]  705 19945.92
##  [750,]  704 19945.92
##  [751,]  698 19945.92
##  [752,]  688 19945.92
##  [753,]  685 19945.92
##  [754,]  684 19945.92
##  [755,]  683 19945.92
##  [756,]  679 19945.92
##  [757,]  676 19945.92
##  [758,]  674 19945.92
##  [759,]  673 19945.92
##  [760,]  672 19945.92
##  [761,]  669 19945.92
##  [762,]  666 19945.92
##  [763,]  661 19945.92
##  [764,]  660 19945.92
##  [765,]  659 19945.92
##  [766,]  657 19945.92
##  [767,]  656 19945.92
##  [768,]  654 19945.92
##  [769,]  649 19945.92
##  [770,]  647 19945.92
##  [771,]  645 19945.92
##  [772,]  644 19945.92
##  [773,]  643 19945.92
##  [774,]  628 19945.92
##  [775,]  627 19945.92
##  [776,]  620 19945.92
##  [777,]  618 19945.92
##  [778,]  614 19945.92
##  [779,]  609 19945.92
##  [780,]  601 19945.92
##  [781,]  598 19945.92
##  [782,]  597 19945.92
##  [783,]  596 19945.92
##  [784,]  595 19945.92
##  [785,]  593 19945.92
##  [786,]  589 19945.92
##  [787,]  588 19945.92
##  [788,]  587 19945.92
##  [789,]  586 19945.92
##  [790,]  582 19945.92
##  [791,]  581 19945.92
##  [792,]  580 19945.92
##  [793,]  569 19945.92
##  [794,]  567 19945.92
##  [795,]  565 19945.92
##  [796,]  564 19945.92
##  [797,]  557 19945.92
##  [798,]  555 19945.92
##  [799,]  552 19945.92
##  [800,]  551 19945.92
##  [801,]  549 19945.92
##  [802,]  548 19945.92
##  [803,]  547 19945.92
##  [804,]  544 19945.92
##  [805,]  543 19945.92
##  [806,]  527 19945.92
##  [807,]  525 19945.92
##  [808,]  522 19945.92
##  [809,]  521 19945.92
##  [810,]  517 19945.92
##  [811,]  515 19945.92
##  [812,]  513 19945.92
##  [813,]  509 19945.92
##  [814,]  508 19945.92
##  [815,]  506 19945.92
##  [816,]  504 19945.92
##  [817,]  501 19945.92
##  [818,]  493 19945.92
##  [819,]  492 19945.92
##  [820,]  490 19945.92
##  [821,]  482 19945.92
##  [822,]  479 19945.92
##  [823,]  472 19945.92
##  [824,]  471 19945.92
##  [825,]  466 19945.92
##  [826,]  449 19945.92
##  [827,]  447 19945.92
##  [828,]  445 19945.92
##  [829,]  444 19945.92
##  [830,]  443 19945.92
##  [831,]  442 19945.92
##  [832,]  441 19945.92
##  [833,]  440 19945.92
##  [834,]  439 19945.92
##  [835,]  438 19945.92
##  [836,]  434 19945.92
##  [837,]  428 19945.92
##  [838,]  426 19945.92
##  [839,]  418 19945.92
##  [840,]  416 19945.92
##  [841,]  415 19945.92
##  [842,]  412 19945.92
##  [843,]  409 19945.92
##  [844,]  406 19945.92
##  [845,]  401 19945.92
##  [846,]  399 19945.92
##  [847,]  397 19945.92
##  [848,]  396 19945.92
##  [849,]  395 19945.92
##  [850,]  394 19945.92
##  [851,]  393 19945.92
##  [852,]  390 19945.92
##  [853,]  383 19945.92
##  [854,]  382 19945.92
##  [855,]  381 19945.92
##  [856,]  379 19945.92
##  [857,]  375 19945.92
##  [858,]  374 19945.92
##  [859,]  373 19945.92
##  [860,]  372 19945.92
##  [861,]  370 19945.92
##  [862,]  365 19945.92
##  [863,]  363 19945.92
##  [864,]  359 19945.92
##  [865,]  356 19945.92
##  [866,]  350 19945.92
##  [867,]  348 19945.92
##  [868,]  347 19945.92
##  [869,]  342 19945.92
##  [870,]  341 19945.92
##  [871,]  340 19945.92
##  [872,]  334 19945.92
##  [873,]  330 19945.92
##  [874,]  323 19945.92
##  [875,]  322 19945.92
##  [876,]  321 19945.92
##  [877,]  318 19945.92
##  [878,]  317 19945.92
##  [879,]  306 19945.92
##  [880,]  302 19945.92
##  [881,]  300 19945.92
##  [882,]  299 19945.92
##  [883,]  297 19945.92
##  [884,]  290 19945.92
##  [885,]  289 19945.92
##  [886,]  287 19945.92
##  [887,]  281 19945.92
##  [888,]  280 19945.92
##  [889,]  279 19945.92
##  [890,]  278 19945.92
##  [891,]  274 19945.92
##  [892,]  273 19945.92
##  [893,]  267 19945.92
##  [894,]  266 19945.92
##  [895,]  261 19945.92
##  [896,]  260 19945.92
##  [897,]  257 19945.92
##  [898,]  256 19945.92
##  [899,]  255 19945.92
##  [900,]  253 19945.92
##  [901,]  252 19945.92
##  [902,]  251 19945.92
##  [903,]  230 19945.92
##  [904,]  229 19945.92
##  [905,]  228 19945.92
##  [906,]  226 19945.92
##  [907,]  225 19945.92
##  [908,]  224 19945.92
##  [909,]  222 19945.92
##  [910,]  221 19945.92
##  [911,]  214 19945.92
##  [912,]  213 19945.92
##  [913,]  211 19945.92
##  [914,]  210 19945.92
##  [915,]  202 19945.92
##  [916,]  199 19945.92
##  [917,]  195 19945.92
##  [918,]  194 19945.92
##  [919,]  192 19945.92
##  [920,]  189 19945.92
##  [921,]  179 19945.92
##  [922,]  178 19945.92
##  [923,]  177 19945.92
##  [924,]  175 19945.92
##  [925,]  174 19945.92
##  [926,]  173 19945.92
##  [927,]  171 19945.92
##  [928,]  170 19945.92
##  [929,]  165 19945.92
##  [930,]  164 19945.92
##  [931,]  163 19945.92
##  [932,]  162 19945.92
##  [933,]  160 19945.92
##  [934,]  159 19945.92
##  [935,]  153 19945.92
##  [936,]  152 19945.92
##  [937,]  151 19945.92
##  [938,]  150 19945.92
##  [939,]  149 19945.92
##  [940,]  148 19945.92
##  [941,]  146 19945.92
##  [942,]  145 19945.92
##  [943,]  144 19945.92
##  [944,]  140 19945.92
##  [945,]  139 19945.92
##  [946,]  135 19945.92
##  [947,]  134 19945.92
##  [948,]  125 19945.92
##  [949,]  124 19945.92
##  [950,]  122 19945.92
##  [951,]  120 19945.92
##  [952,]  116 19945.92
##  [953,]  115 19945.92
##  [954,]  112 19945.92
##  [955,]  106 19945.92
##  [956,]  102 19945.92
##  [957,]   98 19945.92
##  [958,]   96 19945.92
##  [959,]   95 19945.92
##  [960,]   90 19945.92
##  [961,]   89 19945.92
##  [962,]   88 19945.92
##  [963,]   82 19945.92
##  [964,]   80 19945.92
##  [965,]   79 19945.92
##  [966,]   78 19945.92
##  [967,]   75 19945.92
##  [968,]   74 19945.92
##  [969,]   73 19945.92
##  [970,]   70 19945.92
##  [971,]   60 19945.92
##  [972,]   59 19945.92
##  [973,]   57 19945.92
##  [974,]   56 19945.92
##  [975,]   55 19945.92
##  [976,]   54 19945.92
##  [977,]   51 19945.92
##  [978,]   48 19945.92
##  [979,]   45 19945.92
##  [980,]   43 19945.92
##  [981,]   42 19945.92
##  [982,]   41 19945.92
##  [983,]   39 19945.92
##  [984,]   38 19945.92
##  [985,]   36 19945.92
##  [986,]   35 19945.92
##  [987,]   33 19945.92
##  [988,]   32 19945.92
##  [989,]   30 19945.92
##  [990,]   28 19945.92
##  [991,]   27 19945.92
##  [992,]   26 19945.92
##  [993,]   25 19945.92
##  [994,]   23 19945.92
##  [995,]   21 19945.92
##  [996,]   20 19945.92
##  [997,]   19 19945.92
##  [998,]   17 19945.92
##  [999,]   16 19945.92
## [1000,]   15 19945.92
## [1001,]   14 19945.92
## [1002,]   13 19945.92
## [1003,]   12 19945.92
## [1004,]   11 19945.92
## [1005,]   10 19945.92
## [1006,]    9 19945.92
## [1007,]    8 19945.92
## [1008,]    7 19945.92
## [1009,]    6 19945.92
## [1010,]    5 19945.92
## [1011,]    4 19945.92
## [1012,]    3 20175.51
## [1013,]    2 20477.21
## [1014,]    1 21194.48
plot(cvTreeQ1$size, cvTreeQ1$dev, type="b")

The lower the deviance, the better. best size is 10 as it saturates at tree node [577,] 10 13971.86

bestSizeQ1 <- 10
ptreeFitQ1 <- prune.tree(ltreeFitQ1, best = bestSizeQ1)
plot(ptreeFitQ1)
text(ptreeFitQ1, pretty = FALSE)

summary(ptreeFitQ1)
## 
## Classification tree:
## snip.tree(tree = ltreeFitQ1, nodes = c(19L, 13L, 7L, 8L, 74L, 
## 72L, 73L, 75L, 5L, 12L))
## Variables actually used in tree construction:
## [1] "Contact" "Age"     "Default" "Job"     "Marital"
## Number of terminal nodes:  10 
## Residual mean deviance:  0.6484 = 19450 / 29990 
## Misclassification error rate: 0.1132 = 3397 / 30000

Obtain Accuracy parameter

The following table compares the optimal model with the full model tree of Subscribed vs all the variables of the Personal Profile and Financial Profile of a person.

Type Model complexity Relevant variables Misclassification error rate
Full Model 8 leaf nodes NumEmp, Duration, PrevDays, Month 0.09753 = 2926 / 30000
Optimal Model 4 leaf nodes Contact, Age, Default 0.1132 = 3397 / 30000

Verify the Misclassification error rate by predicting with MarketingPred data.

predDataQ1op <- predict(ptreeFitQ1, marketDataQ1, type = "class")
summary(predDataQ1op)
##    no   yes 
## 30000     0
table(marketData$Subscribed, predDataQ1op)
##      predDataQ1op
##          no   yes
##   no  26603     0
##   yes  3397     0

(0+3397) / (30000+0) = 0.1132333333. The Misclassification error rate is very similar.

Import the CSV data file assign2_MarketingPred.csv for analysis, and quickly check the structure of the data.

marketPred <- read.csv("assign2_MarketingPred.csv", header = TRUE)
str(marketPred)
## 'data.frame':    1000 obs. of  20 variables:
##  $ Age          : int  29 25 37 31 37 49 48 52 35 34 ...
##  $ Job          : Factor w/ 12 levels "admin","blue-collar",..: 3 2 2 10 1 4 2 10 5 5 ...
##  $ Marital      : Factor w/ 4 levels "divorced","married",..: 2 3 2 2 2 2 2 2 2 2 ...
##  $ Education    : Factor w/ 7 levels "basic4y","basic6y",..: 2 3 5 6 6 5 3 5 6 6 ...
##  $ Default      : Factor w/ 2 levels "no","unknown": 1 1 1 1 1 1 1 1 1 1 ...
##  $ Housing      : Factor w/ 3 levels "no","unknown",..: 1 1 1 1 1 3 1 1 3 1 ...
##  $ Loan         : Factor w/ 3 levels "no","unknown",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ Contact      : Factor w/ 2 levels "cellular","telephone": 2 1 2 1 2 2 1 1 1 2 ...
##  $ Month        : Factor w/ 10 levels "apr","aug","dec",..: 7 7 5 2 5 4 7 4 1 7 ...
##  $ Day          : Factor w/ 5 levels "fri","mon","thu",..: 1 1 3 1 2 3 3 1 3 3 ...
##  $ Duration     : int  217 299 11 168 85 645 214 221 584 200 ...
##  $ Campaign     : int  2 3 7 1 8 2 1 2 1 2 ...
##  $ PrevDays     : int  999 999 999 999 999 999 999 999 999 999 ...
##  $ Previous     : int  0 0 0 0 0 0 1 0 0 0 ...
##  $ PrevOutcome  : Factor w/ 3 levels "failure","nonexistent",..: 2 2 2 2 2 2 1 2 2 2 ...
##  $ EmpVarRate   : num  1.1 -1.8 1.4 1.4 1.4 1.4 -1.8 1.4 -1.8 1.1 ...
##  $ ConPriceIndex: num  94 92.9 94.5 93.4 94.5 ...
##  $ ConConfIndex : num  -36.4 -46.2 -41.8 -36.1 -41.8 -42.7 -46.2 -42.7 -47.1 -36.4 ...
##  $ EuriborRate  : num  4.86 1.31 4.96 4.96 4.87 ...
##  $ NumEmp       : num  5191 5099 5228 5228 5228 ...

Conclusion

Identify the top three important variables in this case.

Contact, Age, Default as given by the optimal tree.

Why are these important? Justify in terms of the Business.

The form of communication in sales is the most important when selling something in order to get the message and benefits across to the customer. The Age of customers is also important as a person who has retired would not be keen in looking for profits by subscribing to a bank. The Default rate is important as if a person have credit in their default, they would not have money to subscribe to a bank if they cannot even pay their debts.

How would you influence Subscribed using these variables?

The campaign shall target their customers using the celluar network, target customers aged < 59.5 and do not have credit default. Some ground survey could be done to obtain such information beforehand.

Problem 2

Build an optimal tree-based classification model for Subscribed vs Personal Profile, Financial Profile, and Campaign Data corresponding to a person. Check the relevant accuracy parameters of your model, and use it to predict Subscribed in the assign2_MarketingPred.csv.

Prediction

The same dataset is used for predicting as the previous problem.

str(marketPred)
## 'data.frame':    1000 obs. of  20 variables:
##  $ Age          : int  29 25 37 31 37 49 48 52 35 34 ...
##  $ Job          : Factor w/ 12 levels "admin","blue-collar",..: 3 2 2 10 1 4 2 10 5 5 ...
##  $ Marital      : Factor w/ 4 levels "divorced","married",..: 2 3 2 2 2 2 2 2 2 2 ...
##  $ Education    : Factor w/ 7 levels "basic4y","basic6y",..: 2 3 5 6 6 5 3 5 6 6 ...
##  $ Default      : Factor w/ 2 levels "no","unknown": 1 1 1 1 1 1 1 1 1 1 ...
##  $ Housing      : Factor w/ 3 levels "no","unknown",..: 1 1 1 1 1 3 1 1 3 1 ...
##  $ Loan         : Factor w/ 3 levels "no","unknown",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ Contact      : Factor w/ 2 levels "cellular","telephone": 2 1 2 1 2 2 1 1 1 2 ...
##  $ Month        : Factor w/ 10 levels "apr","aug","dec",..: 7 7 5 2 5 4 7 4 1 7 ...
##  $ Day          : Factor w/ 5 levels "fri","mon","thu",..: 1 1 3 1 2 3 3 1 3 3 ...
##  $ Duration     : int  217 299 11 168 85 645 214 221 584 200 ...
##  $ Campaign     : int  2 3 7 1 8 2 1 2 1 2 ...
##  $ PrevDays     : int  999 999 999 999 999 999 999 999 999 999 ...
##  $ Previous     : int  0 0 0 0 0 0 1 0 0 0 ...
##  $ PrevOutcome  : Factor w/ 3 levels "failure","nonexistent",..: 2 2 2 2 2 2 1 2 2 2 ...
##  $ EmpVarRate   : num  1.1 -1.8 1.4 1.4 1.4 1.4 -1.8 1.4 -1.8 1.1 ...
##  $ ConPriceIndex: num  94 92.9 94.5 93.4 94.5 ...
##  $ ConConfIndex : num  -36.4 -46.2 -41.8 -36.1 -41.8 -42.7 -46.2 -42.7 -47.1 -36.4 ...
##  $ EuriborRate  : num  4.86 1.31 4.96 4.96 4.87 ...
##  $ NumEmp       : num  5191 5099 5228 5228 5228 ...

Building tree-based classificaiton model

Install the tree package if you have not, import tree library. Construct the full model tree: decision tree of Subscribed vs all the variables of the Personal Profile, Financial Profile, and Campaign Data of a person. Display and print the entire tree structure.

# install.packages("tree")
library("tree")
marketDataQ2 <- marketData[-c(16:20)]
treefitQ2 <- tree(Subscribed ~ ., data = marketDataQ2)
plot(treefitQ2)
text(treefitQ2, pretty = FALSE, all = TRUE)

treefitQ2
## node), split, n, deviance, yval, (yprob)
##       * denotes terminal node
## 
##  1) root 30000 21190.0 no ( 0.886767 0.113233 )  
##    2) Duration < 393.5 24594 11280.0 no ( 0.939131 0.060869 )  
##      4) PrevDays < 513 811  1100.0 yes ( 0.413070 0.586930 ) *
##      5) PrevDays > 513 23783  8426.0 no ( 0.957070 0.042930 )  
##       10) Month: aug,jul,jun,may,nov 21438  4895.0 no ( 0.975744 0.024256 )  
##         20) Duration < 159.5 11901  1009.0 no ( 0.992858 0.007142 ) *
##         21) Duration > 159.5 9537  3536.0 no ( 0.954388 0.045612 ) *
##       11) Month: apr,dec,mar,oct,sep 2345  2433.0 no ( 0.786354 0.213646 ) *
##    3) Duration > 393.5 5406  7010.0 no ( 0.648539 0.351461 )  
##      6) Duration < 644.5 3251  3608.0 no ( 0.756690 0.243310 )  
##       12) PrevDays < 510 174   146.8 yes ( 0.149425 0.850575 ) *
##       13) PrevDays > 510 3077  3154.0 no ( 0.791030 0.208970 ) *
##      7) Duration > 644.5 2155  2986.0 yes ( 0.485383 0.514617 ) *
summary(treefitQ2)
## 
## Classification tree:
## tree(formula = Subscribed ~ ., data = marketDataQ2)
## Variables actually used in tree construction:
## [1] "Duration" "PrevDays" "Month"   
## Number of terminal nodes:  7 
## Residual mean deviance:  0.4789 = 14360 / 29990 
## Misclassification error rate: 0.1024 = 3071 / 30000

Obtain Accuracy parameter

The following table summarizes the full model tree of Subscribed vs all the variables of the Personal Profile, Financial Profile, and Campaign Data of a person.

Type Model complexity Relevant variables Misclassification error rate
Full Model 7 leaf nodes Duration, PrevDays, Month 0.1024 = 3071 / 30000

Verify the Misclassification error rate by predicting with MarketingPred data.

predDataQ2 <- predict(treefitQ2, marketDataQ2, type = "class")
summary(predDataQ2)
##    no   yes 
## 26860  3140
table(marketData$Subscribed, predDataQ2)
##      predDataQ2
##          no   yes
##   no  25196  1407
##   yes  1664  1733

(1407+1664) / (26860+3140) = 0.1023666667. The Misclassification error rate is very similar.

Optimise tree-based classificaiton model by having it be Cross Validated

Starting with the largest tree

ltreeFitQ2 <- tree(Subscribed ~ ., data = marketDataQ2, 
                 split = "deviance",
                 method = "recursive.partition",
                 control = tree.control(nobs = nrow(marketDataQ2),
                                        mincut = 7,
                                        mindev = 0))
plot(ltreeFitQ2)
## Warning in node * 2L: NAs produced by integer overflow

This is too large to be useful. Implement 10-fold Cross-Validation

cvTreeQ2 <- cv.tree(ltreeFitQ2, FUN = prune.tree, K = 10) 
cbind(cvTreeQ2$size, cvTreeQ2$dev)
##        [,1]     [,2]
##   [1,] 1082 14320.81
##   [2,] 1075 14320.81
##   [3,] 1074 14320.81
##   [4,] 1073 14320.81
##   [5,] 1071 14320.81
##   [6,] 1069 14320.81
##   [7,] 1068 14320.81
##   [8,] 1064 14320.81
##   [9,] 1062 14320.81
##  [10,] 1060 14320.81
##  [11,] 1058 14320.81
##  [12,] 1057 14320.81
##  [13,] 1056 14320.81
##  [14,] 1055 14320.81
##  [15,] 1054 14320.81
##  [16,] 1051 14320.81
##  [17,] 1050 14320.81
##  [18,] 1048 14320.81
##  [19,] 1046 14320.81
##  [20,] 1041 14320.81
##  [21,] 1038 14320.81
##  [22,] 1037 14320.81
##  [23,] 1036 14320.81
##  [24,] 1034 14320.81
##  [25,] 1032 14320.81
##  [26,] 1031 14320.81
##  [27,] 1028 14320.81
##  [28,] 1021 14320.81
##  [29,] 1020 14320.81
##  [30,] 1019 14320.81
##  [31,] 1015 14320.81
##  [32,] 1014 14320.81
##  [33,] 1011 14320.81
##  [34,] 1010 14320.81
##  [35,] 1009 14320.81
##  [36,] 1008 14320.81
##  [37,] 1006 14320.81
##  [38,] 1004 14320.81
##  [39,] 1003 14320.81
##  [40,] 1002 14320.81
##  [41,] 1001 14320.81
##  [42,] 1000 14320.81
##  [43,]  999 14320.81
##  [44,]  997 14320.81
##  [45,]  995 14320.81
##  [46,]  994 14320.81
##  [47,]  993 14320.81
##  [48,]  988 14320.81
##  [49,]  986 14320.81
##  [50,]  985 14320.81
##  [51,]  983 14320.81
##  [52,]  982 14320.81
##  [53,]  981 14320.81
##  [54,]  979 14320.81
##  [55,]  978 14320.81
##  [56,]  976 14320.81
##  [57,]  974 14320.81
##  [58,]  973 14320.81
##  [59,]  972 14320.81
##  [60,]  967 14320.81
##  [61,]  966 14320.81
##  [62,]  964 14320.81
##  [63,]  963 14320.81
##  [64,]  962 14320.81
##  [65,]  959 14320.81
##  [66,]  958 14320.81
##  [67,]  954 14320.81
##  [68,]  953 14320.81
##  [69,]  952 14320.81
##  [70,]  951 14320.81
##  [71,]  948 14320.81
##  [72,]  946 14320.81
##  [73,]  945 14320.81
##  [74,]  944 14320.81
##  [75,]  942 14320.81
##  [76,]  939 14320.81
##  [77,]  933 14320.81
##  [78,]  932 14320.81
##  [79,]  931 14320.81
##  [80,]  930 14320.81
##  [81,]  928 14320.81
##  [82,]  926 14320.81
##  [83,]  925 14320.81
##  [84,]  923 14320.81
##  [85,]  922 14320.81
##  [86,]  921 14320.81
##  [87,]  920 14320.81
##  [88,]  919 14320.81
##  [89,]  918 14320.81
##  [90,]  917 14320.81
##  [91,]  916 14320.81
##  [92,]  914 14320.81
##  [93,]  912 14320.81
##  [94,]  911 14320.81
##  [95,]  910 14320.81
##  [96,]  909 14320.81
##  [97,]  908 14320.81
##  [98,]  907 14320.81
##  [99,]  906 14320.81
## [100,]  905 14320.81
## [101,]  904 14320.81
## [102,]  903 14320.81
## [103,]  900 14320.81
## [104,]  898 14320.81
## [105,]  896 14320.81
## [106,]  895 14320.81
## [107,]  894 14320.81
## [108,]  893 14320.81
## [109,]  891 14320.81
## [110,]  890 14320.81
## [111,]  887 14320.81
## [112,]  886 14320.81
## [113,]  884 14320.81
## [114,]  883 14320.81
## [115,]  882 14320.81
## [116,]  881 14320.81
## [117,]  879 14320.81
## [118,]  867 14320.81
## [119,]  866 14320.81
## [120,]  865 14320.81
## [121,]  864 14320.81
## [122,]  859 14320.81
## [123,]  857 14320.81
## [124,]  856 14320.81
## [125,]  855 14320.81
## [126,]  854 14320.81
## [127,]  852 14320.81
## [128,]  851 14320.81
## [129,]  850 14320.81
## [130,]  848 14320.81
## [131,]  847 14320.81
## [132,]  846 14320.81
## [133,]  845 14320.81
## [134,]  844 14320.81
## [135,]  842 14320.81
## [136,]  841 14320.81
## [137,]  840 14320.81
## [138,]  839 14320.81
## [139,]  838 14320.81
## [140,]  836 14320.81
## [141,]  835 14320.81
## [142,]  834 14320.81
## [143,]  833 14320.81
## [144,]  832 14320.81
## [145,]  831 14320.81
## [146,]  830 14320.81
## [147,]  829 14320.81
## [148,]  828 14320.81
## [149,]  827 14320.81
## [150,]  826 14320.81
## [151,]  821 14320.81
## [152,]  819 14320.81
## [153,]  817 14320.81
## [154,]  816 14320.81
## [155,]  815 14320.81
## [156,]  813 14320.81
## [157,]  812 14320.81
## [158,]  811 14320.81
## [159,]  810 14320.81
## [160,]  808 14320.81
## [161,]  807 14320.81
## [162,]  805 14320.81
## [163,]  804 14320.81
## [164,]  802 14320.81
## [165,]  801 14320.81
## [166,]  800 14320.81
## [167,]  797 14320.81
## [168,]  795 14320.81
## [169,]  794 14320.81
## [170,]  793 14320.81
## [171,]  792 14320.81
## [172,]  791 14320.81
## [173,]  790 14320.81
## [174,]  789 14320.81
## [175,]  788 14320.81
## [176,]  786 14320.81
## [177,]  785 14320.81
## [178,]  784 14320.81
## [179,]  783 14320.81
## [180,]  782 14320.81
## [181,]  781 14320.81
## [182,]  779 14320.81
## [183,]  778 14320.81
## [184,]  774 14320.81
## [185,]  773 14320.81
## [186,]  768 14320.81
## [187,]  766 14320.81
## [188,]  761 14320.81
## [189,]  760 14320.81
## [190,]  758 14320.81
## [191,]  755 14320.81
## [192,]  754 14320.81
## [193,]  753 14320.81
## [194,]  751 14320.81
## [195,]  750 14320.81
## [196,]  747 14320.81
## [197,]  744 14320.81
## [198,]  743 14320.81
## [199,]  741 14320.81
## [200,]  738 14320.81
## [201,]  737 14320.81
## [202,]  735 14320.81
## [203,]  734 14320.81
## [204,]  731 14320.81
## [205,]  729 14320.81
## [206,]  728 14320.81
## [207,]  727 14320.81
## [208,]  726 14320.81
## [209,]  721 14320.81
## [210,]  720 14320.81
## [211,]  719 14320.81
## [212,]  717 14320.81
## [213,]  716 14320.81
## [214,]  715 14320.81
## [215,]  714 14320.81
## [216,]  713 14320.81
## [217,]  712 14320.81
## [218,]  708 14320.81
## [219,]  707 14320.81
## [220,]  705 14320.81
## [221,]  704 14320.81
## [222,]  703 14320.81
## [223,]  702 14320.81
## [224,]  699 14320.81
## [225,]  697 14320.81
## [226,]  696 14320.81
## [227,]  695 14320.81
## [228,]  694 14320.81
## [229,]  692 14320.81
## [230,]  688 14320.81
## [231,]  686 14320.81
## [232,]  685 14320.81
## [233,]  684 14320.81
## [234,]  682 14320.81
## [235,]  680 14320.81
## [236,]  679 14320.81
## [237,]  678 14320.81
## [238,]  677 14320.81
## [239,]  676 14320.81
## [240,]  675 14320.81
## [241,]  674 14320.81
## [242,]  673 14320.81
## [243,]  668 14320.81
## [244,]  665 14320.81
## [245,]  662 14320.81
## [246,]  661 14320.81
## [247,]  658 14320.81
## [248,]  657 14320.81
## [249,]  655 14320.81
## [250,]  654 14320.81
## [251,]  653 14320.81
## [252,]  652 14320.81
## [253,]  650 14320.81
## [254,]  648 14320.81
## [255,]  645 14320.81
## [256,]  643 14320.81
## [257,]  642 14320.81
## [258,]  639 14320.81
## [259,]  638 14320.81
## [260,]  637 14320.81
## [261,]  636 14320.81
## [262,]  633 14320.81
## [263,]  627 14320.81
## [264,]  626 14320.81
## [265,]  625 14320.81
## [266,]  624 14320.81
## [267,]  623 14320.81
## [268,]  622 14320.81
## [269,]  621 14320.81
## [270,]  619 14320.81
## [271,]  618 14320.81
## [272,]  617 14320.81
## [273,]  614 14320.81
## [274,]  613 14320.81
## [275,]  612 14320.81
## [276,]  611 14320.81
## [277,]  610 14320.81
## [278,]  608 14320.81
## [279,]  600 14320.81
## [280,]  598 14320.81
## [281,]  591 14320.81
## [282,]  589 14320.81
## [283,]  586 14320.81
## [284,]  582 14320.81
## [285,]  580 14320.81
## [286,]  578 14320.81
## [287,]  576 14320.81
## [288,]  572 14320.81
## [289,]  571 14320.81
## [290,]  565 14320.81
## [291,]  564 14320.81
## [292,]  563 14320.81
## [293,]  559 14320.81
## [294,]  558 14320.81
## [295,]  555 14320.81
## [296,]  554 14320.81
## [297,]  553 14320.81
## [298,]  542 14320.81
## [299,]  541 14320.81
## [300,]  538 14320.81
## [301,]  537 14320.81
## [302,]  535 14320.81
## [303,]  534 14320.81
## [304,]  533 14320.81
## [305,]  532 14320.81
## [306,]  531 14320.81
## [307,]  530 14320.81
## [308,]  524 14320.81
## [309,]  523 14320.81
## [310,]  522 14320.81
## [311,]  520 14320.81
## [312,]  516 14320.81
## [313,]  512 14320.81
## [314,]  509 14320.81
## [315,]  507 14320.81
## [316,]  506 14320.81
## [317,]  505 14320.81
## [318,]  502 14320.81
## [319,]  498 14320.81
## [320,]  496 14320.81
## [321,]  493 14320.81
## [322,]  492 14320.81
## [323,]  487 14320.81
## [324,]  486 14320.81
## [325,]  485 14320.81
## [326,]  484 14320.81
## [327,]  479 14320.81
## [328,]  478 14320.81
## [329,]  476 14320.81
## [330,]  474 14320.81
## [331,]  473 14320.81
## [332,]  472 14320.81
## [333,]  471 14320.81
## [334,]  470 14320.81
## [335,]  468 14320.81
## [336,]  465 14320.81
## [337,]  461 14320.81
## [338,]  459 14320.81
## [339,]  456 14320.81
## [340,]  454 14320.81
## [341,]  453 14320.81
## [342,]  446 14320.81
## [343,]  445 14320.81
## [344,]  443 14320.81
## [345,]  441 14320.81
## [346,]  440 14320.81
## [347,]  436 14320.81
## [348,]  434 14320.81
## [349,]  433 14320.81
## [350,]  425 14320.81
## [351,]  424 14320.81
## [352,]  423 14320.81
## [353,]  422 14320.81
## [354,]  419 14320.81
## [355,]  418 14320.81
## [356,]  417 14320.81
## [357,]  416 14320.81
## [358,]  411 14320.81
## [359,]  408 14320.81
## [360,]  406 14320.81
## [361,]  401 14320.81
## [362,]  395 14320.81
## [363,]  394 14320.81
## [364,]  393 14320.81
## [365,]  392 14320.81
## [366,]  391 14320.81
## [367,]  390 14320.81
## [368,]  389 14320.81
## [369,]  387 14320.81
## [370,]  384 14320.81
## [371,]  383 14320.81
## [372,]  382 14320.81
## [373,]  379 14320.81
## [374,]  376 14320.81
## [375,]  374 14320.81
## [376,]  373 14320.81
## [377,]  372 14320.81
## [378,]  370 14320.81
## [379,]  367 14320.81
## [380,]  366 14320.81
## [381,]  355 14320.81
## [382,]  352 14320.81
## [383,]  348 14320.81
## [384,]  347 14320.81
## [385,]  343 14320.81
## [386,]  342 14320.81
## [387,]  337 14320.81
## [388,]  336 14320.81
## [389,]  335 14320.81
## [390,]  334 14320.81
## [391,]  330 14320.81
## [392,]  326 14320.81
## [393,]  324 14320.81
## [394,]  321 14320.81
## [395,]  320 14320.81
## [396,]  316 14320.81
## [397,]  315 14320.81
## [398,]  312 14320.81
## [399,]  311 14320.81
## [400,]  307 14320.81
## [401,]  306 14320.81
## [402,]  304 14320.81
## [403,]  303 14320.81
## [404,]  302 14320.81
## [405,]  301 14320.81
## [406,]  299 14320.81
## [407,]  297 14320.81
## [408,]  296 14320.81
## [409,]  293 14320.81
## [410,]  291 14320.81
## [411,]  290 14320.81
## [412,]  287 14320.81
## [413,]  279 14320.81
## [414,]  277 14320.81
## [415,]  276 14320.81
## [416,]  275 14320.81
## [417,]  262 14320.81
## [418,]  261 14320.81
## [419,]  260 14320.81
## [420,]  259 14320.81
## [421,]  256 14320.81
## [422,]  253 14320.81
## [423,]  252 14320.81
## [424,]  251 14320.81
## [425,]  247 14320.81
## [426,]  245 14320.81
## [427,]  244 14320.81
## [428,]  242 14320.81
## [429,]  241 14320.81
## [430,]  240 14320.81
## [431,]  239 14320.81
## [432,]  236 14320.81
## [433,]  231 14320.81
## [434,]  230 14320.81
## [435,]  229 14320.81
## [436,]  228 14320.81
## [437,]  227 14320.81
## [438,]  226 14320.81
## [439,]  225 14320.81
## [440,]  223 14320.81
## [441,]  221 14320.81
## [442,]  219 14320.81
## [443,]  218 14320.81
## [444,]  217 14320.81
## [445,]  216 14320.81
## [446,]  215 14320.81
## [447,]  211 14320.81
## [448,]  208 14320.81
## [449,]  207 14320.81
## [450,]  201 14320.81
## [451,]  200 14320.81
## [452,]  194 14320.81
## [453,]  193 14320.81
## [454,]  192 14320.81
## [455,]  191 14320.81
## [456,]  190 14320.81
## [457,]  188 14320.81
## [458,]  187 14320.81
## [459,]  186 14320.81
## [460,]  184 14320.81
## [461,]  182 14320.81
## [462,]  181 14320.81
## [463,]  180 14320.81
## [464,]  179 14320.81
## [465,]  178 14320.81
## [466,]  177 14320.81
## [467,]  176 14320.81
## [468,]  173 14320.81
## [469,]  172 14320.81
## [470,]  171 14320.81
## [471,]  169 14320.81
## [472,]  167 14320.81
## [473,]  165 14320.81
## [474,]  161 14320.81
## [475,]  158 14320.81
## [476,]  157 14320.81
## [477,]  156 14320.81
## [478,]  155 14320.81
## [479,]  150 14320.81
## [480,]  149 14320.81
## [481,]  148 14320.81
## [482,]  143 14320.81
## [483,]  142 14320.81
## [484,]  141 14320.81
## [485,]  140 14320.81
## [486,]  138 14320.81
## [487,]  137 14320.81
## [488,]  136 14320.81
## [489,]  135 14320.81
## [490,]  134 14320.81
## [491,]  133 14320.81
## [492,]  131 14320.81
## [493,]  130 14320.81
## [494,]  127 14320.81
## [495,]  126 14320.81
## [496,]  124 14320.81
## [497,]  120 14320.81
## [498,]  119 14320.81
## [499,]  117 14320.81
## [500,]  114 14320.81
## [501,]  113 14320.81
## [502,]  112 14320.81
## [503,]  108 14320.81
## [504,]  106 14320.81
## [505,]  105 14320.81
## [506,]  104 14320.81
## [507,]  103 14320.81
## [508,]   99 14320.81
## [509,]   98 14320.81
## [510,]   97 14320.81
## [511,]   95 14320.81
## [512,]   94 14320.81
## [513,]   92 14320.81
## [514,]   91 14320.81
## [515,]   90 14320.81
## [516,]   89 14320.81
## [517,]   86 14320.81
## [518,]   84 14320.81
## [519,]   81 14320.81
## [520,]   80 14320.81
## [521,]   79 14320.81
## [522,]   77 14320.81
## [523,]   76 14320.81
## [524,]   75 14320.81
## [525,]   74 14320.81
## [526,]   73 14320.81
## [527,]   72 14320.81
## [528,]   71 14320.81
## [529,]   69 14320.81
## [530,]   68 14320.81
## [531,]   67 14320.81
## [532,]   65 14320.81
## [533,]   64 14320.81
## [534,]   60 14320.81
## [535,]   59 14320.81
## [536,]   58 14320.81
## [537,]   57 14320.81
## [538,]   56 14320.81
## [539,]   55 14320.81
## [540,]   54 14320.81
## [541,]   52 14320.81
## [542,]   50 14320.81
## [543,]   49 14320.81
## [544,]   44 14320.81
## [545,]   43 14320.81
## [546,]   41 14320.81
## [547,]   40 14320.81
## [548,]   39 14320.81
## [549,]   38 14320.81
## [550,]   37 14320.81
## [551,]   36 14320.81
## [552,]   35 14320.81
## [553,]   34 14320.81
## [554,]   33 14320.81
## [555,]   32 14320.81
## [556,]   31 14320.81
## [557,]   30 14320.81
## [558,]   29 14320.81
## [559,]   28 14320.81
## [560,]   27 14320.81
## [561,]   26 14320.81
## [562,]   25 14320.81
## [563,]   24 14320.81
## [564,]   23 14320.81
## [565,]   22 14320.81
## [566,]   21 14320.81
## [567,]   20 14320.81
## [568,]   19 14320.81
## [569,]   18 14320.81
## [570,]   17 14320.81
## [571,]   16 14320.81
## [572,]   15 14320.81
## [573,]   14 14320.81
## [574,]   13 14320.81
## [575,]   12 14320.81
## [576,]   11 14320.81
## [577,]   10 14320.81
## [578,]    9 14351.25
## [579,]    7 14405.36
## [580,]    6 14701.31
## [581,]    5 15127.39
## [582,]    4 15455.46
## [583,]    3 16573.06
## [584,]    2 18341.65
## [585,]    1 21196.04
plot(cvTreeQ2$size, cvTreeQ2$dev, type="b")

The lower the deviance, the better. best size is 4 as it saturates at tree node [1011,] 4 19995.12

bestSizeQ2 <- 10
ptreeFitQ2 <- prune.tree(ltreeFitQ2, best = bestSizeQ2)
plot(ptreeFitQ2)
text(ptreeFitQ2, pretty = FALSE)

summary(ptreeFitQ2)
## 
## Classification tree:
## snip.tree(tree = ltreeFitQ2, nodes = c(22L, 85L, 12L, 7L, 20L, 
## 43L, 13L, 84L, 23L, 4L))
## Variables actually used in tree construction:
## [1] "Duration" "PrevDays" "Month"    "Contact" 
## Number of terminal nodes:  10 
## Residual mean deviance:  0.4564 = 13690 / 29990 
## Misclassification error rate: 0.1024 = 3071 / 30000

Obtain Accuracy parameter

The following table compares the optimal model with the full model tree of Subscribed vs all the variables of the Personal Profile and Financial Profile of a person.

Type Model complexity Relevant variables Misclassification error rate
Full Model 7 leaf nodes Duration, PrevDays, Month 0.1024 = 3071 / 30000
Optimal Model 10 leaf nodes Duration, PrevDays, Month, Contact 0.1024 = 3071 / 30000

The optimal model’s Misclassification error rate is the same as the full model. However, the optimal model have more variables and higher complexity(more leaf nodes).

Verify the Misclassification error rate by predicting with MarketingPred data.

predDataQ2op <- predict(ptreeFitQ2, marketDataQ2, type = "class")
summary(predDataQ2op)
##    no   yes 
## 26860  3140
table(marketData$Subscribed, predDataQ2op)
##      predDataQ2op
##          no   yes
##   no  25196  1407
##   yes  1664  1733

(1407+1664) / (26860+3140) = 0.1023666667. The Misclassification error rate is very similar.

Conclusion

Identify the top three important variables in this case.

Duration, PrevDays, Month as given by the full model tree. The optimal tree was not chosen as it has higher complexity and variables even though it had the same Misclassification error rate.

Why are these important? Justify in terms of the Business.

The Duration of last contact is important as a person is more likely to subscribe to a bank if they are constantly informed of the latest deals. Besides that, the constant reminders would entise a potential customer if he have been contemplating about it. The PrevDays: number of days from the last contact during the Previous Campaign is important as well as mentioned above, contant reminders about the latest promotions is important. The Month of the campaign is also important as during certain periods of the year (second half of the year), they receive bonuses from their jobs and have excess capital available for subcribing to the bank.

How would you influence Subscribed using these variables?

The campaign shall target their customers during the 2nd half of the year and ensure that they keep in contact with their customers at least once every 3 months.

Problem 3

Build an optimal tree-based classification model for Subscribed vs all variables, Personal Profile, Financial Profile, Campaign Data, Demographic Info corresponding to a person. Check the relevant accuracy parameters of your model, and use it to predict Subscribed in the assign2_MarketingPred.csv.

Prediction

The same dataset is used for predicting as the previous problem.

str(marketPred)
## 'data.frame':    1000 obs. of  20 variables:
##  $ Age          : int  29 25 37 31 37 49 48 52 35 34 ...
##  $ Job          : Factor w/ 12 levels "admin","blue-collar",..: 3 2 2 10 1 4 2 10 5 5 ...
##  $ Marital      : Factor w/ 4 levels "divorced","married",..: 2 3 2 2 2 2 2 2 2 2 ...
##  $ Education    : Factor w/ 7 levels "basic4y","basic6y",..: 2 3 5 6 6 5 3 5 6 6 ...
##  $ Default      : Factor w/ 2 levels "no","unknown": 1 1 1 1 1 1 1 1 1 1 ...
##  $ Housing      : Factor w/ 3 levels "no","unknown",..: 1 1 1 1 1 3 1 1 3 1 ...
##  $ Loan         : Factor w/ 3 levels "no","unknown",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ Contact      : Factor w/ 2 levels "cellular","telephone": 2 1 2 1 2 2 1 1 1 2 ...
##  $ Month        : Factor w/ 10 levels "apr","aug","dec",..: 7 7 5 2 5 4 7 4 1 7 ...
##  $ Day          : Factor w/ 5 levels "fri","mon","thu",..: 1 1 3 1 2 3 3 1 3 3 ...
##  $ Duration     : int  217 299 11 168 85 645 214 221 584 200 ...
##  $ Campaign     : int  2 3 7 1 8 2 1 2 1 2 ...
##  $ PrevDays     : int  999 999 999 999 999 999 999 999 999 999 ...
##  $ Previous     : int  0 0 0 0 0 0 1 0 0 0 ...
##  $ PrevOutcome  : Factor w/ 3 levels "failure","nonexistent",..: 2 2 2 2 2 2 1 2 2 2 ...
##  $ EmpVarRate   : num  1.1 -1.8 1.4 1.4 1.4 1.4 -1.8 1.4 -1.8 1.1 ...
##  $ ConPriceIndex: num  94 92.9 94.5 93.4 94.5 ...
##  $ ConConfIndex : num  -36.4 -46.2 -41.8 -36.1 -41.8 -42.7 -46.2 -42.7 -47.1 -36.4 ...
##  $ EuriborRate  : num  4.86 1.31 4.96 4.96 4.87 ...
##  $ NumEmp       : num  5191 5099 5228 5228 5228 ...

Building tree-based classificaiton model

Install the tree package if you have not, import tree library. Construct the full model tree: decision tree of Subscribed vs all the variables of the Personal Profile, Financial Profile, Campaign Data, Demographic Info of a person. Display and print the entire tree structure.

# install.packages("tree")
library("tree")
marketDataQ3 <- marketData
treefitQ3 <- tree(Subscribed ~ ., data = marketDataQ3)
plot(treefitQ3)
text(treefitQ3, pretty = FALSE, all = TRUE)

treefitQ3
## node), split, n, deviance, yval, (yprob)
##       * denotes terminal node
## 
##  1) root 30000 21190.0 no ( 0.886767 0.113233 )  
##    2) NumEmp < 5087.65 3618  4979.0 no ( 0.550304 0.449696 )  
##      4) Duration < 163.5 1245  1114.0 no ( 0.835341 0.164659 ) *
##      5) Duration > 163.5 2373  3196.0 yes ( 0.400759 0.599241 )  
##       10) PrevDays < 513 696   633.6 yes ( 0.169540 0.830460 ) *
##       11) PrevDays > 513 1677  2325.0 yes ( 0.496720 0.503280 ) *
##    3) NumEmp > 5087.65 26382 12980.0 no ( 0.932909 0.067091 )  
##      6) Duration < 474.5 22961  4899.0 no ( 0.977745 0.022255 )  
##       12) Month: aug,jul,jun,may,nov 21229  2320.0 no ( 0.990296 0.009704 )  
##         24) Duration < 267.5 17018   706.1 no ( 0.996944 0.003056 ) *
##         25) Duration > 267.5 4211  1321.0 no ( 0.963429 0.036571 ) *
##       13) Month: apr,dec,mar,oct 1732  1612.0 no ( 0.823903 0.176097 ) *
##      7) Duration > 474.5 3421  4501.0 no ( 0.631979 0.368021 )  
##       14) Duration < 644.5 1530  1595.0 no ( 0.784314 0.215686 ) *
##       15) Duration > 644.5 1891  2621.0 no ( 0.508726 0.491274 ) *
summary(treefitQ3)
## 
## Classification tree:
## tree(formula = Subscribed ~ ., data = marketDataQ3)
## Variables actually used in tree construction:
## [1] "NumEmp"   "Duration" "PrevDays" "Month"   
## Number of terminal nodes:  8 
## Residual mean deviance:  0.3977 = 11930 / 29990 
## Misclassification error rate: 0.09753 = 2926 / 30000

Obtain Accuracy parameter

The following table summarizes the full model tree of Subscribed vs all the variables of the Personal Profile, Financial Profile, Campaign Data, Demographic Info of a person.

Type Model complexity Relevant variables Misclassification error rate
Full Model 8 leaf nodes NumEmp, Duration, PrevDays, Month 0.09753 = 2926 / 30000

Verify the Misclassification error rate by predicting with MarketingPred data.

predDataQ3 <- predict(treefitQ3, marketDataQ3, type = "class")
summary(predDataQ3)
##    no   yes 
## 27627  2373
table(marketData$Subscribed, predDataQ3)
##      predDataQ3
##          no   yes
##   no  25652   951
##   yes  1975  1422

(951+1975) / (27627+2373) = 0.09753333333. The Misclassification error rate is very similar.

Optimise tree-based classificaiton model by having it be Cross Validated

Starting with the largest tree

ltreeFitQ3 <- tree(Subscribed ~ ., data = marketDataQ3, 
                 split = "deviance",
                 method = "recursive.partition",
                 control = tree.control(nobs = nrow(marketDataQ3),
                                        mincut = 1,
                                        mindev = 0))
plot(ltreeFitQ3)

This is too large to be useful. Implement 10-fold Cross-Validation

cvTreeQ3 <- cv.tree(ltreeFitQ3, FUN = prune.tree, K = 10) 
cbind(cvTreeQ3$size, cvTreeQ3$dev)
##        [,1]     [,2]
##   [1,] 1284 12119.61
##   [2,] 1283 12119.61
##   [3,] 1281 12119.61
##   [4,] 1280 12119.61
##   [5,] 1274 12119.61
##   [6,] 1270 12119.61
##   [7,] 1269 12119.61
##   [8,] 1266 12119.61
##   [9,] 1264 12119.61
##  [10,] 1263 12119.61
##  [11,] 1262 12119.61
##  [12,] 1257 12119.61
##  [13,] 1251 12119.61
##  [14,] 1250 12119.61
##  [15,] 1249 12119.61
##  [16,] 1248 12119.61
##  [17,] 1246 12119.61
##  [18,] 1245 12119.61
##  [19,] 1243 12119.61
##  [20,] 1240 12119.61
##  [21,] 1239 12119.61
##  [22,] 1236 12119.61
##  [23,] 1233 12119.61
##  [24,] 1232 12119.61
##  [25,] 1230 12119.61
##  [26,] 1228 12119.61
##  [27,] 1224 12119.61
##  [28,] 1223 12119.61
##  [29,] 1221 12119.61
##  [30,] 1219 12119.61
##  [31,] 1214 12119.61
##  [32,] 1213 12119.61
##  [33,] 1209 12119.61
##  [34,] 1199 12119.61
##  [35,] 1195 12119.61
##  [36,] 1194 12119.61
##  [37,] 1193 12119.61
##  [38,] 1192 12119.61
##  [39,] 1190 12119.61
##  [40,] 1188 12119.61
##  [41,] 1187 12119.61
##  [42,] 1186 12119.61
##  [43,] 1182 12119.61
##  [44,] 1181 12119.61
##  [45,] 1179 12119.61
##  [46,] 1178 12119.61
##  [47,] 1175 12119.61
##  [48,] 1173 12119.61
##  [49,] 1172 12119.61
##  [50,] 1170 12119.61
##  [51,] 1160 12119.61
##  [52,] 1159 12119.61
##  [53,] 1151 12119.61
##  [54,] 1149 12119.61
##  [55,] 1146 12119.61
##  [56,] 1143 12119.61
##  [57,] 1140 12119.61
##  [58,] 1139 12119.61
##  [59,] 1137 12119.61
##  [60,] 1133 12119.61
##  [61,] 1130 12119.61
##  [62,] 1129 12119.61
##  [63,] 1128 12119.61
##  [64,] 1123 12119.61
##  [65,] 1119 12119.61
##  [66,] 1117 12119.61
##  [67,] 1114 12119.61
##  [68,] 1112 12119.61
##  [69,] 1110 12119.61
##  [70,] 1106 12119.61
##  [71,] 1102 12119.61
##  [72,] 1101 12119.61
##  [73,] 1098 12119.61
##  [74,] 1097 12119.61
##  [75,] 1096 12119.61
##  [76,] 1095 12119.61
##  [77,] 1094 12119.61
##  [78,] 1087 12119.61
##  [79,] 1080 12119.61
##  [80,] 1078 12119.61
##  [81,] 1077 12119.61
##  [82,] 1075 12119.61
##  [83,] 1072 12119.61
##  [84,] 1071 12119.61
##  [85,] 1070 12119.61
##  [86,] 1066 12119.61
##  [87,] 1065 12119.61
##  [88,] 1058 12119.61
##  [89,] 1056 12119.61
##  [90,] 1055 12119.61
##  [91,] 1053 12119.61
##  [92,] 1051 12119.61
##  [93,] 1049 12119.61
##  [94,] 1047 12119.61
##  [95,] 1046 12119.61
##  [96,] 1044 12119.61
##  [97,] 1042 12119.61
##  [98,] 1041 12119.61
##  [99,] 1040 12119.61
## [100,] 1038 12119.61
## [101,] 1036 12119.61
## [102,] 1034 12119.61
## [103,] 1030 12119.61
## [104,] 1026 12119.61
## [105,] 1024 12119.61
## [106,] 1023 12119.61
## [107,] 1019 12119.61
## [108,] 1018 12119.61
## [109,] 1017 12119.61
## [110,] 1014 12119.61
## [111,] 1013 12119.61
## [112,] 1010 12119.61
## [113,] 1009 12119.61
## [114,] 1008 12119.61
## [115,] 1007 12119.61
## [116,] 1004 12119.61
## [117,]  999 12119.61
## [118,]  998 12119.61
## [119,]  997 12119.61
## [120,]  994 12119.61
## [121,]  991 12119.61
## [122,]  990 12119.61
## [123,]  989 12119.61
## [124,]  982 12119.61
## [125,]  979 12119.61
## [126,]  977 12119.61
## [127,]  976 12119.61
## [128,]  975 12119.61
## [129,]  969 12119.61
## [130,]  966 12119.61
## [131,]  963 12119.61
## [132,]  962 12119.61
## [133,]  959 12119.61
## [134,]  958 12119.61
## [135,]  949 12119.61
## [136,]  944 12119.61
## [137,]  941 12119.61
## [138,]  938 12119.61
## [139,]  935 12119.61
## [140,]  932 12119.61
## [141,]  931 12119.61
## [142,]  929 12119.61
## [143,]  925 12119.61
## [144,]  924 12119.61
## [145,]  922 12119.61
## [146,]  921 12119.61
## [147,]  918 12119.61
## [148,]  913 12119.61
## [149,]  912 12119.61
## [150,]  910 12119.61
## [151,]  909 12119.61
## [152,]  904 12119.61
## [153,]  902 12119.61
## [154,]  898 12119.61
## [155,]  891 12119.61
## [156,]  884 12119.61
## [157,]  883 12119.61
## [158,]  880 12119.61
## [159,]  879 12119.61
## [160,]  872 12119.61
## [161,]  870 12119.61
## [162,]  863 12119.61
## [163,]  860 12119.61
## [164,]  857 12119.61
## [165,]  856 12119.61
## [166,]  854 12119.61
## [167,]  853 12119.61
## [168,]  852 12119.61
## [169,]  847 12119.61
## [170,]  845 12119.61
## [171,]  842 12119.61
## [172,]  840 12119.61
## [173,]  833 12119.61
## [174,]  830 12119.61
## [175,]  829 12119.61
## [176,]  822 12119.61
## [177,]  821 12119.61
## [178,]  820 12119.61
## [179,]  815 12119.61
## [180,]  813 12119.61
## [181,]  811 12119.61
## [182,]  810 12119.61
## [183,]  807 12119.61
## [184,]  805 12119.61
## [185,]  804 12119.61
## [186,]  803 12119.61
## [187,]  802 12119.61
## [188,]  800 12119.61
## [189,]  799 12119.61
## [190,]  795 12119.61
## [191,]  787 12119.61
## [192,]  786 12119.61
## [193,]  784 12119.61
## [194,]  782 12119.61
## [195,]  781 12119.61
## [196,]  779 12119.61
## [197,]  778 12119.61
## [198,]  775 12119.61
## [199,]  772 12119.61
## [200,]  771 12119.61
## [201,]  770 12119.61
## [202,]  767 12119.61
## [203,]  765 12119.61
## [204,]  763 12119.61
## [205,]  762 12119.61
## [206,]  760 12119.61
## [207,]  759 12119.61
## [208,]  758 12119.61
## [209,]  756 12119.61
## [210,]  755 12119.61
## [211,]  753 12119.61
## [212,]  751 12119.61
## [213,]  748 12119.61
## [214,]  746 12119.61
## [215,]  745 12119.61
## [216,]  744 12119.61
## [217,]  743 12119.61
## [218,]  742 12119.61
## [219,]  740 12119.61
## [220,]  731 12119.61
## [221,]  730 12119.61
## [222,]  728 12119.61
## [223,]  725 12119.61
## [224,]  724 12119.61
## [225,]  719 12119.61
## [226,]  718 12119.61
## [227,]  715 12119.61
## [228,]  713 12119.61
## [229,]  712 12119.61
## [230,]  711 12119.61
## [231,]  708 12119.61
## [232,]  706 12119.61
## [233,]  701 12119.61
## [234,]  700 12119.61
## [235,]  698 12119.61
## [236,]  693 12119.61
## [237,]  692 12119.61
## [238,]  683 12119.61
## [239,]  682 12119.61
## [240,]  675 12119.61
## [241,]  674 12119.61
## [242,]  673 12119.61
## [243,]  672 12119.61
## [244,]  671 12119.61
## [245,]  669 12119.61
## [246,]  666 12119.61
## [247,]  664 12119.61
## [248,]  662 12119.61
## [249,]  661 12119.61
## [250,]  660 12119.61
## [251,]  658 12119.61
## [252,]  656 12119.61
## [253,]  654 12119.61
## [254,]  651 12119.61
## [255,]  647 12119.61
## [256,]  645 12119.61
## [257,]  642 12119.61
## [258,]  640 12119.61
## [259,]  639 12119.61
## [260,]  633 12119.61
## [261,]  631 12119.61
## [262,]  629 12119.61
## [263,]  628 12119.61
## [264,]  623 12119.61
## [265,]  614 12119.61
## [266,]  613 12119.61
## [267,]  612 12119.61
## [268,]  610 12119.61
## [269,]  609 12119.61
## [270,]  608 12119.61
## [271,]  596 12119.61
## [272,]  593 12119.61
## [273,]  592 12119.61
## [274,]  588 12119.61
## [275,]  587 12119.61
## [276,]  586 12119.61
## [277,]  585 12119.61
## [278,]  584 12119.61
## [279,]  582 12119.61
## [280,]  581 12119.61
## [281,]  575 12119.61
## [282,]  574 12119.61
## [283,]  573 12119.61
## [284,]  571 12119.61
## [285,]  560 12119.61
## [286,]  558 12119.61
## [287,]  553 12119.61
## [288,]  552 12119.61
## [289,]  551 12119.61
## [290,]  548 12119.61
## [291,]  547 12119.61
## [292,]  546 12119.61
## [293,]  544 12119.61
## [294,]  543 12119.61
## [295,]  537 12119.61
## [296,]  534 12119.61
## [297,]  532 12119.61
## [298,]  530 12119.61
## [299,]  528 12119.61
## [300,]  525 12119.61
## [301,]  520 12119.61
## [302,]  518 12119.61
## [303,]  516 12119.61
## [304,]  514 12119.61
## [305,]  513 12119.61
## [306,]  511 12119.61
## [307,]  510 12119.61
## [308,]  499 12119.61
## [309,]  498 12119.61
## [310,]  496 12119.61
## [311,]  494 12119.61
## [312,]  488 12119.61
## [313,]  486 12119.61
## [314,]  484 12119.61
## [315,]  483 12119.61
## [316,]  480 12119.61
## [317,]  479 12119.61
## [318,]  478 12119.61
## [319,]  469 12119.61
## [320,]  468 12119.61
## [321,]  467 12119.61
## [322,]  465 12119.61
## [323,]  464 12119.61
## [324,]  463 12119.61
## [325,]  453 12119.61
## [326,]  452 12119.61
## [327,]  451 12119.61
## [328,]  446 12119.61
## [329,]  445 12119.61
## [330,]  441 12119.61
## [331,]  438 12119.61
## [332,]  437 12119.61
## [333,]  433 12119.61
## [334,]  423 12119.61
## [335,]  418 12119.61
## [336,]  417 12119.61
## [337,]  414 12119.61
## [338,]  413 12119.61
## [339,]  408 12119.61
## [340,]  407 12119.61
## [341,]  405 12119.61
## [342,]  404 12119.61
## [343,]  400 12119.61
## [344,]  399 12119.61
## [345,]  397 12119.61
## [346,]  396 12119.61
## [347,]  393 12119.61
## [348,]  390 12119.61
## [349,]  388 12119.61
## [350,]  387 12119.61
## [351,]  386 12119.61
## [352,]  384 12119.61
## [353,]  383 12119.61
## [354,]  381 12119.61
## [355,]  380 12119.61
## [356,]  374 12119.61
## [357,]  373 12119.61
## [358,]  371 12119.61
## [359,]  368 12119.61
## [360,]  367 12119.61
## [361,]  366 12119.61
## [362,]  362 12119.61
## [363,]  359 12119.61
## [364,]  356 12119.61
## [365,]  354 12119.61
## [366,]  353 12119.61
## [367,]  350 12119.61
## [368,]  343 12119.61
## [369,]  342 12119.61
## [370,]  341 12119.61
## [371,]  339 12119.61
## [372,]  336 12119.61
## [373,]  335 12119.61
## [374,]  333 12119.61
## [375,]  329 12119.61
## [376,]  328 12119.61
## [377,]  326 12119.61
## [378,]  319 12119.61
## [379,]  318 12119.61
## [380,]  317 12119.61
## [381,]  314 12119.61
## [382,]  312 12119.61
## [383,]  311 12119.61
## [384,]  307 12119.61
## [385,]  301 12119.61
## [386,]  294 12119.61
## [387,]  290 12119.61
## [388,]  286 12119.61
## [389,]  285 12119.61
## [390,]  282 12119.61
## [391,]  281 12119.61
## [392,]  276 12119.61
## [393,]  275 12119.61
## [394,]  274 12119.61
## [395,]  273 12119.61
## [396,]  270 12119.61
## [397,]  269 12119.61
## [398,]  268 12119.61
## [399,]  267 12119.61
## [400,]  266 12119.61
## [401,]  264 12119.61
## [402,]  260 12119.61
## [403,]  259 12119.61
## [404,]  258 12119.61
## [405,]  257 12119.61
## [406,]  252 12119.61
## [407,]  248 12119.61
## [408,]  247 12119.61
## [409,]  246 12119.61
## [410,]  242 12119.61
## [411,]  241 12119.61
## [412,]  236 12119.61
## [413,]  235 12119.61
## [414,]  231 12119.61
## [415,]  230 12119.61
## [416,]  226 12119.61
## [417,]  225 12119.61
## [418,]  224 12119.61
## [419,]  223 12119.61
## [420,]  222 12119.61
## [421,]  220 12119.61
## [422,]  219 12119.61
## [423,]  218 12119.61
## [424,]  215 12119.61
## [425,]  209 12119.61
## [426,]  208 12119.61
## [427,]  205 12119.61
## [428,]  204 12119.61
## [429,]  203 12119.61
## [430,]  202 12119.61
## [431,]  201 12119.61
## [432,]  200 12119.61
## [433,]  199 12119.61
## [434,]  198 12119.61
## [435,]  197 12119.61
## [436,]  194 12119.61
## [437,]  193 12119.61
## [438,]  190 12119.61
## [439,]  189 12119.61
## [440,]  187 12119.61
## [441,]  186 12119.61
## [442,]  185 12119.61
## [443,]  184 12119.61
## [444,]  183 12119.61
## [445,]  182 12119.61
## [446,]  181 12119.61
## [447,]  179 12119.61
## [448,]  178 12119.61
## [449,]  173 12119.61
## [450,]  172 12119.61
## [451,]  171 12119.61
## [452,]  169 12119.61
## [453,]  168 12119.61
## [454,]  165 12119.61
## [455,]  160 12119.61
## [456,]  155 12119.61
## [457,]  154 12119.61
## [458,]  148 12119.61
## [459,]  146 12119.61
## [460,]  144 12119.61
## [461,]  142 12119.61
## [462,]  139 12119.61
## [463,]  136 12119.61
## [464,]  131 12119.61
## [465,]  130 12119.61
## [466,]  129 12119.61
## [467,]  127 12119.61
## [468,]  124 12119.61
## [469,]  123 12119.61
## [470,]  121 12119.61
## [471,]  120 12119.61
## [472,]  118 12119.61
## [473,]  116 12119.61
## [474,]  112 12119.61
## [475,]  106 12119.61
## [476,]  105 12119.61
## [477,]  104 12119.61
## [478,]  100 12119.61
## [479,]   99 12119.61
## [480,]   92 12119.61
## [481,]   89 12119.61
## [482,]   88 12119.61
## [483,]   86 12119.61
## [484,]   85 12119.61
## [485,]   84 12119.61
## [486,]   83 12119.61
## [487,]   82 12119.61
## [488,]   81 12119.61
## [489,]   80 12119.61
## [490,]   79 12119.61
## [491,]   76 12119.61
## [492,]   75 12119.61
## [493,]   74 12119.61
## [494,]   73 12119.61
## [495,]   72 12119.61
## [496,]   71 12119.61
## [497,]   70 12119.61
## [498,]   69 12119.61
## [499,]   67 12119.61
## [500,]   66 12119.61
## [501,]   65 12119.61
## [502,]   64 12119.61
## [503,]   61 12119.61
## [504,]   60 12119.61
## [505,]   58 12119.61
## [506,]   57 12119.61
## [507,]   56 12119.61
## [508,]   55 12119.61
## [509,]   54 12119.61
## [510,]   53 12119.61
## [511,]   52 12119.61
## [512,]   51 12119.61
## [513,]   50 12119.61
## [514,]   49 12119.61
## [515,]   48 12119.61
## [516,]   46 12119.61
## [517,]   44 12119.61
## [518,]   42 12119.61
## [519,]   41 12119.61
## [520,]   40 12119.61
## [521,]   39 12119.61
## [522,]   38 12119.61
## [523,]   37 12119.61
## [524,]   36 12119.61
## [525,]   35 12119.61
## [526,]   34 12119.61
## [527,]   33 12119.61
## [528,]   32 12119.61
## [529,]   31 12119.61
## [530,]   29 12119.61
## [531,]   28 12119.61
## [532,]   27 12119.61
## [533,]   26 12119.61
## [534,]   25 12119.61
## [535,]   24 12119.61
## [536,]   23 12119.61
## [537,]   22 12119.61
## [538,]   21 12119.61
## [539,]   20 12119.61
## [540,]   19 12119.61
## [541,]   18 12119.61
## [542,]   17 12119.61
## [543,]   16 12119.61
## [544,]   15 12119.61
## [545,]   14 12119.61
## [546,]   13 12119.61
## [547,]   12 12119.61
## [548,]   11 12119.61
## [549,]   10 12119.61
## [550,]    9 12119.61
## [551,]    8 12119.61
## [552,]    7 12323.65
## [553,]    6 12805.86
## [554,]    5 12805.86
## [555,]    4 13484.15
## [556,]    3 14436.53
## [557,]    1 21196.40
plot(cvTreeQ3$size, cvTreeQ3$dev, type="b")

The lower the deviance, the better. best size is 8 as it saturates at tree node [551,] 8 12025.64

bestSizeQ3 <- 8
ptreeFitQ3 <- prune.tree(ltreeFitQ3, best = bestSizeQ3)
plot(ptreeFitQ3)
text(ptreeFitQ3, pretty = FALSE)

summary(ptreeFitQ3)
## 
## Classification tree:
## snip.tree(tree = ltreeFitQ3, nodes = c(10L, 14L, 15L, 11L, 24L, 
## 4L, 25L, 13L))
## Variables actually used in tree construction:
## [1] "NumEmp"   "Duration" "PrevDays" "Month"   
## Number of terminal nodes:  8 
## Residual mean deviance:  0.3977 = 11930 / 29990 
## Misclassification error rate: 0.09753 = 2926 / 30000

Obtain Accuracy parameter

The following table compares the optimal model with the full model tree of Subscribed vs all the variables of the Personal Profile, Financial Profile, Campaign Data, Demographic Info of a person.

Type Model complexity Relevant variables Misclassification error rate
Full Model 7 leaf nodes Duration, PrevDays, Month 0.1024 = 3071 / 30000
Optimal Model 8 leaf nodes NumEmp, Duration, PrevDays, Month 0.09753 = 2926 / 30000

Verify the Misclassification error rate by predicting with MarketingPred data.

predDataQ3op <- predict(ptreeFitQ3, marketDataQ3, type = "class")
summary(predDataQ3op)
##    no   yes 
## 27627  2373
table(marketData$Subscribed, predDataQ3op)
##      predDataQ3op
##          no   yes
##   no  25652   951
##   yes  1975  1422

(951+1975) / (27627+2373) = 0.09753333333. The Misclassification error rate is very similar.

Conclusion

Identify the top three important variables in this case.

Duration, PrevDays, Month as given by both the full model tree and the optimal. The NumEmp in optimal tree was not chosen as it it was absent in the full model tree.

Why are these important? Justify in terms of the Business.

The Duration of last contact is important as a person is more likely to subscribe to a bank if they are constantly informed of the latest deals. Besides that, the constant reminders would entise a potential customer if he have been contemplating about it. The PrevDays: number of days from the last contact during the Previous Campaign is important as well as mentioned above, contant reminders about the latest promotions is important. The Month of the campaign is also important as during certain periods of the year (second half of the year), they receive bonuses from their jobs and have excess capital available for subcribing to the bank.

How would you influence Subscribed using these variables?

The campaign shall target their customers during the 2nd half of the year and ensure that they keep in contact with their customers at least once every 163 days.

CONSULTING REPORT

As given in problem 2 and 3, The campaign shall target their customers during the 2nd half of the year and ensure that they keep in contact with their customers at least once every now and then.