1
$\begingroup$

Learning Microsoft's DP-100 and saw this notebook:

The part of its code which I have question with is

# Define preprocessing for categorical features (encode the Age column)
categorical_features = [7]
categorical_transformer = Pipeline(steps=[
    ('onehot', OneHotEncoder(handle_unknown='ignore'))])

here is the link for the entire notebook for you to see the full picture. I cannot copy the full pages of code here.

Here is how the data look like: enter image description here

My question is: Why is the DiabetesPedigree column(which is the 7th column) treated as a categorical feature?

To me, it looks nothing different from the rest of other columns(except the Diabetic column).

If DiabetesPedigree could be treated as categorical why not Pregnancies?

What are the rules to tell whether a column of data is numeric or categorical?

$\endgroup$
1
$\begingroup$

Have a look at the comment in that notebook:

# Define preprocessing for categorical features (encode the Age column)

It seems that the data you have is different (maybe only in order) to what is used in the notebook as the Age column is the eigth column (index seven) in the notebook. See also the cell where data is selected from the input file:

# Separate features and labels
features = ['Pregnancies','PlasmaGlucose','DiastolicBloodPressure','TricepsThickness','SerumInsulin','BMI','DiabetesPedigree','Age']
label = 'Diabetic'
X, y = diabetes[features].values, diabetes[label].values
$\endgroup$
1
  • $\begingroup$ found why the 7th col is Age, thanks for pointing it out. But this doesn't answer my question, why Age is considered as a categorical column rather than a numeric column? $\endgroup$ – Franva Feb 5 at 1:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.