0
0
Data Analysis Pythondata~10 mins

Customer segmentation pattern in Data Analysis Python - Interactive Code Practice

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

Complete 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'
Apandas
Bnumpy
Cmatplotlib
Dsklearn
Attempts:
3 left
💡 Hint
Common Mistakes
Using numpy instead of pandas for data tables.
Importing sklearn here instead of pandas.
2fill in blank
medium

Complete 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'
Aread_excel
Bread_csv
Cread_json
Dread_table
Attempts:
3 left
💡 Hint
Common Mistakes
Using read_excel for CSV files.
Using read_json when the file is CSV.
3fill in blank
hard

Fix 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'
A'float64'
B'numeric'
C'object'
D'number'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'object' which selects text columns.
Using 'float64' which selects only one numeric type.
4fill in blank
hard

Fill 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'
AKMeans
BLinearRegression
DLogisticRegression
Attempts:
3 left
💡 Hint
Common Mistakes
Using regression models instead of clustering.
Mismatching import and model names.
5fill in blank
hard

Fill 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'
Apredict
Bhead
Ctail
Dfit_predict
Attempts:
3 left
💡 Hint
Common Mistakes
Using predict without fitting first.
Using tail instead of head to show rows.