# Question on Linear and logistic regression

**URL:** <https://community.deeplearning.ai/t/question-on-linear-and-logistic-regression/311442>\
**Category:** Supervised ML: Regression and Classification\
**Tags:** week-module-3\
**Created:** [April 19, 2023, 1:22pm UTC](https://community.deeplearning.ai/t/question-on-linear-and-logistic-regression/311442 "2023-04-19T13:22:15Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Christian\_Simonis](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/christian_simonis/32/142583_2.png) [@Christian\_Simonis](https://community.deeplearning.ai/u/Christian_Simonis)\
**Post date:** [April 19, 2023, 4:21pm UTC](https://community.deeplearning.ai/t/question-on-linear-and-logistic-regression/311442/3 "2023-04-19T16:21:44Z")

</div>

Hi @kaki178925

Sometimes fitting a streight line or a plane (w/ a linear model) is just not sufficient to model the relationship between your features and your label, especially if the relationship is a bit more complex.

In order to describe the non-linearity, feature engineering can do the trick which can involve:

- different powers of x as you mentioned
- features crosses, see also this thread: [Example of encoding the non linearity using feature crossing - #2 by Christian\_Simonis](https://community.deeplearning.ai/t/example-of-encoding-the-non-linearity-using-feature-crossing/267749/2)
- or some other kind of domain knowledge that you model into your features which is called feature engineering

When you have a manageable amount of features what always helps is to analyze the residuals to see where you have still systematic patterns left that you could potentially exploit in your feature engineering, see also:

- this thread: [How to evaluate accuracy of a regression model - #21 by Christian\_Simonis](https://community.deeplearning.ai/t/how-to-evaluate-accuracy-of-a-regression-model/243120/21)
- [a coding example](https://github.com/christiansimonis/CRISP-DM-AI-tutorial/blob/master/Classic_ML.ipynb)

In a perfect world you would just see some random (Gaussian) distribution in your residua and no systematic patterns:  
[![](https://global.discourse-cdn.com/dlai/original/3X/c/0/c0b9819ef070619a63cffc64b637c1dd598074e8.jpeg) ](https://global.discourse-cdn.com/dlai/original/3X/c/0/c0b9819ef070619a63cffc64b637c1dd598074e8.jpeg)

Since your question also touches upon logistic regression, maybe this thread could be interesting for you, too: [Can logistic regression be replaced with ordinary linear regression - #16 by Christian\_Simonis](https://community.deeplearning.ai/t/can-logistic-regression-be-replaced-with-ordinary-linear-regression/244196/16)

Hope that helps!

Best regards  
Christian

---

_[View the full topic](https://community.deeplearning.ai/t/question-on-linear-and-logistic-regression/311442)._
