I can not get this program to work. import numpy as np import pandas as pd # Do not change these options; This allows the CodeGrade auto grading to function correctly pd.set_option('display.max_columns', None) import warnings warnings.filterwarnings('ignore') fileName = "JohnnyPiesData.csv" pie_df = pd.read_csv('JohnnyPiesData.csv') pie_df pie_df =pie_df.drop(['Example'],axis=1); features = pie_df.drop(['Example'], axis =  1); response = pd.get_dummies(pie_df['Example']) pie_df from sklearn.linear_model import LinearRegression from sklearn.metrics import accuracy_score reg_model = LinearRegression() reg_model.fit(features, response) reg_model.coef_ reg_model.intercept_ preds = reg_model.predict (features) preds [preds <= 0.5] = 0 preds[preds > 0.5] = 1 resp_comp = response.copy() reg_outputs = [float(reg_model.predict(np.reshape(row, (1, -1)))) for row in features.itertuples(index=False)] predicted_resp = np.array([1 if reg_output > 0.5 else 0 for reg_output in reg_outputs]) resp_comp = resp_comp.assign(Regression_Predictions = reg_outputs) resp_comp = resp_comp.assign(Predicted_Responses = predicted_resp) resp_comp acc_score = accuracy_score(response, preds)

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

I can not get this program to work.

import numpy as np
import pandas as pd

# Do not change these options; This allows the CodeGrade auto grading to function correctly
pd.set_option('display.max_columns', None)
import warnings
warnings.filterwarnings('ignore')

fileName = "JohnnyPiesData.csv"
pie_df = pd.read_csv('JohnnyPiesData.csv')
pie_df

pie_df =pie_df.drop(['Example'],axis=1);
features = pie_df.drop(['Example'], axis =  1);
response = pd.get_dummies(pie_df['Example'])
pie_df

from sklearn.linear_model import LinearRegression
from sklearn.metrics import accuracy_score
reg_model = LinearRegression()
reg_model.fit(features, response)

reg_model.coef_
reg_model.intercept_

preds = reg_model.predict (features)
preds [preds <= 0.5] = 0
preds[preds > 0.5] = 1

resp_comp = response.copy()
reg_outputs = [float(reg_model.predict(np.reshape(row, (1, -1)))) for row in features.itertuples(index=False)]
predicted_resp = np.array([1 if reg_output > 0.5 else 0 for reg_output in reg_outputs])
resp_comp = resp_comp.assign(Regression_Predictions = reg_outputs)
resp_comp = resp_comp.assign(Predicted_Responses = predicted_resp)
resp_comp

acc_score = accuracy_score(response, preds)

D1
20
21
22
23
24
25
26
27
28
File
5
2
29
30
31
32
33
34
35
36
Insert
X Cut
[Copy ✓
✔Format Painter
Clipboard
Number
Font
G
Alignment
G
Undo
(i) POSSIBLE DATA LOSS Some features might be lost if you save this workbook in the comma-delimited (.csv) format. To preserve these features, save it in an Excel file format.
AutoSave Off 8 JohnnyPiesData ✓
4
Ready
H
Home
Page Layout Formulas Data Review View
✓ A^ A
~A~
Paste
Circle Thick
Triangle Thick
Circle Thin
A
B
с
D
F
G
1 Example Crust Shap Crust Size Crust ShadFilling Size Filling Sha Class
2 ex1
Circle Thick
Thick Dark
pos
3 ex2
Thick Dark
pos
4 ex3
Thick Gray
pos
5 ex4
pos
Gray
White
Dark
White Thin
Dark Thin
White Thin
Gray Thick
White Thick
6 ex5
Dark
White
Dark
pos
7 ex6
pos
8 ex7
White
neg
9 ex8
Gray
neg
10 ex9
Dark
neg
Gray
Dark
Thin
Thick
11 ex10
White
neg
12 ex11
White Thick
Dark
neg
13 ex12
White Thick Gray neg
14
15
16
17
18
19
Square Thick
Circle Thick
Circle Thick
Square Thick
Triangle Thin
Circle Thick
Square Thick
Triangle Thick
JohnnyPies Data
Accessibility: Unavailable
Calibri
Type here to search
B
I
Crust Shade
+
✓11
H✓
U
E
X
O
10
Help
==
= = = B 五
H
C
I
,C
ab Wrap Text
Merge & Center
J
K
Search (Alt+Q)
L
General
$%950000
M
>
N
5
Conditional Format as
Formatting Table
O
Normal
Good
P
Don't show again
Styles
Q
Bad
R
Neutral
Save As...
S
T
T
Insert
U
T
Delete Format
Cells
V
W
Σ. AutoSum
Fill
Clear
X
AY
Sort & Find &
Filter Select
Editing
Gary Neisler
Y
Z
77°F Mostly cloudy
GN
m
Analyze
Data
Analysis
AA
Comments
Sensitivity
Sensitivity
AB
^4x
AC
9:00 AM
9/9/2022
Share
100%
Transcribed Image Text:D1 20 21 22 23 24 25 26 27 28 File 5 2 29 30 31 32 33 34 35 36 Insert X Cut [Copy ✓ ✔Format Painter Clipboard Number Font G Alignment G Undo (i) POSSIBLE DATA LOSS Some features might be lost if you save this workbook in the comma-delimited (.csv) format. To preserve these features, save it in an Excel file format. AutoSave Off 8 JohnnyPiesData ✓ 4 Ready H Home Page Layout Formulas Data Review View ✓ A^ A ~A~ Paste Circle Thick Triangle Thick Circle Thin A B с D F G 1 Example Crust Shap Crust Size Crust ShadFilling Size Filling Sha Class 2 ex1 Circle Thick Thick Dark pos 3 ex2 Thick Dark pos 4 ex3 Thick Gray pos 5 ex4 pos Gray White Dark White Thin Dark Thin White Thin Gray Thick White Thick 6 ex5 Dark White Dark pos 7 ex6 pos 8 ex7 White neg 9 ex8 Gray neg 10 ex9 Dark neg Gray Dark Thin Thick 11 ex10 White neg 12 ex11 White Thick Dark neg 13 ex12 White Thick Gray neg 14 15 16 17 18 19 Square Thick Circle Thick Circle Thick Square Thick Triangle Thin Circle Thick Square Thick Triangle Thick JohnnyPies Data Accessibility: Unavailable Calibri Type here to search B I Crust Shade + ✓11 H✓ U E X O 10 Help == = = = B 五 H C I ,C ab Wrap Text Merge & Center J K Search (Alt+Q) L General $%950000 M > N 5 Conditional Format as Formatting Table O Normal Good P Don't show again Styles Q Bad R Neutral Save As... S T T Insert U T Delete Format Cells V W Σ. AutoSum Fill Clear X AY Sort & Find & Filter Select Editing Gary Neisler Y Z 77°F Mostly cloudy GN m Analyze Data Analysis AA Comments Sensitivity Sensitivity AB ^4x AC 9:00 AM 9/9/2022 Share 100%
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Topological Sort
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education