Question
![1. What will be output of this Python code:
import numpy as np
import matplotlib.pyplot as plt
x = np.array([1, 2, 3, 4, 5])
y = np.array([4, 2, 1, 3, 7])
plt.scatter(x, y);
2. What will be output of this Python code for the same data as above,
from sklearn.linear_model import LinearRegression
X = x[:, np.newaxis]
model = LinearRegression().fit(x, y)
yfit=model.predict(X)
plt.scatter(x, y)
plt.plot(x, yfit);](https://content.bartleby.com/qna-images/question/a38b1750-4836-4d47-bfc9-b05e81f0daae/cc12913c-dc1c-4e99-84d0-bde0cf404317/hxcc3ui_thumbnail.png)
Transcribed Image Text:1. What will be output of this Python code:
import numpy as np
import matplotlib.pyplot as plt
x = np.array([1, 2, 3, 4, 5])
y = np.array([4, 2, 1, 3, 7])
plt.scatter(x, y);
2. What will be output of this Python code for the same data as above,
from sklearn.linear_model import LinearRegression
X = x[:, np.newaxis]
model = LinearRegression().fit(x, y)
yfit=model.predict(X)
plt.scatter(x, y)
plt.plot(x, yfit);
![3. What will be output of this Python code
from numpy import nan
X = np.array([[nan, 0, 3 ],
[3,7,9],
[3,5,2],
[4, nan, 6],
[8, 8, 1]])
y = np.array([14, 16, -1, 8, -5])
from sklearn.preprocessing import Imputer
imp = Imputer(strategy='mean')
X2 = imp.fit_transform(X)
X2](https://content.bartleby.com/qna-images/question/a38b1750-4836-4d47-bfc9-b05e81f0daae/cc12913c-dc1c-4e99-84d0-bde0cf404317/fpabvz_thumbnail.png)
Transcribed Image Text:3. What will be output of this Python code
from numpy import nan
X = np.array([[nan, 0, 3 ],
[3,7,9],
[3,5,2],
[4, nan, 6],
[8, 8, 1]])
y = np.array([14, 16, -1, 8, -5])
from sklearn.preprocessing import Imputer
imp = Imputer(strategy='mean')
X2 = imp.fit_transform(X)
X2
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 5 steps with 3 images

Knowledge Booster
Similar questions
- Matlab: How do I convert a matrix into a cell array? When I try to convert for some reason my cellA and cellB sees everything as 1 string but I want something like A = {'File_20210916_5823.tsv', 'File_20210918_5023.tsv'} % Matrices A and B (defined as matrices)A = ['File_20210916_5823.tsv', 'File_20210918_5023.tsv'];B = ['Record_2021_09_16.csv', 'Record_2021_09_18.csv']; % Convert matrices A and B into cell arrays with individual stringscellA = cellstr(A);cellB = cellstr(B);disp(cellA)arrow_forward1. Write a python program that combines two arrays of the same size one-in-a-row. For instance, if a=[1,2,3,4] and b=[5,6,7,8], the combined array should be [1,5,2,6,3,7,4,8].arrow_forward