help me create an R code,

Am very new to R, please help me here. Using the dataset iris.csv , generate a code to build Naive Bayes and Logistic Regression classification models to predict the variety of the flower based on petal and sepal size (length and width).

Hi, welcome!

Homework inspired questions are welcome here, but you have to tell us what have you tried so far? what is your specific problem? We are more inclined towards helping you with specific coding problems rather than doing your work for you.

For guidelines about how to properly ask homework related questions here, please read our homework policy.

many thanks for the info. i appreciate it . Well, yes its homework related, we have tried to generate the code and we got stuck at theus stage:
{r}

Regression model(lr)

lr_model <- glm(Species ~ Sepal.Length + Sepal.Width + Petal.Length + Petal.Width, data = train_data, family = "binomial", maxit = 1000)

predictions on the test dataset

lr_probabilities <- predict(lr_model, test_data, type = "response")
lr_predictions <- ifelse(lr_probabilities > 0.5, "versicolor", "not versicolor")

Display the confusion matrix

confusion_matrix_lr <- table(lr_predictions, test_data$Species)
confusion_matrix_lr

thats a code extract that resulted into an error. "Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred "

So i seek a guide to make sense out of it.

First of all, please bear in mind that generally in R there are warnings and there are errors, and these are different. A warning is just that, its a " you should know something seems off, maybe look into it?" . And an error is an actual concrete "this is wrong and cant be done". You have a warning, you do not have an error (in the R sense)

Secondly it seems to me a very searchable warning message, which i wonder if you googled ? I have googled for you and selected one of the links up top

If you are using common R functions, you will often find that warnings and errors are quite searchable. Thats a good thing :slight_smile:

My advice is to to data exploration to validate your model. Put up some charts to see if its feasible that you would achieve the quality of model claimed given the data.

Does it make sense to do a standard logit when there are three species?

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.