Question: Subject: Data Analytics Question: Please discuss the results obtained + Code + Text Copy to Drive RAM L Disk Editing A [] from google.colab import

Subject: Data Analytics Question: Please discuss the results obtained + Code +Text Copy to Drive RAM L Disk Editing A [] from google.colabimport drive drive.mount('/content/drive') Drive already mounted at /content/drive; to attempt to forciblyremount, call drive.mount("/content/drive", force_remount=True). #@title import pandas df = pandas.read_csv('/content/costumer.csv') [] fromsklearn import linear_model import numpy as np import matplotlib.pyplot as plt fromSubject: Data Analytics

Question: Please discuss the results obtained

+ Code + Text Copy to Drive RAM L Disk Editing A [] from google.colab import drive drive.mount('/content/drive') Drive already mounted at /content/drive; to attempt to forcibly remount, call drive.mount("/content/drive", force_remount=True). #@title import pandas df = pandas.read_csv('/content/costumer.csv') [] from sklearn import linear_model import numpy as np import matplotlib.pyplot as plt from sklearn.linear_model import Linear regression [ ] df.plot(kind="scatter",x='Avg. Session Length', y='Yearly Amount Spent') x = df['Avg. Session Length'].values.reshape(-1,1) y = df [ 'Yearly Amount Spent').values.reshape (-1,1) reg - Linear regression() reg.fit(x, y) y_pred = reg. predict(x) plt.plot(x, y_pred, color='red', linewidth=2) plt.show() r_59 = reg.score(x, y) print('coefficient of determination:', r_sq) beta=float(reg.intercept_) print('beta :', beta) #For retrieving the slope: alpha=float(reg.coef_) print('alpa:', alpha) # define a function for prediction def pred(x_i: float) -> float: return alpha * x_i + beta + Code + Text A Copy to Drive RAM C Disk Editing [] 700 600 Yearly Amount Spent 500 400 300 30 31 32 34 35 36 Avg. Session Length coefficient of determination: 0.12608769710022838 beta: -438.56274367909253 alpa: 28.374770547430963 [ ] df.plot(kind="scatter",x='Time on App', y='Yearly Amount Spent') x = df [ 'Time on App').values.reshape (-1,1) y = df [ 'Yearly Amount Spent').values.reshape(-1,1) reg = Linear regression() reg.fit(x, y) y_pred = reg.predict(x) plt.plot(x, y_pred, color='red', linewidth=2) plt.show() 700 600 Yearly Amount Spent 500 400 300 9 10 11 12 Time on App 13 14 15 + Code + Text Copy to Drive RAM Disk Editing [] df.plot(kind="scatter",x='Time on Website', y='Yearly Amount Spent') x = df['Time on Website'].values.reshape(-1,1) y = df['Yearly Amount Spent').values.reshape(-1,1) reg - LinearRegression() reg. fit(x, y) y_pred - reg.predict(x) plt.plot(x, y_pred, color='red', linewidth=2) plt.show() 700 600 Yearly Amount Spent 500 400 300 34 40 37 Time on Website [] df.plot(kind="scatter",x='Length of Membership', y='Yearly Amount Spent') x = df ['Length of Membership'].values.reshape(-1,1) y = df['Yearly Amount Spent').values.reshape (-1,1) reg = LinearRegression() reg.fit(x, y) y_pred = reg.predict(x) plt.plot(x, y_pred, color='red', linewidth=2) plt.show() 700 600 Yearly Amount Spent 500 400 300 0 6 7 Length of Membership []df.plot(kind="scatter",x='Length of Membership', 'Time on Website', y='Yearly Amount Spent') x = df[['Length of Membership', 'Time on Website']].values.reshape(-1,1) y = df [ 'Yearly Amount Spent').values.reshape (-1,1) reg = Linear regression() reg. fit(x, y) y_pred = reg.predict(x) plt.plot(x, y_pred, color='red', linewidth=2) plt.show File "", line 1 df.plot(kind="scatter", (x='Length of Membership', 'Time on Website'), y='Yearly Amount Spent') SyntaxError: invalid syntax SEARCH STACK OVERFLOW [] import matplotlib.pyplot as plt import numpy as np y = [('Length of Membership'), ('Time on Website')] x = ['Yearly Amount Spent'] for xe, ye in zip(x, y): plt.scatter(xe, ye) plt.xticks(['Yearly Amount Spent']) plt.axes().set_xticklabels(['Length of Membership', 'Time on Website']) plt. savefig('t.png') In a future version, a new instance will /usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py:11: MatplotlibDeprecationWarning: Adding an axes using the same arguments as a previous axes currently reuses the earlier instance. # This is added back by InteractiveShellApp.init_path() Length of Membership Length of Membership

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!