after successfully fitting my network, i just seem to not be able to compute the number of parameters.This is what im having:
# Ensure bn_fitted is a bn.fit object
if (inherits(bn_fitted, "bn.fit")) {
# Calculate the number of parameters for each node and the total number of parameters
node_params <- sapply(bn_fitted, nparams)
total_params <- sum(node_params)
# Print the number of parameters for each node and the total number of parameters
print(node_params)
print(total_params)
} else {
stop("bn_fitted is not a bn.fit object")
}
Error in check.bn.or.fit(x) :
x must be an object of class 'bn' or 'bn.fit'.
The node classes are all of them bn.fit.dnode, which is supposed to be recognized by the above nparams.
node_classes <- sapply(bn_fitted, class)
print(node_classes)
Diagnosis radius_mean texture_mean perimeter_mean area_mean
“bn.fit.dnode” “bn.fit.dnode” “bn.fit.dnode” “bn.fit.dnode” “bn.fit.dnode”
don draper is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.