当前位置:网站首页>R语言书籍学习03 《深入浅出R语言数据分析》-第八章 逻辑回归模型 第九章 聚类模型
R语言书籍学习03 《深入浅出R语言数据分析》-第八章 逻辑回归模型 第九章 聚类模型
2022-06-11 21:39:00 【深竹清风】
1 逻辑回归模型
1.1 逻辑回归
逻辑回归模型属于广义的线性模型,在数学上,GLM可以表示为


1.2 构建回归模型
使用glm()构建逻辑回归模型,在逻辑回归模型中,使用default特征作为因变量,其他作为自变量。
modle<-glm(default~., data=default_trn,family="binomial")
#family="gaussian"表示调用glm等同于lm
1.3 逻辑回归预测
使用predict()函数进行预测,指定type="response"。
predict(model_glm,type="response")1.4 逻辑回归评估
评估分类模型最常见的事情可能是使用交叉表将实际响应值与预测响应值进行比较,可以使用base中的table()函数生成此矩阵。
trn_tab<-table(predicted=trn_pred, actual= default_trn$default)1.5 总结
逻辑回归模型适用于二分类问题。ROC、KS等方法被用来衡量模型的优劣。
2 聚类模型
2.1 概述
聚类是一种非监督的机器学习模型,用于识别数据中存在的模式。基本思想是计算样本之间的相似性。有K均值聚类、分层聚类、Medoids聚类等方法。
2.2 K均值聚类——确定K值
可以使用Gap统计法、Elbow方法等。详见其他R语言数据分析与挖掘的介绍。
2.3 层次聚类
dist_data<-dist(food[,-1],method="euclidean")
hdata<-hclust(dist_data)
#绘制树形图2.4 Medoids聚类(PAM)
K均值算法使用均值获得中心点,但均值对异常值敏感。这个问题通过PAM解决,PAM在数据中搜索k个代表性对象或中间体。在找到k个代表性对象后,通过将每个观察数据指定到最近的中间体来构建k个簇。
food_pam<-pam(food[,-1],3)

2.5 总结
聚类分析是机器学习中的一种非监督算法,可以用来识别数据中的潜在模式。最常用的是K均值聚类和层次聚类。
边栏推荐
- 每日一题 - 罗马数字转整数
- Educational Codeforces Round 114 (Rated for Div. 2) D
- Flutter series: detailed explanation of container layout commonly used in flutter
- Redis basic data type (set)
- Relatively perfect singleton mode
- zypper命令使用示例
- Refresh and upgrade | innovation, starting from cloud store
- 多态的所有特征
- 2021 Niuke multi school 5 double strings
- 实验10 Bezier曲线生成-实验提高-交互式生成B样条曲线
猜你喜欢

领先企业推进智慧财务的同款效率工具,赶快了解一下?

「大模型」之所短,「知识图谱」之所长

Apache local multi port configuration

快速排序的优化

LeetCode-110-平衡二叉树
![[v2.1] automatic update system based on motion step API (repair bug, increase completion display, support disconnection reconnection and data compensation)](/img/73/2ec957d58616d692e571a70826787f.jpg)
[v2.1] automatic update system based on motion step API (repair bug, increase completion display, support disconnection reconnection and data compensation)

LeetCode-76-最小覆盖子串

实现栈和队列

The same efficiency tool for leading enterprises to promote smart finance. Let's have a quick look?

Add anti debugging function to game or code (application level)
随机推荐
一步步把 SAP UI5 应用部署到 SAP BTP Kyma 运行环境中去
LeetCode-43-字符串相乘
How to create the simplest SAP kyma function
JVM | local method interface; Native Method Stack
Chain storage structure of linear table
多态的所有特征
Refresh and upgrade | innovation, starting from cloud store
Using the sap ui5 cli command line tool to build and run SAP ui5 applications
Look for leap years and see how many leap years I have had since I was born (I have had five)
LaTex实战笔记 3-宏包与控制命令
「大模型」之所短,「知识图谱」之所长
Deploy SAP ui5 applications to the sap BTP kyma operating environment step by step
How to use RPA robot to start the first step of digital transformation of freight forwarding industry?
判断大小端存储两种办法
Redis basic data type (set)
如何使用 SAP Kyma 控制台手动发送 SAP Commerce Cloud Mock 应用暴露的事件
Supplementary questions for the training ground on September 11, 2021
In the post epidemic era, how can enterprise CIOs improve enterprise production efficiency through distance
2022-02-28(1)
Redis basic data type (hash)