Pular para o conteúdo principal

Questão de TI - Ciência de Dados e Inteligência Artificial — Python (Conceitos Gerais e Códigos) — FCC 2024

TI - Ciência de Dados e Inteligência ArtificialPython (Conceitos Gerais e Códigos)
Código
fc147236
Banca
FCC
Órgão
TRT 20
Ano
2024
Cargo
AJ TRT20

Considere o código em Python abaixo que será executado em condições ideais.

 

from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.neighbors import KNeighborsClassifier
from sklearn.metrics import accuracy_score

 

iris = load_iris()
X = iris.data
y = iris.target
 

 

_I_

   

knn = KNeighborsClassifier(n_neighbors=3)
knn.fit(X_train, y_train)

y_pred = knn.predict(X_test)

accuracy = accuracy_score(y_test, y_pred)

print(f"Acurácia do modelo: {accuracy * 100:.2f}%")

 

Para que o programa divida o conjunto de dados em treino e teste na proporção de 80% treino e 20% teste, a lacuna I deve ser corretamente preenchida por:

  1. AX_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
  2. BX_train, X_test, y_train, y_test = test_train_split(X, y, train_size=0.8, random_state=42)
  3. Cx_train, x_test, y_train, y_test = train test_split(x, y, test_size=0.2, random_state(42))
  4. DY_train, Y_test, x_train, x_test = train test_split(Y, x, train_size=0.8)
  5. Ex_train, x_test, y_train, y_test = test train_split(x, y, train_size=0.8, random_state(0))
Revelar gabarito e comentário

GabaritoA — X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

Link permanente: /questoes/fc147236