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);

icon
Related questions
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);
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
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
steps

Step by step

Solved in 5 steps with 3 images

Blurred answer