当前位置:网站首页>R 语言 UniversalBank.csv“ 数据分析
R 语言 UniversalBank.csv“ 数据分析
2022-06-22 19:17:00 【Mrrunsen】
(10分)以第二次作业中所采用的数据集(航班延误 Flightdelayscsv和贷款接收 Universal Bank. csv中任意选择一个)为例,综合采用多种分类监督学习方法,包括,kNN, glmnet,回归分类树,随机森林等,自行设定训练集(估计最优模型)和测试集(评价模型),比较不同方法的分类精度(或误分类错误率并给出不同模型方法对重要特征变量的选取结果。
set.seed(123)
df = read.csv("UniversalBank.csv",stringsAsFactors = TRUE)
# 去除ID
df = df[,-1]
df$CreditCard <- as.factor(df$CreditCard )
# 划分训练集和测试集
train <- sample(nrow(df), 0.9*nrow(df))
df.train <- df[train,]
df.validate <- df[-train,]
# kNN
library(kknn)
knn <- kknn(CreditCard ~ .,df.train,df.validate)
#在测试集上预测
pre_knn <- fitted(knn)
#输出混淆矩阵
library(caret)
confusionMatrix(df.validate$CreditCard, pre_knn)

基于KNN 模型 的 准确率是 0.698
逻辑回归
log <- glm(CreditCard ~ ., data = df.train, family=binomial())
prob <- predict(log, df.validate, ty边栏推荐
- EasyDSS问题及解决方案汇总
- How to calculate yoy and mom in MySQL
- MySQL Basics - functions
- 三维天地助力实验室夯实完整质量体系管理
- 86-给参加&lt;SQL写法与改写培训&gt;的学员补充一个二手案例
- Introduction to async profiler
- ROS from entry to mastery (VIII) common sensors and message data
- 什么?你居然不会微信分身
- How to realize @ person function in IM instant messaging
- ROS从入门到精通(八) 常用传感器与消息数据
猜你喜欢
mysql8.0忘记密码的详细解决方法

MySQL基础——约束

EasyDSS问题及解决方案汇总

Easydss problem and solution summary
Oracle system/用户被锁定的解决方法

How to consider the arrangement of complete knapsack

AAAI 2022 | traditional Gan can be interpreted after modification, and the interpretability of convolution kernel and the authenticity of generated image are guaranteed

Simple integration of client go gin 11 delete
![[observation] innovation in the software industry has entered a](/img/b8/232ce6bc41a4154f6c9d48b0819d8f.png)
[observation] innovation in the software industry has entered a "new cycle". How can we make a new start in the changing situation?

三维天地助力实验室夯实完整质量体系管理
随机推荐
Summary of 2019: 31 is just another start
An IPFs enabled email - skiff
软件压力测试有哪些方法,如何选择软件压力测试机构?
Three months of self-taught automatic test, salary from 4.5K to 15K, who knows what I have experienced?
【已解决】--go_out: protoc-gen-go: Plugin failed with status code 1.
From perceptron to transformer, a brief history of deep learning
Stochastic Adaptive Dynamics of a Simple Market as a Non-Stationary Multi-Armed Bandit Problem
Using qtest for data set test performance test GUI test
手把手教你IDEA创建SSM项目结构
LORA技术---LoRa信号从数据流变为LoRa扩频信号,再从射频信号通过解调变为数据
80-分页查询,不止写法
Code to Image Converter | 代码生成漂亮图片工具
CVPR 2022 Oral | 视频文本预训练新SOTA,港大、腾讯ARC Lab推出基于多项选择题的借口任务
3个月自学自动化测试,薪资从4.5K到15K,鬼知道我经历了什么?
【奇葩需求之记录对象不同的日志】
[proteus simulation] NE555 delay circuit
Container container runtime (2): which is better for you, yum installation or binary installation?
【深入理解TcaplusDB技术】创建游戏区
Solutions to Oracle system/ user locking
【Proteus仿真】NE555延时电路