R分类算法-Logistic回归算法
来源:互联网 发布:减肥软件有哪些 编辑:程序博客网 时间:2024/05/19 01:58
逻辑回归 Logistic Regression
所谓LR,就是一个被Logistic方程归一化后的线性回归,可以将非线性的问题转化为线性问题。
优点:
算法易于实现和部署,执行效率和准确度高
缺点:
离散型的数据需要通过生产虚拟变量的方式来使用。
R API
glm(formula,data)
- formula 建模表达式
- data 训练数据
★glm会自动帮我们把变量离散化,不需要自己设置虚拟变量了。
代码实现:
data <- read.csv("customers.csv")data <- data[data$Gender!='NULL' & data$Marital.Status!='NULL',]data <- data[, colnames(data)!='CustomerID']formula <- Home.Ownership ~ .;total <- nrow(data)index <- sample(1:total, total*0.7)data.train <- data[index, ]data.test <- data[-index, ]data.train.glm = glm( formula = formula, data = data.train, family='binomial')data.test.predict <- predict( data.train.glm, newdata = data.test, type="response")data.test.predict <- ifelse(data.test.predict>0.5, "Rent", "Own")table(data.test$Home.Ownership, data.test.predict)data.test.predict Own Rent Own 537 93 Rent 87 227prop.table(table(data.test$Home.Ownership, data.test.predict), 1) Own Rent Own 0.8523810 0.1476190 Rent 0.2770701 0.7229299
阅读全文
0 0
- R分类算法-Logistic回归算法
- 分类算法:Logistic回归
- 分类算法之logistic 回归模型
- R语言与机器学习学习笔记(分类算法)(6)logistic回归
- R语言与机器学习学习笔记(分类算法)(6)logistic回归
- R语言与机器学习学习笔记(分类算法)(6)logistic回归
- R语言与机器学习学习笔记(分类算法)(6)logistic回归
- 数据挖掘回顾四:分类算法之 logistic回归 算法
- 机器学习算法(分类算法)—Logistic回归
- 【机器学习算法模型】分类算法——logistic回归
- R语言使用逻辑回归分类算法
- Logistic回归算法
- Logistic回归算法实现
- Logistic回归算法
- 逻辑回归算法--Logistic回归
- [学习笔记]分类算法之logistic 回归模型
- 【机器学习】分类算法——Logistic回归
- Logistic Regression 分类算法
- easyui的tree加载数据过滤匹配
- Docker模拟多人协作进行Git操作
- Android 7.0中apn FOTA升级问题解决
- 微信小程序tabBar底部导航栏菜单详细介绍
- Python I/O多路复用
- R分类算法-Logistic回归算法
- XPath、XML
- Producer 性能调优公式及验证
- AndroidStudio 下用ndk 生成so包
- ArrayList1.8 源码
- Concurrency in Scala
- Linux内核分析-3/Linux系统的启动分析
- 如何将项目从github克隆到本地
- Android之侧滑菜单