# Combining information from a categorical variable and a continuous variable

I asked a question regarding relationship between a categorical and a continuous variables yesterday, and I have another question with regards to how to deal with a categorical and a continuous variable.

c1 = name of the closest metro station

x1 = distance to that metro station


The outcome is affected by both which station and how far away the station is, so, obviously, I would like to combine the information from both variables. The steps I took are:

1) First perform label encoding for c1 -> c1_le

2) Perform one hot encoding to c1_le -> c1_le_encoded

3) Then perform element-wise (not matrix) multiplications c1_le_encoded -> c1_le_encoded_km (Okay maybe these are not the best variable names....)

So in essence, if

c1 = [station1, station2, station1]

c1_le = [1, 2, 1]

c1_le_encoded = [[1, 0],
[0, 1],
[1, 0]]

x1 = [2, 2, 3]

c1_le_encoded_km = [[2, 0],
[0, 2],
[3, 0]]


So each data would represent 2km away from station1, 2 km away from station2, and 3km away from station1.

Q1: I feel like this combined variable should represent the information with much more meaning than feeding them separately to a regression/ML model. Is this okay/legal to do? Or could this introduce some distortion in the data?

Q2: If I wanted to standardize my real value variable, x1 -> x1_std, my intuition tells me that I would also have to multiply c1_le_encoded by x1_std not x1. Is there a difference (Of course, given the first step is legal to begin with)?

Thank You