Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 6 :Project the data in the arrays X _ neg and X _ pos to the 2 - dimensional subspace spanned by u 1

Problem 6:Project the data in the arrays X_neg and X_pos to the 2-dimensional subspace spanned by u1 and u2. Save the 2-dimensional datasets as X_neg_2D and X_pos_2D respectively.
Similarly, project the vectors Alice and Bob and save the resulting 2-dimensional vectors as Alice_2D and Bob_2D respectively.
given:
df = pd.read_csv('Lab11data.csv',header=None)
X_neg=df.loc[df[100]==0].drop(columns=100).values.transpose()
X_pos=df.loc[df[100]==1].drop(columns=100).values.transpose()
X_total=df.loc[df[100]>=0].drop(columns=100).values.transpose()
Alice=df.loc[df[100]<0].drop(columns=100).values[0,:]
Bob=df.loc[df[100]<0].drop(columns=100).values[1,:]
my current code:
# Save the projected data points from Problem 6 here.
X_neg=df.loc[df[100]==0].drop(columns=100).values.transpose()
X_pos=df.loc[df[100]==1].drop(columns=100).values.transpose()
Alice=df.loc[df[100]<0].drop(columns=100).values[0,:]
Bob=df.loc[df[100]<0].drop(columns=100).values[1,:]
U = np.vstack((u1, u2)).T
# Projecting X_neg and X_pos to 2D subspace spanned by u1 and u2
X_neg_2D = np.dot(X_neg, U)
X_pos_2D = np.dot(X_pos, U)
# Project the vectors Alice and Bob and save the resulting 2-dimensional vectors as Alice_2D and Bob_2D respectively.
Alice_2D = np.dot(Alice, U)
ValueError Traceback (most recent call last)
in ()
8
9 # Projecting X_neg and X_pos to 2D subspace spanned by u1 and u2
--->10 X_neg_2D = np.dot(X_neg, U)
11 X_pos_2D = np.dot(X_pos, U)
12
ValueError:Comparing the plots of X_neg_2D and X_pos_2D with Alice_2D and Bob_2D make a prediction about the likelihood of Alice or Bob developing this form of cancer.
Problem 7: 1f you think that Alice is liely to develop this form of cancer, enter a value of 1 for the variable Alice_prediction. If you think it is likely she will not develop this form of cancer, save the value of -1 for the variable Alice_prediction. Similarly, assign a value of 1 or -1 for the variable Bob_prediction. shapes (100,980) and (6,2) not aligned: 980(dim 1)!=6(dim 0)

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

Managing Your Information How To Design And Create A Textual Database On Your Microcomputer

Authors: Tenopir, Carol, Lundeen, Gerald

1st Edition

1555700233, 9781555700232

More Books

Students also viewed these Databases questions

Question

What modifier specifies that a variables value is fixed/constant?

Answered: 1 week ago

Question

Weakness and strenght as a democratic leader

Answered: 1 week ago