机器学习与R语言之 探索和理解数据 使用数据usedcars
发布日期:2021-05-12 17:19:38 浏览次数:20 分类:精选文章

本文共 3092 字,大约阅读时间需要 10 分钟。

2.3 ���������������������

���������������������������������������������������������������������R������������������������������������������������������������������������������������������������������������������������������������������������������

���������������

���R���������read.csv()������������������������������������������str()������������������������������������������������������������������������������������������������������������������������������������������������������������������������

## ���������������������������
usedcars <- read.csv("usedcars.csv", stringsAsFactors = FALSE)
str(usedcars)

������������������������������������������������������������������������������������������������������������������������������������������

���������������������

������������������������summary()������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������

���������

## ���������������������
summary(usedcars$year)
summary(usedcars[c("price", "mileage")])

���������������������

  • ���������������������������������������������������������������������������������������
  • ���������������������������������������������������������������������������������������

���������������������

  • ������������������������������������������������������������
  • ���������������IQR������������������������������������Q3 - Q1���������������������������������������������������

���������

## ������������������������������
mean(c(36000, 44000, 56000))
median(c(36000, 44000, 56000))

������������������

���������������������������������������������������������������������������table()���prop.table()���������������������������������������������������������������������������

##���������������������������
table(usedcars$year)
table(usedcars$model)
table(usedcars$color)
## ���������������������
model_table <- table(usedcars$model)
model_pct <- prop.table(model_table)
round(model_pct, digits = 1)
color_table <- table(usedcars$color)
color_pct <- prop.table(color_table) * 100
round(color_pct, digits = 1)

������������������������

���������������������������������������������������������������������������������������������������������������

## ���������������������������������������
plot(x = usedcars$mileage, y = usedcars$price, main = "Scatterplot of Price vs. Mileage",
xlab = "Used Car Odometer (mi.)", ylab = "Used Car Price ($)")

���������������������������������������������������������������������������������������������������������������������

���������������������������������������������������������������������������������������������������������������������������������������������������������������

## ���������������������������������������
boxplot(usedcars$price, main="Boxplot of Used Car Prices", ylab="Price ($)")
boxplot(usedcars$mileage, main="Boxplot of Used Car Mileage", ylab="Odometer (mi.)")
hist(usedcars$price, main="Histogram of Used Car Prices", xlab="Price ($)")
hist(usedcars$mileage, main="Histogram of Used Car Mileage", xlab="Odometer (mi.)")
上一篇:机器学习与R语言 多元线性回归insurance.R:保险费
下一篇:机器学习简介

发表评论

最新留言

留言是一种美德,欢迎回访!
[***.207.175.100]2025年04月07日 21时40分25秒