3
$\begingroup$

In the Titanic dataset, there are two features, "SibSp" and "Parch," which have an impact on the survival rate. For instance, the survival rate tends to increase when the values of "SibSp" range from 0 to 2, but it decreases from 2 onwards. I intend to use logistic regression for predictions and I am unsure if I can utilize these features. Although they do not show a linear relationship with the survival rate, I wonder if logistic regression can still be applied or if it is not suitable. One idea I have is to OneHotEncode these features. This way, logistic regression could identify patterns by creating new features for each class in "SibSp" and "Parch." For example, we could check if "is SibSp = 1?" and assign 1 for "yes" and 0 for "no."

$\endgroup$

3 Answers 3

2
$\begingroup$

These features can indeed be used for regression, and in my experience helped a little bit (been awhile since I looked at Titanic ;). I ended up combining them:

train_set['Relatives']=train_set.SibSp+train_set.Parch
test_set['Relatives']=test_set.SibSp+test_set.Parch

though I was using SVMs so your mileage may vary, hth.

$\endgroup$
2
$\begingroup$

You describe that the correlation between survival rate and the variable "SibSp" is first increasing and then decreasing. In this case a logistic regression seems like the wrong choice. The relationship is clearly not linear.

A logistic regression means that you apply a logarithmic function to your variables. This models (some specific) non-linear relationsships but the relationsship is still monotonic, more of one variable always implies more of the other variable. This doesn't fit your example.

In this example I would suggest to bin the "SibSp" variable, that is map the numbers to a finite collection of groups (say between 0 and 1, between 1 and 2 and so forth) and then use these bins as a categorical variable in your model.

$\endgroup$
1
$\begingroup$

The features can be used for regression, but my advise would be to perform feature selection to get the optimal results for the model.

For Logistic Regression, you can go with Solver or use Regularization for the purpose for instance.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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