0
0
MLOpsdevops~10 mins

Training data pipeline automation in MLOps - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to read a CSV file into a DataFrame using pandas.

MLOps
import pandas as pd
data = pd.read_csv([1])
Drag options to blanks, or click blank then click option'
Adata.csv
B'data.csv'
Cread.csv
Dcsv.read
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the filename
Using incorrect function names
2fill in blank
medium

Complete the code to split data into training and testing sets using scikit-learn.

MLOps
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=[1], random_state=42)
Drag options to blanks, or click blank then click option'
A0.2
B0.5
C2
D20
Attempts:
3 left
💡 Hint
Common Mistakes
Using integers instead of decimals
Setting test_size too large
3fill in blank
hard

Fix the error in the code to automate data scaling with StandardScaler.

MLOps
from sklearn.preprocessing import StandardScaler
scaler = StandardScaler()
X_scaled = scaler.[1](X_train)
Drag options to blanks, or click blank then click option'
Ascale
Btransform
Cfit
Dfit_transform
Attempts:
3 left
💡 Hint
Common Mistakes
Using transform without fitting first
Using fit without transforming
4fill in blank
hard

Fill both blanks to create a pipeline that scales data and fits a logistic regression model.

MLOps
from sklearn.pipeline import Pipeline
from sklearn.linear_model import LogisticRegression
pipeline = Pipeline([('scaler', [1]()), ('model', [2]())])
Drag options to blanks, or click blank then click option'
AStandardScaler
BMinMaxScaler
CLogisticRegression
DRandomForestClassifier
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong scaler or model classes
Mixing up order of pipeline steps
5fill in blank
hard

Fill all three blanks to automate training, prediction, and accuracy calculation.

MLOps
pipeline.fit([1], [2])
predictions = pipeline.predict([3])
from sklearn.metrics import accuracy_score
accuracy = accuracy_score(y_test, predictions)
Drag options to blanks, or click blank then click option'
AX_train
By_train
CX_test
Dy_test
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up train and test sets
Using labels instead of features for prediction