Working with more product features
In the example, we will use a dataset that contains many more features than the previous example. In this case, we will simulate data obtained from a crisp retail vendor that has asked some of its customers to rank its products according to their level of preference:
- The following block of code will read the dataset, which is a CSV file, and will prompt us with the result:
# Load data
conjoint_dat = pd.read_csv('/content/conjoint_data.csv')
conjoint_dat
This results in the following output:
Figure 4.9: Crisps data
- We can see that the data contains only categorical values, so it will be necessary to transform this categorical data into a one-hot vector representation using the
get_dummies
pandas function, which is what we do in the next block of code:conjoint_dat_dum = pd.get_dummies(conjoint_dat.iloc[:,:-1], columns = conjoint_dat.iloc[:,:-1].columns)
conjoint_dat_dum
We can see that now...