# $Id: shuttle.R,v 1.2 2007/09/21 13:35:44 kaip Exp $ # # Copyright (c) 2007 Kai Puolamaki # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above # copyright notice and this permission notice appear in all copies. # # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # # # T-61.3050 Machine Learning: Basic Principles # Example for the lecture of 25 September 2007 # # The required shuttle data is in the MASS library library(MASS) help(shuttle) ## shuttle package:MASS R Documentation ## ## Space Shuttle Autolander Problem ## ## Description: ## ## The 'shuttle' data frame has 256 rows and 7 columns. The first six ## columns are categorical variables giving example conditions; the ## seventh is the decision. The first 253 rows are the training set, ## the last 3 the test conditions. ## ## Usage: ## ## shuttle ## ## Format: ## ## This data frame contains the following columns: ## ## 'stability' Stable positioning or not ('stab / xstab') ## ## 'error' Size of error ('MM / SS / LX / XL') ## ## 'sign' Sign of error, positive or negative ('pp / nn') ## ## 'wind' Wind sign ('head / tail') ## ## 'magn' Wind strength ('Light / Medium / Strong / Out of Range') ## ## 'vis' Visibility ('yes / no') ## ## 'use' Use the autolander or not ## ## Source: ## ## D. Michie (1989) Problems of computer-aided concept formation. In ## _Applications of Expert Systems 2_, ed. J. R. Quinlan, Turing ## Institute Press / Addison-Wesley, pp. 310-333. ## ## References: ## ## Venables, W. N. and Ripley, B. D. (2002) _Modern Applied ## Statistics with S._ Fourth edition. Springer. ############################################################################## ############################################################################## # Let's construct a network using Bene at http://b-course.hiit.fi/bene # Reference: Silander T, Myllymaki P (2006) A Simple Optimal Approach # for Finding the Globally Optimal Bayesian Network Structure. In Proc # 22nd Annual Conference on Uncertainty in Artificial Intelligence # (UAI'06). # # We must transform each column such that the factors are from 0 to n: numerize <- function(D) { res <- D for(col in colnames(D)) res[,col] <- as.integer(D[,col])-1 res } shuttleN <- numerize(shuttle) for(row in rownames(shuttleN)) { for(col in colnames(shuttleN)) cat(sprintf("%d ",shuttleN[row,col])) cat("\n") } # Write table for those with no access to R: # write.table(shuttle,file="shuttle.txt") write.table(shuttleN,file="shuttleN.txt",col.names=FALSE,row.names=FALSE) for(i in 1:length(colnames(D3))) cat(sprintf("%d %s\n",i-1,colnames(D3)[i])) # Cut-and-paste the numerical output to http://b-course.hiit.fi/bene # You can then analyze the resulting network.