In this example we use VerbaGPT to classify the type of Iris flower from the famous iris dataset1.
Video:
Coming soon…
User question: Give me a model to classify the iris flower. Give me the confusion matrix as a performance metric.
VerbaGPT response:
Cost of query: $0.00
[[50 0 0] [ 0 47 3] [ 0 1 49]]
VerbaGPT answers the question correctly and gives us exactly what we asked for. The diagonal represents correctly classified examples, and the off-diagonal items in the confusion matrix are the errors. Pretty cool!
Check out the full VerbaGPT read-out by click on below.
VerbaGPT Message Window
Here is a code snippet that you can use to classify the iris flower using a logistic regression model and generate a confusion matrix as a performance metric. import pandas as pd from sklearn.linear_model import LogisticRegression from sklearn.metrics import confusion_matrix # Load iris data from the database query = "SELECT * FROM iris" iris_data = pd.read_sql(query, conn) # Split data into features and target X = iris_data.drop('target', axis=1) y = iris_data['target'] # Create and fit logistic regression model model = LogisticRegression() model.fit(X, y) # Generate predictions and confusion matrix y_pred = model.predict(X) confusion = confusion_matrix(y, y_pred) # Print confusion matrix print(confusion)
Leave a Reply