0
0
Prompt Engineering / GenAIml~10 mins

Training data preparation in Prompt Engineering / GenAI - Interactive Code Practice

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

Complete the code to load data from a CSV file using pandas.

Prompt Engineering / GenAI
import pandas as pd
data = pd.read_csv([1])
Drag options to blanks, or click blank then click option'
A'data.csv'
Bdata.csv
Ccsv.data
Dread.csv
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the file name
Using incorrect function names
2fill in blank
medium

Complete the code to split data into features and labels.

Prompt Engineering / GenAI
X = data.drop([1], axis=1)
y = data['label']
Drag options to blanks, or click blank then click option'
A'features'
B'label'
Clabel
Dfeatures
Attempts:
3 left
💡 Hint
Common Mistakes
Dropping the wrong column
Not using quotes for column name
3fill in blank
hard

Fix the error in the code to split data into training and testing sets.

Prompt Engineering / GenAI
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'
A50
B0.5
C0.2
D2
Attempts:
3 left
💡 Hint
Common Mistakes
Using integers instead of floats
Using values greater than 1
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps words to their lengths only if length is greater than 3.

Prompt Engineering / GenAI
lengths = {word: [1] for word in words if len(word) [2] 3}
Drag options to blanks, or click blank then click option'
Alen(word)
B<
C>
Dword
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong comparison operator
Mapping word instead of length
5fill in blank
hard

Fill all three blanks to create a filtered dictionary with uppercase keys, values as counts, and only include counts greater than 1.

Prompt Engineering / GenAI
result = { [1]: [2] for k, v in data.items() if v [3] 1 }
Drag options to blanks, or click blank then click option'
Ak.upper()
Bv
C>
Dk
Attempts:
3 left
💡 Hint
Common Mistakes
Using original keys instead of uppercase
Using wrong comparison operator