Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

image text in transcribedhere 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2019 Wurzburg Germany September 16 20 2019 Proceedings Part 2 Lnai 11907

Authors: Ulf Brefeld ,Elisa Fromont ,Andreas Hotho ,Arno Knobbe ,Marloes Maathuis ,Celine Robardet

1st Edition

3030461467, 978-3030461461

More Books

Students also viewed these Databases questions

Question

=+Which associations exist?

Answered: 1 week ago