I want the solution for the picture below please. Write an R function prism(df,
ID: 3860066 • Letter: I
Question
I want the solution for the picture below please.
Write an R function prism(df, decisionAttributelndex) that applies the Prism algorithm to the dataset specified by the dataframe df where decisionAttributelndex is the (1-based) index that corresponds to the decision attribute in the dataframe df. The function should output the rules that are found. Show that your function works by running it on the two datasets given below: a b c df color1 color2 a b c d f color1 color2 DeCISIOn attribute IS (1.e., attribute number 5) Output should be: If b = L then f=0 If c = 1 then f = 1 (instead of c = 1, could be a = 0) If a = 1 then f= 2 (instead of a = 1, could be b = R, c = 0, or d = L) If a = 2 then f = 3 (instead of a = 2, could be b = S, c = 2, or d = H) Note: Your output doesn't have to list all the alternatives for conditions in a rule, we're just showing them so you can check for alternate answersExplanation / Answer
There is no need to create an object , you can just design a list like this:
y = list(cluster = matlabObj$cluster ,
centers = matlabObj$centers ,
withins = matlabObj$withins,
size = matlabObj$size)
Here an example using cclust(you should use your matlab cluster here) to show that the 4 variables are enough to use clustIndex function:
x<- rbind(matrix(rnorm(100,sd=0.3),ncol=2),
matrix(rnorm(100,mean=1,sd=0.3),ncol=2))
matlabObj <- cclust(x,2,20,verbose=TRUE,method="kmeans")
clustIndex(matlabObj,x, index="all")
y = list(cluster = matlabObj$cluster ,
centers = matlabObj$centers ,
withins = matlabObj$withins,
size = matlabObj$size)
identical(clustIndex(y,x, index="all"),
clustIndex(matlabObj,x, index="all"))
[1] TRUE
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.