//


//

问题到数据

理解问题

  1. 理解客户的问题:谁是客户(某航空公司)?交流,交流,交流!
  2. 问题要具体
  3. 某航空公司: 乘客体验如何?哪方面需要提高?
  4. 类别:比较、描述、聚类,判别还是回归
  5. 需要什么样的数据:现有数据,数据质量,需要收集的数据,自变量,因变量
  6. 哪些方面的满意度?哪些主要竞争对手?
  7. 内部数据?外部数据?

领导不关心的问题都是没有未来的!

设计问卷

  1. 礼貌(Courtesy
  2. 友善(Friendliness
  3. 能够提供需要的帮助(Helpfulness
  4. 食物饮料服务(Service
  5. 购票容易度(Easy_Reservation
  6. 座椅选择(Preferred_Seats
  7. 航班选择(Flight_Options
  8. 票价(Ticket_Prices
  9. 座椅舒适度(Seat_Comfort
  10. 位置前后空间(Seat_Roominess
  11. 随机行李存放(Overhead_Storage
  12. 机舱清洁(Clean_Aircraft
  13. 总体满意度(Satisfaction
  14. 再次选择次航空公司(Fly_Again
  15. 向朋友推荐此航空公司(Recommend

数据到信息

  1. 流程图:数据准备,数据清理,建模和模型评估
  2. 数据预处理:清理、变换、缺失值填补等 (非常重要且耗时)
  3. 建模和评估:
  4. 分析用户感知:特征提取
  5. PCAEFA
  6. 评估标准:此处不是预测类的评估,是市场类人员等是否能够信服

数据

  1. # 载入了相关包,但是此处不对后面相关
  2. library(readr)
  3. library(dplyr)
  4. library(corrplot)
  5. # gplots是可视化包
  6. library(gplots)
  7. # RColorBrewer包用于设计图形的调色盘
  8. # 相关信息见:http://colorbrewer2.org
  9. library(RColorBrewer)
  1. # 可以从网站下载该数据
  2. airline<-read.csv("AirlineRating.csv")
  3. # install.packages('tibble')
  4. library(tibble)
  5. glimpse(airline)
  1. ## Observations: 3,000
  2. ## Variables: 17
  3. ## $ Easy_Reservation <int> 6, 5, 6, 5, 4, 5, 6, 4, 6, 4, 5, 5, 6, 5, 5, ...
  4. ## $ Preferred_Seats <int> 5, 7, 6, 6, 5, 6, 6, 6, 5, 4, 7, 5, 7, 6, 6, ...
  5. ## $ Flight_Options <int> 4, 7, 5, 5, 3, 4, 6, 3, 4, 5, 6, 6, 6, 5, 6, ...
  6. ## $ Ticket_Prices <int> 5, 6, 6, 5, 6, 5, 5, 5, 5, 6, 7, 7, 6, 7, 7, ...
  7. ## $ Seat_Comfort <int> 5, 6, 7, 7, 6, 6, 6, 4, 6, 9, 7, 7, 6, 6, 6, ...
  8. ## $ Seat_Roominess <int> 7, 8, 6, 8, 7, 8, 6, 5, 7, 8, 8, 9, 7, 8, 6, ...
  9. ## $ Overhead_Storage <int> 5, 5, 7, 6, 5, 4, 4, 4, 5, 7, 6, 6, 7, 5, 4, ...
  10. ## $ Clean_Aircraft <int> 7, 6, 7, 7, 7, 7, 6, 4, 6, 7, 7, 7, 7, 7, 6, ...
  11. ## $ Courtesy <int> 5, 6, 6, 4, 2, 5, 5, 4, 5, 6, 4, 6, 4, 5, 5, ...
  12. ## $ Friendliness <int> 4, 6, 6, 6, 3, 4, 5, 5, 4, 5, 6, 7, 5, 4, 4, ...
  13. ## $ Helpfulness <int> 6, 5, 6, 4, 4, 5, 5, 4, 3, 5, 5, 6, 5, 4, 5, ...
  14. ## $ Service <int> 6, 5, 6, 5, 3, 5, 5, 5, 3, 5, 6, 6, 5, 5, 4, ...
  15. ## $ Satisfaction <int> 6, 7, 7, 5, 4, 6, 5, 5, 4, 7, 6, 7, 6, 4, 4, ...
  16. ## $ Fly_Again <int> 6, 6, 6, 7, 4, 5, 3, 4, 7, 6, 8, 6, 5, 4, 6, ...
  17. ## $ Recommend <int> 3, 6, 5, 5, 4, 5, 6, 5, 8, 6, 8, 7, 6, 5, 6, ...
  18. ## $ ID <int> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14...
  19. ## $ Airline <fctr> AirlineCo.1, AirlineCo.1, AirlineCo.1, Airli...

检查相关性

  1. # library(dplyr)
  2. # install.packages('corrplot')
  3. # library(corrplot)
  4. # 我们用`corrplot()`函数检查问卷调查问题的相关性:
  5. # 选取其中的问卷调查项
  6. select(airline,Easy_Reservation:Recommend) %>%
  7. # 得到相关矩阵
  8. cor() %>%
  9. # 用corrplot()绘制相关图
  10. # 选项order="hclust"按照变量的相似度,基于系统聚类的结果对行列进行重新排列
  11. corrplot(,order="hclust")

主成分分析

  1. airline.pc<-select(airline,Easy_Reservation:Recommend) %>%
  2. # prcomp:Principal Components Analysis主成分分析
  3. prcomp()
  4. summary(airline.pc)
  1. ## Importance of components:
  2. ## PC1 PC2 PC3 PC4 PC5 PC6
  3. ## Standard deviation 4.693 4.2836 1.68335 1.03625 0.88896 0.82333
  4. ## Proportion of Variance 0.435 0.3624 0.05596 0.02121 0.01561 0.01339
  5. ## Cumulative Proportion 0.435 0.7974 0.85338 0.87458 0.89019 0.90358
  6. ## PC7 PC8 PC9 PC10 PC11 PC12
  7. ## Standard deviation 0.80349 0.78694 0.77536 0.77020 0.74612 0.71831
  8. ## Proportion of Variance 0.01275 0.01223 0.01187 0.01172 0.01099 0.01019
  9. ## Cumulative Proportion 0.91633 0.92856 0.94043 0.95215 0.96314 0.97333
  10. ## PC13 PC14 PC15
  11. ## Standard deviation 0.69417 0.66650 0.65131
  12. ## Proportion of Variance 0.00952 0.00877 0.00838
  13. ## Cumulative Proportion 0.98285 0.99162 1.00000

主成分分析陡坡图

  1. # 主成分分析陡坡图
  2. plot(airline.pc,type="l",main="PCA陡坡图")

主成分分析双标图

  1. # PCA双标图
  2. biplot(airline.pc,main="PCA双标图",cex=c(0.5,1),xlim=c(-0.06,0.04))

数据聚合

  1. # 我们可以用之前介绍的`dplyr`包中的各种函数,以及使用之前讲到的管道操作`%>%`让代码更易读:
  2. # 选取其中的问卷调查项和航空公司因子信息
  3. # 即删除ID项
  4. airline.mean<-select(airline,-ID)%>%
  5. # 按Airline对数据进行分组总结
  6. group_by(Airline)%>%
  7. # 对每个数值
  8. summarise_each(funs(mean))%>%
  9. # 显示数据
  10. glimpse()
  1. ## Observations: 3
  2. ## Variables: 16
  3. ## $ Airline <fctr> AirlineCo.1, AirlineCo.2, AirlineCo.3
  4. ## $ Easy_Reservation <dbl> 5.031, 2.939, 2.038
  5. ## $ Preferred_Seats <dbl> 6.025, 2.995, 2.019
  6. ## $ Flight_Options <dbl> 4.996, 2.033, 2.067
  7. ## $ Ticket_Prices <dbl> 5.997, 3.016, 2.058
  8. ## $ Seat_Comfort <dbl> 6.988, 5.009, 7.918
  9. ## $ Seat_Roominess <dbl> 7.895, 3.970, 7.908
  10. ## $ Overhead_Storage <dbl> 5.967, 4.974, 7.924
  11. ## $ Clean_Aircraft <dbl> 6.947, 6.050, 7.882
  12. ## $ Courtesy <dbl> 5.016, 7.937, 7.942
  13. ## $ Friendliness <dbl> 4.997, 7.946, 7.914
  14. ## $ Helpfulness <dbl> 5.017, 7.962, 7.954
  15. ## $ Service <dbl> 5.019, 7.956, 7.906
  16. ## $ Satisfaction <dbl> 5.944, 3.011, 7.903
  17. ## $ Fly_Again <dbl> 5.983, 3.008, 7.920
  18. ## $ Recommend <dbl> 6.008, 2.997, 7.929

聚合后PCA结果双标图

  1. # 聚合后PCA结果双标图
  2. airline.mean.pc<-select(airline.mean,Easy_Reservation:Recommend)%>%
  3. prcomp()
  4. biplot(airline.mean.pc,main="聚合后PCA结果双标图",
  5. cex=0.7, expand=2,xlim=c(-0.8, 1),ylim=c(-0.7,0.8))

可视化

  1. # 将航空公司设置成行名称然后将对应的字符列删除
  2. row.names(airline.mean)<-airline.mean$Airline
  1. airline.mean<-select(airline.mean,-Airline)
  2. # 绘制热图
  3. heatmap.2(as.matrix(airline.mean),
  4. col=brewer.pal(9,"YlGn"),trace="none",key=FALSE,dend="none",cexCol=0.6,cexRow =1)
  5. title(main="航空公司问卷调查均值热图")

探索性因子分析(EFA)

  1. 获取抽样调查中问题之间的构造
  2. 结果是一个因子矩阵,其目标是使一小部分变量对应较高的因子载荷,其余的因子载荷都很低
  3. 为什么用因子分析:
  4. 使结果可实践,PCA很难实现
  5. 优化调查项,保留因子载荷高的项
  6. 探索调查项之间的联系是不是符合我们的期待
  1. # 因子分析
  2. library(GPArotation)
  3. airline.fa<-airline%>%
  4. subset(select=Easy_Reservation:Recommend)%>%
  5. factanal(factors=3,rotation="oblimin")

因子载荷热图

  1. Factor 1: 乘客的总体感觉
  2. Factor 2: 机舱服务感知
  3. Factor 3: 购票体验感知
  1. # library(gplots)
  2. # library(RColorBrewer)
  3. # 绘制热图
  4. heatmap.2(airline.fa$loadings,
  5. col=brewer.pal(9,"YlGn"),trace="none",key=FALSE,dend="none",cexCol=0.6,cexRow =1)
  6. title(main="航空公司满意度因子载荷")

平均因子分值热图

  1. Factor 1: 乘客的总体感觉
  2. Factor 2: 机舱服务感知
  3. Factor 3: 购票体验感知
  1. # 因子得分
  2. airline.fa<-airline%>%
  3. subset(select=Easy_Reservation:Recommend)%>%
  4. factanal(factors=3,rotation="oblimin",scores="Bartlett")
  5. airline.fa
  1. ##
  2. ## Call:
  3. ## factanal(x = ., factors = 3, scores = "Bartlett", rotation = "oblimin")
  4. ##
  5. ## Uniquenesses:
  6. ## Easy_Reservation Preferred_Seats Flight_Options Ticket_Prices
  7. ## 0.233 0.157 0.222 0.173
  8. ## Seat_Comfort Seat_Roominess Overhead_Storage Clean_Aircraft
  9. ## 0.251 0.165 0.253 0.495
  10. ## Courtesy Friendliness Helpfulness Service
  11. ## 0.219 0.191 0.153 0.161
  12. ## Satisfaction Fly_Again Recommend
  13. ## 0.151 0.111 0.113
  14. ##
  15. ## Loadings:
  16. ## Factor1 Factor2 Factor3
  17. ## Easy_Reservation 0.941
  18. ## Preferred_Seats 0.880
  19. ## Flight_Options 0.167 0.803
  20. ## Ticket_Prices 0.887
  21. ## Seat_Comfort 0.865
  22. ## Seat_Roominess 0.844 -0.242
  23. ## Overhead_Storage 0.833 0.137 -0.142
  24. ## Clean_Aircraft 0.708
  25. ## Courtesy 0.818
  26. ## Friendliness 0.868
  27. ## Helpfulness 0.953
  28. ## Service 0.922
  29. ## Satisfaction 0.921
  30. ## Fly_Again 0.943
  31. ## Recommend 0.942
  32. ##
  33. ## Factor1 Factor2 Factor3
  34. ## SS loadings 5.316 3.285 3.135
  35. ## Proportion Var 0.354 0.219 0.209
  36. ## Cumulative Var 0.354 0.573 0.782
  37. ##
  38. ## Factor Correlations:
  39. ## Factor1 Factor2 Factor3
  40. ## Factor1 1.0000 -0.0494 0.0188
  41. ## Factor2 -0.0494 1.0000 -0.7535
  42. ## Factor3 0.0188 -0.7535 1.0000
  43. ##
  44. ## Test of the hypothesis that 3 factors are sufficient.
  45. ## The chi square statistic is 769.65 on 63 degrees of freedom.
  46. ## The p-value is 3.9e-122
  1. fa.score<-airline.fa$scores%>%
  2. data.frame()
  3. fa.score$Airline<-airline$Airline
  4. fa.score.mean<-fa.score%>%
  5. group_by(Airline)%>%
  6. summarise(Factor1=mean(Factor1),
  7. Factor2=mean(Factor2),
  8. Factor3=mean(Factor3))
  9. row.names(fa.score.mean)<-as.character(fa.score.mean$Airline)
  10. fa.score.mean<-select(fa.score.mean,-Airline)
  11. heatmap.2(as.matrix(fa.score.mean),
  12. col=brewer.pal(9,"YlGn"),trace="none",key=FALSE,dend="none",cexCol=0.6,cexRow =1)
  13. title(main="航空公司满意度平均因子分值")

得到的信息

  1. 公司在很多方面具有竞争优势,客户满意度总体高于竞争对手
  2. 公司在购票体验上有明显劣势,这是需要努力改进的地方
  3. 我们为什么在购票体验上满意度高的乘客更不满空航服务?是因为乘客本身的特质,或是由于某种原因重视空航服务的公司容易忽视购票体验?
  4. 需要进一步研究购票体验差的原因,以及评估其可能带来的影响:如果购票体验差并不会影响当前总体满意度以及票的销售情况,那我们需要投入多少改进该问题?

信息到行动

  1. 行业知识:
  2. 解释购票体验和空航服务体验的关系
  3. 信息的接收者:哪些人员真正实践这些改进?交流、倾听和尊重
  4. 讲故事的能力

//

//

转自:

http://www.xueqing.tv/course/69

原文作者:

林荟,现任美国杜邦公司商业数据科学家,毕业于爱荷华州立大学,统计学博士,先后担任该校兽医学院统计咨询师及商学院统计咨询师,研究兴趣在预测模型,机器学习,数据可视化,市场营销调查分析,消费者行为分析,自然语义处理和文本挖据,健康与疾病统计分析等方面。

本文链接:

http://www.cnblogs.com/homewch/p/5703091.html

用R进行市场调查和消费者感知分析的更多相关文章

  1. R笔记 单样本t检验 功效分析

    R data analysis examples 功效分析 power analysis for one-sample t-test单样本t检验 例1.一批电灯泡,标准寿命850小时,标准偏差50,4 ...

  2. R语言做文本挖掘 Part5情感分析

    Part5情感分析 这是本系列的最后一篇文章,该.事实上这种单一文本挖掘的每一个部分进行全部值获取水落石出细致的研究,0基础研究阶段.用R里面现成的算法,来实现自己的需求,当然还參考了众多网友的智慧结 ...

  3. R语言学习笔记-Corrplot相关性分析

    示例图像 首先安装需要的包 install.packages("Corrplot") #安装Corrplot install.packages("RColorBrewer ...

  4. sarama的消费者组分析、使用

    以前老的sarama版本不支持消费者组的消费方式,所以大多数人都用sarama-cluster. 后来sarama支持了消费者组的消费方式,sarama-cluster也停止维护了,但网上关于sara ...

  5. 左右手坐标系转换时R和T的具体形式分析

    本文介绍了在计算机视觉的一些应用中,左手坐标系和右手坐标系之间转换时,旋转矩阵R和平移向量T的具体表达形式有哪些变化.

  6. R语言画全基因组关联分析中的曼哈顿图(manhattan plot)

    1.在linux中安装好R 2.准备好画曼哈顿图的R脚本即manhattan.r,manhattan.r内容如下: #!/usr/bin/Rscript #example : Rscript plot ...

  7. R包 randomForest 进行随机森林分析

    randomForest 包提供了利用随机森林算法解决分类和回归问题的功能:我们这里只关注随机森林算法在分类问题中的应用 首先安装这个R包 install.packages("randomF ...

  8. 吴裕雄--天生自然 R语言开发学习:功效分析(续一)

    #----------------------------------------# # R in Action (2nd ed): Chapter 10 # # Power analysis # # ...

  9. 吴裕雄--天生自然 R语言开发学习:功效分析

    #----------------------------------------# # R in Action (2nd ed): Chapter 10 # # Power analysis # # ...

随机推荐

  1. chrome shortcutkey

    按下Shift并点击链接 – 在新窗口打开链接. Ctrl+ – 切换到最后一个标签. Ctrl+Shift+V – 将剪切板中的内容无格式粘贴(举个例子,将你从网页中复制的HTML格式内容粘贴为纯文 ...

  2. 解决eclipse manven项目添加不了maven dependencis

    <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"& ...

  3. NYOJ题目11613n+1问题

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAscAAAIvCAIAAAAXg+GWAAAgAElEQVR4nO3dO1LryNsH4G8T5CyE2A ...

  4. Android Programming: Pushing the Limits -- Chapter 1: Fine-Tuning Your Development Environment

    ADB命令 Application Exerciser Monkey Gradle ProGuard 代码重用 版本控制 静态代码分析 代码重构 开发者模式   ADB命令: @.adb help:查 ...

  5. MVC学习笔记--跟小静学MVC相关语法特性小补习

    http://www.cnblogs.com/janes/archive/2012/10/15/2721101.html http://www.cnblogs.com/h82258652/p/4795 ...

  6. Delphi中函数定义和声明的位置

    当函数(或过程)A定义在函数(或过程)B之前,那么函数B就可以调用函数A,并且编译成功,例如下面的 procedure TForm1.btn1Click(Sender: TObject); 和   f ...

  7. java中常用的工具类(三)

    继续分享java中常用的一些工具类.前两篇的文章中有人评论使用Apache 的lang包和IO包,或者Google的Guava库.后续的我会加上的!谢谢支持IT江湖 一.连接数据库的综合类       ...

  8. Linux LVM全面实践

    1.磁盘分区 [root@ol6-121-rac1 ~]# fdisk /dev/sdb Device contains neither a valid DOS partition table, no ...

  9. web magic 小结

    缘起 写了多年的程序,鲜有产出物,于是最近打算做个不可说的东西来祭奠逝去的青春.数据,是一个程序的起点,我们没有数以亿计的用户,无法让活跃用户给我们产生数据,那就只能去别人的站点上借点数据了.这个功能 ...

  10. PL/SQL Developer 9.x 注册码

    记下来,以备以后使用,好笔头,哈哈哈 Product Code:46jw8l8ymfmp2twwbuur8j9gv978m2q2du serial Number:307254 password:xs3 ...