Error in root.matrix(crossprod(process)) : matrix is not positive semidefinite
I want to extend the RandomForest so that each leaf will contain naivebayes regression instead of average. In the following, I first tried to use mob() for adding linearModel. I got the following error:
Error in root.matrix(crossprod(process)) : matrix is not positive semidefinite
Here is my code:
require (data.table)
require (party)
set.seed(123)
data1 <- read.csv('https://archive.ics.uci.edu/ml/machine-learning-databases/car/car.data',header = TRUE)
colnames(data1)<- c("BuyingPrice","Maintenance","NumDoors","NumPersons","BootSpace","Safety","Condition")
# Split into Train and Validation sets
# Training Set : Validation Set = 70 : 30 (random)
set.seed(100)
train <- sample(nrow(data1), 0.7*nrow(data1), replace = FALSE)
TrainSet <- data1[train,]
ValidSet <- data1[-train,]
summary(TrainSet)
summary(ValidSet)
# Create a Random Forest model with default parameters
model1 <- randomForest(Condition ~ ., data = TrainSet, importance = TRUE)
model1
# Fine tuning parameters of Random Forest model
model2 <- randomForest(Condition ~ ., data = TrainSet, ntree = 500, mtry = 6, importance = TRUE)
model2
fmBH <- mob(Condition ~ BuyingPrice + Maintenance | NumDoors+ NumPersons + BootSpace + Safety ,
data = TrainSet, model = linearModel)
r random-forest naivebayes
|
show 1 more comment
I want to extend the RandomForest so that each leaf will contain naivebayes regression instead of average. In the following, I first tried to use mob() for adding linearModel. I got the following error:
Error in root.matrix(crossprod(process)) : matrix is not positive semidefinite
Here is my code:
require (data.table)
require (party)
set.seed(123)
data1 <- read.csv('https://archive.ics.uci.edu/ml/machine-learning-databases/car/car.data',header = TRUE)
colnames(data1)<- c("BuyingPrice","Maintenance","NumDoors","NumPersons","BootSpace","Safety","Condition")
# Split into Train and Validation sets
# Training Set : Validation Set = 70 : 30 (random)
set.seed(100)
train <- sample(nrow(data1), 0.7*nrow(data1), replace = FALSE)
TrainSet <- data1[train,]
ValidSet <- data1[-train,]
summary(TrainSet)
summary(ValidSet)
# Create a Random Forest model with default parameters
model1 <- randomForest(Condition ~ ., data = TrainSet, importance = TRUE)
model1
# Fine tuning parameters of Random Forest model
model2 <- randomForest(Condition ~ ., data = TrainSet, ntree = 500, mtry = 6, importance = TRUE)
model2
fmBH <- mob(Condition ~ BuyingPrice + Maintenance | NumDoors+ NumPersons + BootSpace + Safety ,
data = TrainSet, model = linearModel)
r random-forest naivebayes
I see no question marks... Also, your code doesn't really contain anything related to Naive Bayes. So, be sure to make it clear whether you care about understanding the error (as the title suggests) or something related to Naive Bayes.
– Julius Vainora
Nov 18 '18 at 13:50
Thanks, @Julius Vainora, I asked how to change the model = linearModel to naivebayes and on the way I got error for linear model.
– Avi
Nov 18 '18 at 13:57
Hi @Avi, I think you have to adapt the model to your problem. Your target variable is a factor, so you have no regression problem, it is either a classification problem. And I don't know if mob is working with multiclassification-problem. See for more details:vignette("MOB")I tried the following and your initial problem is kind of solved:fmBH <- mob(TrainSet$Condition ~ BuyingPrice + Maintenance | NumDoors+ NumPersons + BootSpace + Safety , data = TrainSet, model = glinearModel, family = binomial())
– floe
Nov 18 '18 at 14:05
@Avi, I suggest to make it clear in your question. The error comes from the fact thatConditionis a factor and you are fitting a linear model. As to use Naive Bayes, you need to create this model type, seemodelin?mob.
– Julius Vainora
Nov 18 '18 at 14:06
Thanks both. @floe - I tried your solution it works with 26 warnings I don't know why... I would like to know how can I change the model to naivebayes instead of glinearModel when the target value is not factor?
– Avi
Nov 18 '18 at 14:14
|
show 1 more comment
I want to extend the RandomForest so that each leaf will contain naivebayes regression instead of average. In the following, I first tried to use mob() for adding linearModel. I got the following error:
Error in root.matrix(crossprod(process)) : matrix is not positive semidefinite
Here is my code:
require (data.table)
require (party)
set.seed(123)
data1 <- read.csv('https://archive.ics.uci.edu/ml/machine-learning-databases/car/car.data',header = TRUE)
colnames(data1)<- c("BuyingPrice","Maintenance","NumDoors","NumPersons","BootSpace","Safety","Condition")
# Split into Train and Validation sets
# Training Set : Validation Set = 70 : 30 (random)
set.seed(100)
train <- sample(nrow(data1), 0.7*nrow(data1), replace = FALSE)
TrainSet <- data1[train,]
ValidSet <- data1[-train,]
summary(TrainSet)
summary(ValidSet)
# Create a Random Forest model with default parameters
model1 <- randomForest(Condition ~ ., data = TrainSet, importance = TRUE)
model1
# Fine tuning parameters of Random Forest model
model2 <- randomForest(Condition ~ ., data = TrainSet, ntree = 500, mtry = 6, importance = TRUE)
model2
fmBH <- mob(Condition ~ BuyingPrice + Maintenance | NumDoors+ NumPersons + BootSpace + Safety ,
data = TrainSet, model = linearModel)
r random-forest naivebayes
I want to extend the RandomForest so that each leaf will contain naivebayes regression instead of average. In the following, I first tried to use mob() for adding linearModel. I got the following error:
Error in root.matrix(crossprod(process)) : matrix is not positive semidefinite
Here is my code:
require (data.table)
require (party)
set.seed(123)
data1 <- read.csv('https://archive.ics.uci.edu/ml/machine-learning-databases/car/car.data',header = TRUE)
colnames(data1)<- c("BuyingPrice","Maintenance","NumDoors","NumPersons","BootSpace","Safety","Condition")
# Split into Train and Validation sets
# Training Set : Validation Set = 70 : 30 (random)
set.seed(100)
train <- sample(nrow(data1), 0.7*nrow(data1), replace = FALSE)
TrainSet <- data1[train,]
ValidSet <- data1[-train,]
summary(TrainSet)
summary(ValidSet)
# Create a Random Forest model with default parameters
model1 <- randomForest(Condition ~ ., data = TrainSet, importance = TRUE)
model1
# Fine tuning parameters of Random Forest model
model2 <- randomForest(Condition ~ ., data = TrainSet, ntree = 500, mtry = 6, importance = TRUE)
model2
fmBH <- mob(Condition ~ BuyingPrice + Maintenance | NumDoors+ NumPersons + BootSpace + Safety ,
data = TrainSet, model = linearModel)
r random-forest naivebayes
r random-forest naivebayes
asked Nov 18 '18 at 13:34
AviAvi
1,0161630
1,0161630
I see no question marks... Also, your code doesn't really contain anything related to Naive Bayes. So, be sure to make it clear whether you care about understanding the error (as the title suggests) or something related to Naive Bayes.
– Julius Vainora
Nov 18 '18 at 13:50
Thanks, @Julius Vainora, I asked how to change the model = linearModel to naivebayes and on the way I got error for linear model.
– Avi
Nov 18 '18 at 13:57
Hi @Avi, I think you have to adapt the model to your problem. Your target variable is a factor, so you have no regression problem, it is either a classification problem. And I don't know if mob is working with multiclassification-problem. See for more details:vignette("MOB")I tried the following and your initial problem is kind of solved:fmBH <- mob(TrainSet$Condition ~ BuyingPrice + Maintenance | NumDoors+ NumPersons + BootSpace + Safety , data = TrainSet, model = glinearModel, family = binomial())
– floe
Nov 18 '18 at 14:05
@Avi, I suggest to make it clear in your question. The error comes from the fact thatConditionis a factor and you are fitting a linear model. As to use Naive Bayes, you need to create this model type, seemodelin?mob.
– Julius Vainora
Nov 18 '18 at 14:06
Thanks both. @floe - I tried your solution it works with 26 warnings I don't know why... I would like to know how can I change the model to naivebayes instead of glinearModel when the target value is not factor?
– Avi
Nov 18 '18 at 14:14
|
show 1 more comment
I see no question marks... Also, your code doesn't really contain anything related to Naive Bayes. So, be sure to make it clear whether you care about understanding the error (as the title suggests) or something related to Naive Bayes.
– Julius Vainora
Nov 18 '18 at 13:50
Thanks, @Julius Vainora, I asked how to change the model = linearModel to naivebayes and on the way I got error for linear model.
– Avi
Nov 18 '18 at 13:57
Hi @Avi, I think you have to adapt the model to your problem. Your target variable is a factor, so you have no regression problem, it is either a classification problem. And I don't know if mob is working with multiclassification-problem. See for more details:vignette("MOB")I tried the following and your initial problem is kind of solved:fmBH <- mob(TrainSet$Condition ~ BuyingPrice + Maintenance | NumDoors+ NumPersons + BootSpace + Safety , data = TrainSet, model = glinearModel, family = binomial())
– floe
Nov 18 '18 at 14:05
@Avi, I suggest to make it clear in your question. The error comes from the fact thatConditionis a factor and you are fitting a linear model. As to use Naive Bayes, you need to create this model type, seemodelin?mob.
– Julius Vainora
Nov 18 '18 at 14:06
Thanks both. @floe - I tried your solution it works with 26 warnings I don't know why... I would like to know how can I change the model to naivebayes instead of glinearModel when the target value is not factor?
– Avi
Nov 18 '18 at 14:14
I see no question marks... Also, your code doesn't really contain anything related to Naive Bayes. So, be sure to make it clear whether you care about understanding the error (as the title suggests) or something related to Naive Bayes.
– Julius Vainora
Nov 18 '18 at 13:50
I see no question marks... Also, your code doesn't really contain anything related to Naive Bayes. So, be sure to make it clear whether you care about understanding the error (as the title suggests) or something related to Naive Bayes.
– Julius Vainora
Nov 18 '18 at 13:50
Thanks, @Julius Vainora, I asked how to change the model = linearModel to naivebayes and on the way I got error for linear model.
– Avi
Nov 18 '18 at 13:57
Thanks, @Julius Vainora, I asked how to change the model = linearModel to naivebayes and on the way I got error for linear model.
– Avi
Nov 18 '18 at 13:57
Hi @Avi, I think you have to adapt the model to your problem. Your target variable is a factor, so you have no regression problem, it is either a classification problem. And I don't know if mob is working with multiclassification-problem. See for more details:
vignette("MOB") I tried the following and your initial problem is kind of solved: fmBH <- mob(TrainSet$Condition ~ BuyingPrice + Maintenance | NumDoors+ NumPersons + BootSpace + Safety , data = TrainSet, model = glinearModel, family = binomial())– floe
Nov 18 '18 at 14:05
Hi @Avi, I think you have to adapt the model to your problem. Your target variable is a factor, so you have no regression problem, it is either a classification problem. And I don't know if mob is working with multiclassification-problem. See for more details:
vignette("MOB") I tried the following and your initial problem is kind of solved: fmBH <- mob(TrainSet$Condition ~ BuyingPrice + Maintenance | NumDoors+ NumPersons + BootSpace + Safety , data = TrainSet, model = glinearModel, family = binomial())– floe
Nov 18 '18 at 14:05
@Avi, I suggest to make it clear in your question. The error comes from the fact that
Condition is a factor and you are fitting a linear model. As to use Naive Bayes, you need to create this model type, see model in ?mob.– Julius Vainora
Nov 18 '18 at 14:06
@Avi, I suggest to make it clear in your question. The error comes from the fact that
Condition is a factor and you are fitting a linear model. As to use Naive Bayes, you need to create this model type, see model in ?mob.– Julius Vainora
Nov 18 '18 at 14:06
Thanks both. @floe - I tried your solution it works with 26 warnings I don't know why... I would like to know how can I change the model to naivebayes instead of glinearModel when the target value is not factor?
– Avi
Nov 18 '18 at 14:14
Thanks both. @floe - I tried your solution it works with 26 warnings I don't know why... I would like to know how can I change the model to naivebayes instead of glinearModel when the target value is not factor?
– Avi
Nov 18 '18 at 14:14
|
show 1 more comment
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53361437%2ferror-in-root-matrixcrossprodprocess-matrix-is-not-positive-semidefinite%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53361437%2ferror-in-root-matrixcrossprodprocess-matrix-is-not-positive-semidefinite%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I see no question marks... Also, your code doesn't really contain anything related to Naive Bayes. So, be sure to make it clear whether you care about understanding the error (as the title suggests) or something related to Naive Bayes.
– Julius Vainora
Nov 18 '18 at 13:50
Thanks, @Julius Vainora, I asked how to change the model = linearModel to naivebayes and on the way I got error for linear model.
– Avi
Nov 18 '18 at 13:57
Hi @Avi, I think you have to adapt the model to your problem. Your target variable is a factor, so you have no regression problem, it is either a classification problem. And I don't know if mob is working with multiclassification-problem. See for more details:
vignette("MOB")I tried the following and your initial problem is kind of solved:fmBH <- mob(TrainSet$Condition ~ BuyingPrice + Maintenance | NumDoors+ NumPersons + BootSpace + Safety , data = TrainSet, model = glinearModel, family = binomial())– floe
Nov 18 '18 at 14:05
@Avi, I suggest to make it clear in your question. The error comes from the fact that
Conditionis a factor and you are fitting a linear model. As to use Naive Bayes, you need to create this model type, seemodelin?mob.– Julius Vainora
Nov 18 '18 at 14:06
Thanks both. @floe - I tried your solution it works with 26 warnings I don't know why... I would like to know how can I change the model to naivebayes instead of glinearModel when the target value is not factor?
– Avi
Nov 18 '18 at 14:14