text_plain_output_2.png application_vnd.jupyter.stderr_output_1.png
from sklearn.compose import ColumnTransformer

from sklearn.feature_selection import RFE

from sklearn.linear_model import LogisticRegression

from sklearn.preprocessing import OneHotEncoder

import matplotlib.pyplot as plt

import pandas as pd

data = pd.read_csv('../input/heart-failure-prediction/heart.csv')

data.shape

data.nunique()

data.dropna(inplace=True)
data.isnull().sum()

data.shape

X = data.iloc[:, :-1]
y = data.iloc[:, -1]

ct1 = ColumnTransformer(transformers=[('encoder', OneHotEncoder(), [1, 2, 6, 8, 10])], remainder='passthrough')

X = ct1.fit_transform(X)

X = pd.DataFrame(X)

model = LogisticRegression()
rfe = RFE(model, n_features_to_select=5)
fit = rfe.fit(X, y)

fit.n_features_

features = fit.transform(X)

print(features[0:5, :])