无法访问Caret中的汽车数据集

发布于 2025-01-24 02:37:19 字数 1442 浏览 0 评论 0原文

我正在通过书[应用预测建模] http://appliedpredictictivemodeling.com

说,

为了说明代码,我们将在Caret软件包中使用CARS数据集的子集。 2005年,收集了804克汽车的凯利蓝书转售数据(Kuiper 2008)。该模型的目的是根据已知特征来预测汽车的价格。该演示将重点介绍一部分车辆的价格,里程和汽车类型(例如轿车):

但是,我无法访问数据集。看来 Caret 软件包中没有2005年的汽车数据集。这是我正在使用的代码:

library(AppliedPredictiveModeling)
library(caret)
cars

这是从R数据集包返回CARS数据集,而不是2005年的Applied预测建模数据集。

接下来我尝试:

AppliedPredictiveModeling::cars

这将返回错误:“错误:'CARS'不是从“命名空间:AppliedPredictiveModeling”中导出的对象“

以类似的方式,代码:

caret::cars

返回错误:“错误:'cars'不是从'namespace:caret'的导出对象:

作者的GitHub Solutions页面。本章的任何内容:用于应用的预测建模的github解决方案

同一数据集似乎在中似乎在中modeldata package,但这似乎也不起作用,这也不是:

library(modeldata)
modeldata::car_prices

返回错误:“错误:'car_prices'不是从'namespace:modeldata'“

以类似方式导出的对象”:

car_prices

返回错误:object'car_prices'car_prices “没有发现

我正在使用以下内容,并随后最新(MacOS,R,Rstudio,软件包):

R版本4.2.0(2022-04-22) - “剧烈的健美操” 版权(C)2022 R统计计算基础 平台:AARCH64-APPLE-DARWIN20(64位)

2005 Kelly Blue Book Resale数据集的804 GM汽车的数据集如何访问?

I'm working through the book [Applied Predictive Modeling] http://appliedpredictivemodeling.com

Starting on page 56, the instructions say,

To illustrate the code, we will take a subset of the cars data set in the caret package. For 2005, Kelly Blue Book resale data for 804 GM cars were collected (Kuiper 2008). The object of the model was to predict the price of the car based on known characteristics. This demonstration will focus on the price, mileage, and car type (e.g., sedan) for a subset of vehicles:

However, I'm not able to access the data set. It appears there is no 2005 cars data set in the caret package. Here is the code I'm using:

library(AppliedPredictiveModeling)
library(caret)
cars

This returns a cars data set from the R datasets package, not the Applied Predictive Modeling data set of cars from 2005.

Next I tried:

AppliedPredictiveModeling::cars

This returns an error: "Error: 'cars' is not an exported object from 'namespace:AppliedPredictiveModeling'"

In a similar manner, the code:

caret::cars

returns the error: "Error: 'cars' is not an exported object from 'namespace:caret'"

The Github solutions page by the authors does not have anything for this chapter: Github solutions for Applied Predictive Modeling

The same dataset appears to be in the modeldata package, but this appears not to work, either:

library(modeldata)
modeldata::car_prices

returns an error: "Error: 'car_prices' is not an exported object from 'namespace:modeldata'"

In a similar manner:

car_prices

return an error: object 'car_prices' not found

I'm using the following, with the following up to date (MacOS, R, RStudio, packages):

R version 4.2.0 (2022-04-22) -- "Vigorous Calisthenics"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: aarch64-apple-darwin20 (64-bit)

How is the data set of 2005 Kelly Blue Book resale data for 804 GM cars accessed?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦罢 2025-01-31 02:37:19

有一个默认的cars数据集。您需要过度阴影。 data函数应加载数据集到工作区中:

 data(cars, package='caret')
str(cars)
#-----------------
'data.frame':   804 obs. of  18 variables:
 $ Price      : num  22661 21725 29143 30732 33359 ...
 $ Mileage    : int  20105 13457 31655 22479 17590 23635 17381 27558 25049 17319 ...
 $ Cylinder   : int  6 6 4 4 4 4 4 4 4 4 ...
 $ Doors      : int  4 2 2 2 2 2 2 2 2 4 ...
 $ Cruise     : int  1 1 1 1 1 1 1 1 1 1 ...
 $ Sound      : int  0 1 1 0 1 0 1 0 0 0 ...
 $ Leather    : int  0 0 1 0 1 0 1 1 0 1 ...
 $ Buick      : int  1 0 0 0 0 0 0 0 0 0 ...
 $ Cadillac   : int  0 0 0 0 0 0 0 0 0 0 ...
 $ Chevy      : int  0 1 0 0 0 0 0 0 0 0 ...
 $ Pontiac    : int  0 0 0 0 0 0 0 0 0 0 ...
 $ Saab       : int  0 0 1 1 1 1 1 1 1 1 ...
 $ Saturn     : int  0 0 0 0 0 0 0 0 0 0 ...
 $ convertible: int  0 0 1 1 1 1 1 1 1 0 ...
 $ coupe      : int  0 1 0 0 0 0 0 0 0 0 ...
 $ hatchback  : int  0 0 0 0 0 0 0 0 0 0 ...
 $ sedan      : int  1 0 0 0 0 0 0 0 0 1 ...
 $ wagon      : int  0 0 0 0 0 0 0 0 0 0 ...

此功能的存在以及df函数的存在就是为什么“数据”也不应该用作数据对象的名称。 R解析器能够直接从句法上下文中保持直接,但是错误消息在出现时会令人困惑。人类可能会感到困惑阅读代码。

There is a default cars dataset. You need to over-shadow it. The data function should load the dataset into the workspace:

 data(cars, package='caret')
str(cars)
#-----------------
'data.frame':   804 obs. of  18 variables:
 $ Price      : num  22661 21725 29143 30732 33359 ...
 $ Mileage    : int  20105 13457 31655 22479 17590 23635 17381 27558 25049 17319 ...
 $ Cylinder   : int  6 6 4 4 4 4 4 4 4 4 ...
 $ Doors      : int  4 2 2 2 2 2 2 2 2 4 ...
 $ Cruise     : int  1 1 1 1 1 1 1 1 1 1 ...
 $ Sound      : int  0 1 1 0 1 0 1 0 0 0 ...
 $ Leather    : int  0 0 1 0 1 0 1 1 0 1 ...
 $ Buick      : int  1 0 0 0 0 0 0 0 0 0 ...
 $ Cadillac   : int  0 0 0 0 0 0 0 0 0 0 ...
 $ Chevy      : int  0 1 0 0 0 0 0 0 0 0 ...
 $ Pontiac    : int  0 0 0 0 0 0 0 0 0 0 ...
 $ Saab       : int  0 0 1 1 1 1 1 1 1 1 ...
 $ Saturn     : int  0 0 0 0 0 0 0 0 0 0 ...
 $ convertible: int  0 0 1 1 1 1 1 1 1 0 ...
 $ coupe      : int  0 1 0 0 0 0 0 0 0 0 ...
 $ hatchback  : int  0 0 0 0 0 0 0 0 0 0 ...
 $ sedan      : int  1 0 0 0 0 0 0 0 0 1 ...
 $ wagon      : int  0 0 0 0 0 0 0 0 0 0 ...

The existence of this function as well as the existence of the df function are why neither "data" nor "df" should be used as names for data objects. The R parser is able to keep then straight from syntactic context, but the error messages are rather confusing when they arise. And humans may be confused reading the code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文