Exercise

# Building a logistic regression model

You can build a logistic regression model using the module `linear_model`

from `sklearn`

. First, you create a logistic regression model using the `LogisticRegression()`

method:

```
logreg = linear_model.LogisticRegression()
```

Next, you need to feed data to the logistic regression model, so that it can be fit. `X`

contains the predictive variables, whereas `y`

has the target.

```
X = basetable[["predictor_1","predictor_2","predictor_3"]]`
y = basetable[["target"]]
logreg.fit(X,y)
```

In this exercise you will build your first predictive model using three predictors.

Instructions

**100 XP**

- Import the method
`linear_model`

from`sklearn`

. - The basetable is loaded as
`basetable`

. Note that the column "gender" has been transformed to`gender_F`

so that it can be used as a predictor. Construct a dataframe`X`

that contains the predictors`age`

,`gender_F`

and`time_since_last_gift`

. - Construct a dataframe
`y`

that contains the target. - Create a logistic regression model.
- Fit the logistic regression model on the given basetable.