Questions and answers
24 questions from the community, answered by the
author in
#book-of-the-week
on Slack.
-
Guy Adams asked
Soledad Galli - thanks for agreeing to answer questions! How automatable is the process of feature engineering against unknown/new data?
-
Kshitiz asked
Soledad Galli - Thank you for doing this. Looking forward to other questions/responses as well.
I want to understand if there is any systematic approach to engineer features for specific problems?
-
Quynh Le asked
Hi Soledad Galli, thanks for writing the book! Could you share with us which feature engineering methods are most popular? Also does feature engineering make it more difficult to interpret the model results?
-
Nikhil Shrestha asked
Hi Soledad Galli
Thanks for writing the book.
Feature engineering has always been one of my favorite area in whole machine learning.
I am posting few of many questions here:
1. Depending on data and it's distribution we decide upon the feature engineering we can perform. As I also learnt that this can be mastered with practice and experience with data. Could you point some resources to understand this better. Lets say for e.g. we have a non linearly separable data in binary classification problem. data looks like a concentric circle where -ve points are in the inner circle and positive are on the outer circle. How can we transform such feature to use Logistic Regression.
2. I did a project on Walmart where I used columns like date, weekly sales(dependent variable), store_number, to generate two new ordinal columns which actually helped to improve score a lot. I used mean, addition, if else statement to do this. Another example for the same was formula for calculating social media popularity = (number_of_people_reviewed_for movies / number_of people_voted_for_movie) * no_of_faceboooks_likes. It never made sense to me as how this transformation helps in making model better, but it actually did.
Using this technique made me think does FEATURE ENGINEERING limits. Can we use any mathematical function using various columns and come up with a new column and that will improve the model ? or is there a specific pattern in this technique?
3. There are many articles which says you can even use running average of some variables to create a new one out of it. Does this apply to certain specific cases ? or we can do is more often generally?
I hope I didn't offend or trouble you with these questions, but I couldn't find answers to these. So thank you again Soledad Galli for the book and your expertise in this area, also thank you Alexey Grigorev for this platform.🙂
-
Doink asked
Soledad Galli
1. Classical Feature Engineering vs Deep Learning approach, which to choose when?
2. What are the limitations of feature engineering?
-
WingCode asked
Hi Soledad Galli,
What are the features usually extracted from:
1. Image
2. Video
3. Audio
-
WingCode asked
Is it common for a feature engineering to break down a complex feature into a naive feature and then apply feature engineering on the naive feature?
example 1: Video (complex type) broken down into a list of images (naive type). Apply feature engineering on each image
example 2: Audio (complex type) broken down into frequency domain(naive type). Apply feature engineering on each frequencies.
example 3: IP address (complex type) broken down into approx geo location coordinates(naive type) . Apply feature engineering on geo-location
-
Soledad Galli
Author of the book
Hello. Sorry WingCode I am not an expert on the field of Video, Audio and Image, so I can't comment.
-
WingCode asked
No problems Soledad Galli 🙂
-
Tim Becker asked
Hi Soledad Galli, thanks for answering our questions 🙂
-
Tim Becker asked
- How do you recommend to treat outliers? What do you think about clipping outliers and when is this a good idea?
-
Tim Becker asked
- How do you deal with feature drift? If I re-train a model and e.g., the average of a feature has changed, would you disregard old data?
-
Tim Becker asked
- How do you investigate seasonality and what features do you use when you find seasonality?
-
Tim Becker asked
- If you have timeseries data with a high frequency and you guess that consecutive data points are highly correlated, how do you check this and would you disregard some of the highly correlated data points for training?
-
Soledad Galli
Author of the book
Hello Tim Becker, outliers: you can cap the maximum and minimum values, I think this is what I do most often. Or you can remove them from the training data. But you would probably get outliers in the test, live data and then you need to decide what to do with those if you removed them from the train set. If you cap, then that is handled automatically by the feature engineering pipeline. When to cap or to clip depends on the data, and the model that you are training. Tree based models are robust to outliers, so no need to do much about them. Linear models are, so in that case you may chose to remove them. In some cases outliers are important, for example if you are investigating credit risk and a person has been in court already, it is a bad indicator, yet that happens very rarely, so a positive in that variable is indeed an outlier that you don't want to remove. You can choose to leave in the model and see what happens or perhaps better to create a rule to treat those cases separately (outside the model). Bottom line, I don't think there is a single way to treat outliers, it depends on the nature of the data and the outcome we are after, as well as the mathematical models we are using.
-
Soledad Galli
Author of the book
Feature drift: again, no single answer. Depends on the data, and what you are trying to model. I think the first thing would be to understand why the drift happened and if we expect this drift to hold or if we expect it to go back to original values. Some examples: a drift can happen because the organisation changed a policy, e.g., before it only served people of a certain age, now they serve all segments. Naturally there will be a drift, but that drift is here to stay. So I would probably try and incorporate more data that resembles the new population. Another example, during the 2009 depression debt indicators signaled risk of default. Several years after the depression, people acquire a lot of debt (not that I agree with that economic model) and they did not default. So debt indicator was no longer a signal for risk of default. What do you expect to happen in the next 5 years? a crisis, say a pandemic? then you could model using the old data. Stability? then I would discard the old data.
-
Soledad Galli
Author of the book
My examples are a bit easy and binary, but I guess you get the yest :)
-
Soledad Galli
Author of the book
Seasonality inspection, I think visual inspection + domain knowledge is what is done more often. If your features have seasonality you can create new features capturing aspects of that seasonality (regression in time, seasonal dummies, seasonal lag). I have not done that myself, so you need to come back with that questions in a few weeks from now if you would like more details, because we are preparing a new course on the topic :)
-
Soledad Galli
Author of the book
You can check autocorrelation with autocorrelation plots. I am not sure I would disregard data. I think you can apply filters to decrease a bit the variation if it is too much so that the autocorrelation is to high at some points, and also create lag features to capture that correlation and use it to your advantage if you want to forecast.
-
Sandhya G asked
Soledad Galli What are some suggestions on dealing with large number of features which do not have any physical significance. Few things to think of
1. Use lasso to select features
2. Remove features that have low variance (for floating point data)
3. Remove features that are highly cross correlated
4. PCA
Anything else?
Specifically, this is a chemistry problem, predicting properties using chemical structure of the molecule. There are established packages like RDKit which dump a 1000s of descriptors for each molecule.
Thanks!
-
Nikhil Shrestha asked
Hi Soledad Galli
I am putting my question in 4 steps:
1. Suppose we have some data in CSV and we want to make graph structure or visualization using this data
2. I was thinking of making certain column heading as vertex and the values inside column as edges.
3. For this we can use DictVectorizer to create numerous columns.
4. What can we do for numerical data if want to create a graph structure and end result should be explainable to non technical person
I am presently solving something very similar, so I was thinking of a way out.
So if this approach is completely wrong please suggest me some direction. 🙏🙂
-
Avishek Datta asked
*1. While checking for whether a feature has normal distribution or not, is it necessary to check for the distribution of the Target Variable as well and then transform this Target variable (say, log transform the Target variable)?*
*2. Again while checking the distribution I observe that one of the features is not normally distributed. So I log Transform it. This is a Predictor variable, now. Now after the entire model has been trained, do I need to use anti-log for that particular feature to take in new feature variables for prediction?*
*3. Maximum how many transformations can be added in a Pipeline & also a ColumnTransformer?*
*4. When should one use Winsorization and outlier removal through IQR method? Which is more optimal?*
-
Avishek Datta asked
*5. After applying discretization on a feature, is it necessary to check for the skewness of the discretized feature and then transform it, if necessary (say log transform or root transform?*
-
Shankar Somayajula asked
Hi Soledad Galli.. Thanks for taking questions.
Using the fraud model as an example, once users of your model see the results of latest fraud model incorporated and see the benefits e.g. successful identification of fraud instances... How do they respond to gaps in terms of missing fraud? Can they (opens in a new tab) articulate new features which are variations of existing features and see them incorporated w/o an explicit modeling process (via UI or some other post processing activity)? How does one keep the (domain) features updated? Is Iterative development fast enough to respond to real time fraud behavior/events?
Want the whole story?
The answers above are the short version of Python Feature Engineering Cookbook.