Machine Learning Practice, Quiz 2
Consider the following code and its output:
Code:
from sklearn.datasets import load_irisfrom sklearn.linear_model import LogisticRegression
X, y = load_iris(return_X_y=True)clf = LogisticRegression(random_state=0).fit(X, y)
print(y[70:80])print(clf.predict(X[70:80, :]))Output:
[1 1 1 1 1 1 1 1 1 1][2 1 1 1 1 1 1 2 1 1]What will be the output of the following code? Enter your answer correct to one decimal place.
print(clf.score(X[70:80, :], y[70:80]))Consider the following code and its output: Code: from sklearn.datasets import load_iris from sklearn.linear_model import LogisticRegression X, y = load_iris(return_X_y=True) clf = LogisticRegression(random_state=0).fit(X, y) print(y[70:80]) print(clf.predict(X[70:80, :])) Output: [1 1 1 1 1 1 1 1 1 1] [2 1 1 1 1 1 1 2 1 1] What will be the output of the following code? Enter your answer correct to one decimal place. print(clf.score(X[70:80, :], y[70:80])) Figure from the original question paper What will be the output of the following code ? from sklearn.neighbors import KNeighborsClassifier X_train = [[1,100],[4,400],[5,500],[6,600],[8,800],[9,900], [11,1100],[12,1200],[15,1500], [18,1800],[19,1900]] y_train = [0,0,1,1,1,2,2,2,2,2,2] X_test = [[2,200]] knn = KNeighborsClassifier(n_neighbors= len(y_train), metric="euclidean", weights= 'uniform') knn.fit(X_train,y_train) print(knn.predict(X_test))