𝐖𝐡𝐞𝐧 𝐭𝐨 𝐝𝐨 𝐟𝐞𝐚𝐭𝐮𝐫𝐞 𝐬𝐜𝐚𝐥𝐢𝐧𝐠 𝐚𝐟𝐭𝐞𝐫 𝐭𝐫𝐚𝐢𝐧 𝐭𝐞𝐬𝐭 𝐬𝐩𝐥𝐢𝐭 𝐨𝐫 𝐛𝐞𝐟𝐨𝐫𝐞 𝐭𝐡𝐞 𝐬𝐩𝐥𝐢𝐭?
𝐀𝐧𝐬𝐰𝐞𝐫: In general, feature scaling should be done after the split to avoid data leakage. [A THREAD>>>]
Let's take the example of standardization where we use the standard deviation of training data to scale the features. So to scale test data use the same standard deviation and scale test data (then calculate the standard deviation for testing data and use it.)