Question: I can not run my python code. Please give a fix of my code and provide the correct run screenshots: here are my all python

I can not run my python code. Please give a fix of my code and provide the correct run screenshots:

I can not run my python code. Please give a fix ofhere are my all python codes:

import pandas as pd import numpy as np import matplotlib.pyplot as plt from sklearn.model_selection import train_test_split from sklearn.preprocessing import StandardScaler from sklearn.metrics import accuracy_score, confusion_matrix, classification_report from sklearn.linear_model import LogisticRegression from sklearn.tree import DecisionTreeClassifier from sklearn.ensemble import RandomForestClassifier from sklearn.svm import SVC url = 'https://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-red.csv' df = pd.read_csv(url, sep=';') X = df.iloc[:, :-1].values y = df.iloc[:, -1].values X_train, X_test, y_train, y_test = train_test_split(X, y,test_size=0.2, random_state=0) sc = StandardScaler() X_train = sc.fit_transform(X_train) X_test = sc.transform(X_test) lr = LogisticRegression(random_state=0) lr.fit(X_train, y_train) y_pred_lr = lr.predict(X_test)

print('Logistic Regression:') print('Accuracy:', accuracy_score(y_test, y_pred_lr)) print('Confusion Matrix: ', confusion_matrix(y_test, y_pred_lr)) print('Classification Report: ', classification_report(y_test, y_pred_lr)) dt = DecisionTreeClassifier(random_state=0) dt.fit(X_train, y_train) y_pred_dt = dt.predict(X_test)

print('Decision Tree:') print('Accuracy:', accuracy_score(y_test, y_pred_dt)) print('Confusion Matrix: ', confusion_matrix(y_test, y_pred_dt)) print('Classification Report: ', classification_report(y_test, y_pred_dt)) rf = RandomForestClassifier(random_state=0) rf.fit(X_train, y_train) y_pred_rf = rf.predict(X_test)

print('Random Forest:') print('Accuracy:', accuracy_score(y_test, y_pred_rf)) print('Confusion Matrix: ', confusion_matrix(y_test, y_pred_rf)) print('Classification Report: ', classification_report(y_test, y_pred_rf)) svm = SVC(kernel='linear', random_state=0) svm.fit(X_train, y_train) y_pred_svm = svm.predict(X_test)

print('Support Vector Machine:') print('Accuracy:', accuracy_score(y_test, y_pred_svm)) print('Confusion Matrix: ', confusion_matrix(y_test, y_pred_svm)) print('Classification Report: ', classification_report(y_test, y_pred_svm))

please run my python code and give the correct codes again! !!!!

Python Online Compiler main.py Shell Python Online Compiler main.py Shell

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!