Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import the library used for customer segmentation.
Data Analysis Python
import [1] as pd
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using numpy instead of pandas for data tables.
Importing sklearn here instead of pandas.
✗ Incorrect
We use pandas to handle data in tables, which is essential for customer segmentation.
2fill in blank
mediumComplete the code to load customer data from a CSV file.
Data Analysis Python
data = pd.[1]('customers.csv')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using read_excel for CSV files.
Using read_json when the file is CSV.
✗ Incorrect
To load data from a CSV file, we use pd.read_csv.
3fill in blank
hardFix the error in the code to select only numeric columns for clustering.
Data Analysis Python
numeric_data = data.select_dtypes(include=[1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'object' which selects text columns.
Using 'float64' which selects only one numeric type.
✗ Incorrect
The correct keyword to select numeric columns is 'number'.
4fill in blank
hardFill both blanks to create a KMeans model and fit it to the numeric data.
Data Analysis Python
from sklearn.cluster import [1] model = [2](n_clusters=3) model.fit(numeric_data)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using regression models instead of clustering.
Mismatching import and model names.
✗ Incorrect
We import and create a KMeans clustering model to segment customers.
5fill in blank
hardFill both blanks to add cluster labels to the data and show the first 5 rows.
Data Analysis Python
data['cluster'] = model.[1](numeric_data) print(data.[2](5))
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using predict without fitting first.
Using tail instead of head to show rows.
✗ Incorrect
We use fit_predict to assign clusters and head to display the first 5 rows.