0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Machine-Learning-with-R-Cookbook-Second-Edition-master:dockerで機械学習(78) with R (8)

Last updated at Posted at 2021-04-27

Machine-Learning-with-R-Cookbook-master
https://github.com/PacktPublishing/Machine-Learning-with-R-Cookbook
Machine-Learning-with-R-Cookbook-Second-Edition-master
https://github.com/PacktPublishing/Machine-Learning-with-R-Cookbook-Second-Edition

Installing 'RPostgreSQL' ...
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/RPostgreSQL_0.6-2.tar.gz'
Content type 'application/x-tar' length 582198 bytes (568 KB)
==================================================
downloaded 568 KB

* installing *source* package ‘RPostgreSQL’ ...
** package ‘RPostgreSQL’ successfully unpacked and MD5 sums checked
** using staged installation
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for pg_config... no
configure: checking for PostgreSQL header files
configure: Checking include /usr/include.
configure: Checking include /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include.
configure: Checking include /usr/include/pgsql.
configure: Checking include /usr/include/postgresql.
configure: Checking include /usr/local/include.
configure: Checking include /usr/local/include/pgsql.
configure: Checking include /usr/local/include/postgresql.
configure: Checking include /usr/local/pgsql/include.
configure: Checking include /usr/local/postgresql/include.
configure: Checking include /opt/include.
configure: Checking include /opt/include/pgsql.
configure: Checking include /opt/include/postgresql.
configure: Checking include /opt/local/include.
configure: Checking include /opt/local/include/postgresql.
configure: Checking include /sw/include/postgresql.
configure: Checking lib /usr/lib.
configure: Checking lib /usr/lib/pgsql.
configure: Checking lib /usr/lib/postgresql.
configure: Checking lib /usr/local/lib.
configure: Checking lib /usr/local/lib/pgsql.
configure: Checking lib /usr/local/lib/postgresql.
configure: Checking lib /usr/local/pgsql/lib.
configure: Checking lib /usr/local/postgresql/lib.
configure: Checking lib /opt/lib.
configure: Checking lib /opt/lib/pgsql.
configure: Checking lib /opt/lib/postgresql.
configure: Checking lib /opt/local/lib.
configure: Checking lib /opt/local/lib/postgresql.
configure: Checking lib /sw/lib.
configure: Using internal package libpq-fe.h
checking for "src/libpq/libpq-fe.h"... yes
configure: creating ./config.status
config.status: creating src/Makevars
** libs
gcc -I"/usr/local/lib/R/include" -DNDEBUG -Isrc/libpq  -I/usr/local/include   -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c RS-DBI.c -o RS-DBI.o
gcc -I"/usr/local/lib/R/include" -DNDEBUG -Isrc/libpq  -I/usr/local/include   -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c RS-PQescape.c -o RS-PQescape.o
In file included from RS-PQescape.c:7:
RS-PostgreSQL.h:23:14: fatal error: libpq-fe.h: No such file or directory
   23 | #    include "libpq-fe.h"
      |              ^~~~~~~~~~~~
compilation terminated.
make: *** [/usr/local/lib/R/etc/Makeconf:172: RS-PQescape.o] Error 1
ERROR: compilation failed for package ‘RPostgreSQL’
* removing ‘/usr/local/lib/R/site-library/RPostgreSQL’

The downloaded source packages are in
	‘/tmp/RtmphvFqYA/downloaded_packages’


✔ Package 'RPostgreSQL' successfully installed.
Warning message:
In utils::install.packages("RPostgreSQL", repos = "https://packagemanager.rstudio.com/all/__linux__/focal/latest") :
  installation of package ‘RPostgreSQL’ had non-zero exit status
> class(x)
[1] "numeric"
** Installing R Packages: 'Amelia', 'corrplot'
[1/3] Installing RcppArmadillo...
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/RcppArmadillo_0.10.4.0.0.tar.gz'
Content type 'binary/octet-stream' length 2250399 bytes (2.1 MB)
==================================================
downloaded 2.1 MB

* installing *binary* package ‘RcppArmadillo’ ...
* DONE (RcppArmadillo)
[2/3] Installing Amelia...

The downloaded source packages are in
	‘/tmp/RtmpMDZZhf/downloaded_packages’
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/Amelia_1.7.6.tar.gz'
Content type 'binary/octet-stream' length 2452068 bytes (2.3 MB)
==================================================
downloaded 2.3 MB

[3/3] Installing corrplot...
* installing *binary* package ‘Amelia’ ...
* DONE (Amelia)

The downloaded source packages are in
	‘/tmp/RtmpMDZZhf/downloaded_packages’
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/corrplot_0.84.tar.gz'
Content type 'binary/octet-stream' length 5447375 bytes (5.2 MB)
==================================================
downloaded 5.2 MB

* installing *binary* package ‘corrplot’ ...
* DONE (corrplot)

The downloaded source packages are in
	‘/tmp/RtmpMDZZhf/downloaded_packages’


✔ Packages successfully installed.
> class(AirPassengers)
[1] "ts"
> data()
> sample(1:10)
 [1] 10  2  4  5  3  8  7  1  9  6
> install.packages("car")
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
also installing the dependencies ‘backports’, ‘evaluate’, ‘highr’, ‘markdown’, ‘xfun’, ‘matrixStats’, ‘broom’, ‘knitr’, ‘SparseM’, ‘MatrixModels’, ‘conquer’, ‘sp’, ‘minqa’, ‘nloptr’, ‘statmod’, ‘carData’, ‘abind’, ‘pbkrtest’, ‘quantreg’, ‘maptools’, ‘lme4’

trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/backports_1.2.1.tar.gz'
Content type 'binary/octet-stream' length 88661 bytes (86 KB)
==================================================
downloaded 86 KB

trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/evaluate_0.14.tar.gz'
Content type 'binary/octet-stream' length 74200 bytes (72 KB)
==================================================
downloaded 72 KB

trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/highr_0.9.tar.gz'
Content type 'binary/octet-stream' length 38825 bytes (37 KB)
==================================================
downloaded 37 KB

trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/markdown_1.1.tar.gz'
Content type 'binary/octet-stream' length 230388 bytes (224 KB)
==================================================
downloaded 224 KB

trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/xfun_0.22.tar.gz'
Content type 'binary/octet-stream' length 310406 bytes (303 KB)
==================================================
downloaded 303 KB

trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/matrixStats_0.58.0.tar.gz'
Content type 'binary/octet-stream' length 2539233 bytes (2.4 MB)
==================================================
downloaded 2.4 MB

trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/broom_0.7.6.tar.gz'
Content type 'binary/octet-stream' length 1748118 bytes (1.7 MB)
==================================================
downloaded 1.7 MB

trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/knitr_1.33.tar.gz'
Content type 'binary/octet-stream' length 1401372 bytes (1.3 MB)
==================================================
downloaded 1.3 MB

trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/SparseM_1.81.tar.gz'
Content type 'binary/octet-stream' length 1099766 bytes (1.0 MB)
==================================================
downloaded 1.0 MB

trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/MatrixModels_0.5-0.tar.gz'
Content type 'binary/octet-stream' length 448997 bytes (438 KB)
==================================================
downloaded 438 KB

trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/conquer_1.0.2.tar.gz'
Content type 'binary/octet-stream' length 1295108 bytes (1.2 MB)
==================================================
downloaded 1.2 MB

trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/sp_1.4-5.tar.gz'
Content type 'binary/octet-stream' length 1855713 bytes (1.8 MB)
==================================================
downloaded 1.8 MB

trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/minqa_1.2.4.tar.gz'
Content type 'binary/octet-stream' length 479131 bytes (467 KB)
==================================================
downloaded 467 KB

trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/nloptr_1.2.2.2.tar.gz'
Content type 'binary/octet-stream' length 1154405 bytes (1.1 MB)
==================================================
downloaded 1.1 MB

trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/statmod_1.4.35.tar.gz'
Content type 'binary/octet-stream' length 270979 bytes (264 KB)
==================================================
downloaded 264 KB

trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/carData_3.0-4.tar.gz'
Content type 'binary/octet-stream' length 1817389 bytes (1.7 MB)
==================================================
downloaded 1.7 MB

trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/abind_1.4-5.tar.gz'
Content type 'binary/octet-stream' length 60511 bytes (59 KB)
==================================================
downloaded 59 KB

trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/pbkrtest_0.5.1.tar.gz'
Content type 'binary/octet-stream' length 351839 bytes (343 KB)
==================================================
downloaded 343 KB

trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/quantreg_5.85.tar.gz'
Content type 'binary/octet-stream' length 1641360 bytes (1.6 MB)
==================================================
downloaded 1.6 MB

trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/maptools_1.1-1.tar.gz'
Content type 'binary/octet-stream' length 2206488 bytes (2.1 MB)
==================================================
downloaded 2.1 MB

trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/lme4_1.1-26.tar.gz'
Content type 'binary/octet-stream' length 9211344 bytes (8.8 MB)
==================================================
downloaded 8.8 MB

trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/car_3.0-10.tar.gz'
Content type 'binary/octet-stream' length 1555669 bytes (1.5 MB)
==================================================
downloaded 1.5 MB

* installing *binary* package ‘backports’ ...
* DONE (backports)
* installing *binary* package ‘evaluate’ ...
* DONE (evaluate)
* installing *binary* package ‘xfun’ ...
* DONE (xfun)
* installing *binary* package ‘matrixStats’ ...
* DONE (matrixStats)
* installing *binary* package ‘SparseM’ ...
* DONE (SparseM)
* installing *binary* package ‘MatrixModels’ ...
* DONE (MatrixModels)
* installing *binary* package ‘sp’ ...
* DONE (sp)
* installing *binary* package ‘minqa’ ...
* DONE (minqa)
* installing *binary* package ‘nloptr’ ...
* DONE (nloptr)
* installing *binary* package ‘statmod’ ...
* DONE (statmod)
* installing *binary* package ‘carData’ ...
* DONE (carData)
* installing *binary* package ‘abind’ ...
* DONE (abind)
* installing *binary* package ‘highr’ ...
* DONE (highr)
* installing *binary* package ‘markdown’ ...
* DONE (markdown)
* installing *binary* package ‘broom’ ...
* DONE (broom)
* installing *binary* package ‘conquer’ ...
* DONE (conquer)
* installing *binary* package ‘maptools’ ...
* DONE (maptools)
* installing *binary* package ‘lme4’ ...
* DONE (lme4)
* installing *binary* package ‘knitr’ ...
* DONE (knitr)
* installing *binary* package ‘quantreg’ ...
* DONE (quantreg)
* installing *binary* package ‘pbkrtest’ ...
* DONE (pbkrtest)
* installing *binary* package ‘car’ ...
* DONE (car)

The downloaded source packages are in
	‘/tmp/RtmpgixwWH/downloaded_packages’
> library(car)
Loading required package: carData

Attaching package: ‘car’

The following object is masked from ‘package:arules’:

    recode
> install.packages("survival")
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/survival_3.2-10.tar.gz'
Content type 'binary/octet-stream' length 6798373 bytes (6.5 MB)
==================================================
downloaded 6.5 MB

* installing *binary* package ‘survival’ ...
* DONE (survival)

The downloaded source packages are in
	‘/tmp/RtmpgixwWH/downloaded_packages’
> install.packages("C50")
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/C50_0.1.3.1.tar.gz'
Content type 'binary/octet-stream' length 604693 bytes (590 KB)
==================================================
downloaded 590 KB

* installing *binary* package ‘C50’ ...
* DONE (C50)

The downloaded source packages are in
	‘/tmp/RtmpgixwWH/downloaded_packages’
> library(C50)
> library(e1071)
> model  =svm(churn~., data = trainset, kernel="radial", cost=1, gamma = 1/ncol(trainset))
Error in eval(expr, p) : object 'trainset' not found
> ind = cut(1:nrow(churnTrain), breaks=10, labels=F)
Error in nrow(churnTrain) : object 'churnTrain' not found
> install.packages("SuperLearner")
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
also installing the dependencies ‘caTools’, ‘gplots’, ‘ROCR’, ‘nnls’, ‘cvAUC’

trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/caTools_1.18.2.tar.gz'
Content type 'binary/octet-stream' length 247686 bytes (241 KB)
==================================================
downloaded 241 KB

trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/gplots_3.1.1.tar.gz'
Content type 'binary/octet-stream' length 595163 bytes (581 KB)
==================================================
downloaded 581 KB

trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/ROCR_1.0-11.tar.gz'
Content type 'binary/octet-stream' length 453521 bytes (442 KB)
==================================================
downloaded 442 KB

trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/nnls_1.4.tar.gz'
Content type 'binary/octet-stream' length 40062 bytes (39 KB)
==================================================
downloaded 39 KB

trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/cvAUC_1.1.0.tar.gz'
Content type 'binary/octet-stream' length 123484 bytes (120 KB)
==================================================
downloaded 120 KB

trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/SuperLearner_2.0-26.tar.gz'
Content type 'binary/octet-stream' length 589292 bytes (575 KB)
==================================================
downloaded 575 KB

* installing *binary* package ‘caTools’ ...
* DONE (caTools)
* installing *binary* package ‘nnls’ ...
* DONE (nnls)
* installing *binary* package ‘gplots’ ...
* DONE (gplots)
* installing *binary* package ‘ROCR’ ...
* DONE (ROCR)
* installing *binary* package ‘cvAUC’ ...
* DONE (cvAUC)
* installing *binary* package ‘SuperLearner’ ...
* DONE (SuperLearner)

The downloaded source packages are in
	‘/tmp/RtmpgixwWH/downloaded_packages’
> install.packages("caret")
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/caret_6.0-86.tar.gz'
Content type 'binary/octet-stream' length 6243866 bytes (6.0 MB)
==================================================
downloaded 6.0 MB

* installing *binary* package ‘caret’ ...
* DONE (caret)

The downloaded source packages are in
	‘/tmp/RtmpgixwWH/downloaded_packages’
> install.packages("glmnet")
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
also installing the dependency ‘shape’

trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/shape_1.4.5.tar.gz'
Content type 'binary/octet-stream' length 784267 bytes (765 KB)
==================================================
downloaded 765 KB

trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/glmnet_4.1-1.tar.gz'
Content type 'binary/octet-stream' length 2000378 bytes (1.9 MB)
==================================================
downloaded 1.9 MB

* installing *binary* package ‘shape’ ...
* DONE (shape)
* installing *binary* package ‘glmnet’ ...
* DONE (glmnet)

The downloaded source packages are in
	‘/tmp/RtmpgixwWH/downloaded_packages’
> install.packages("xgboost")
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/xgboost_1.4.1.1.tar.gz'
Content type 'binary/octet-stream' length 16247624 bytes (15.5 MB)
==================================================
downloaded 15.5 MB

* installing *binary* package ‘xgboost’ ...
* DONE (xgboost)

The downloaded source packages are in
	‘/tmp/RtmpgixwWH/downloaded_packages’
> install.packages("randomForest")
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
trying URL 'https://packagemanager.rstudio.com/all/__linux__/focal/latest/src/contrib/randomForest_4.6-14.tar.gz'
Content type 'binary/octet-stream' length 257439 bytes (251 KB)
==================================================
downloaded 251 KB

* installing *binary* package ‘randomForest’ ...
* DONE (randomForest)

The downloaded source packages are in
	‘/tmp/RtmpgixwWH/downloaded_packages’
> library(SuperLearner)
Loading required package: nnls
Super Learner
Version: 2.0-26
Package created on 2019-10-27

> data(Boston, package="MASS")
> training = sample(nrow(Boston), 100)
> X = Boston[training, ]
> X_Hold = Boston[-training, ]
> Y = Boston$medv[training, ]
Error in Boston$medv[training, ] : incorrect number of dimensions
> Y_Hold = Boston$medv[-training, ]
Error in Boston$medv[-training, ] : incorrect number of dimensions
> customer= read.csv('customer.csv', header=TRUE)
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
  cannot open file 'customer.csv': No such file or directory
> head(customer)
Error in h(simpleError(msg, call)) : 
  error in evaluating the argument 'x' in selecting a method for function 'head': object 'customer' not found
> 
> library(arules)
Loading required package: Matrix

Attaching package: ‘arules’

The following objects are masked from ‘package:base’:

    abbreviate, write

> tr_list = list(c("Apple", "Bread", "Cake"),
+                c("Apple", "Bread", "Milk"),
+                c("Bread", "Cake", "Milk"))
> names(tr_list) = paste("Tr",c(1:3), sep = "")
> trans = as(tr_list, "transactions")
> trans
transactions in sparse format with
 3 transactions (rows) and
 4 items (columns)
> tr_matrix = matrix(
+      c(1,1,1,0,
+      1,1,0,1,
+      0,1,1,1), ncol = 4)
> dimnames(tr_matrix) =  list(
+  paste("Tr",c(1:3), sep = ""),
+    c("Apple","Bread","Cake", "Milk")
+    )
> trans2 =  as(tr_matrix, "transactions")
> trans2
transactions in sparse format with
 3 transactions (rows) and
 4 items (columns)
> Tr_df = data.frame(
+   TrID= as.factor(c(1,2,1,1,2,3,2,3,2,3)),
+   Item = as.factor(c("Apple","Milk","Cake","Bread",
+    "Cake","Milk","Apple","Cake","Bread","Bread")))
> trans3 = as(split(Tr_df[,"Item"], Tr_df[,"TrID"]), "trans-actions")
Error in as(split(Tr_df[, "Item"], Tr_df[, "TrID"]), "trans-actions") : 
  no method or default for coercing “list” to “trans-actions”
> trans3
Error: object 'trans3' not found

一覧の一覧( The directory of directories of mine.) Qiita(100)
https://qiita.com/kaizen_nagoya/items/7eb0e006543886138f39

プログラマが知っていると良い「公序良俗」
https://qiita.com/kaizen_nagoya/items/9fe7c0dfac2fbd77a945

小川清最終講義、小川清最終講義(再)計画, Ethernet(100) 英語(100) 安全(100)
https://qiita.com/kaizen_nagoya/items/e2df642e3951e35e6a53

<この記事は個人の過去の経験に基づく個人の感想です。現在所属する組織、業務とは関係がありません。>

最後までおよみいただきありがとうございました。

いいね 💚、フォローをお願いします。

Thank you very much for reading to the last sentence.

Please press the like icon 💚 and follow me for your happy life.

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?