<jupyter_start><jupyter_text>**Survival of the FITtest**<jupyter_code>import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns<jupyter_output><empty_output><jupyter_text>Get  Dataset<jupyter_code>from sklearn.datasets import load_breast_cancer
data = load_breast_cancer()
data.keys()
X = data.data
y = data.target
# TRAIN TEST SPLIT
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.1)
# Feature Scaling
from sklearn.preprocessing import StandardScaler
sc = StandardScaler()
X_train = sc.fit_transform(X_train)
X_test = sc.transform(X_test)
from sklearn.linear_model import LogisticRegression
classifier = LogisticRegression()
classifier.fit(X_train,y_train)
importance = classifier.coef_[0]
# summarize importance
# for i,v in enumerate(importance):
# 	print('Feature: %0d, Score: %.5f' % (i,v))
# plot importance
fig, ax = plt.subplots(figsize=(10,8))
sns.set_theme(style="whitegrid", palette="pastel")
g = sns.barplot([x for x in range(len(importance))], importance, ax=ax)
g.set_xticklabels([])
sns.set_style("whitegrid")
g.set_title("Feature Importance by Logistic Regression")<jupyter_output>/usr/local/lib/python3.7/dist-packages/seaborn/_decorators.py:43: FutureWarning: Pass the following variables as keyword args: x, y. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation.
  FutureWarning<jupyter_text>The positive scores indicate a feature that predicts class 1, whereas the negative scores indicate a feature that predicts class 0.<jupyter_code>type(importance)
n = 5
indices = (-abs(importance)).argsort()[:n]
print(indices)
y_pred = classifier.predict(X_test)
X_train.shape
from sklearn.metrics import accuracy_score
acc_score = accuracy_score(y_test, y_pred)
print(X_train.shape, acc_score)
classifier = LogisticRegression()
classifier.fit(X_train[:, indices], y_train)
y_pred = classifier.predict(X_test[:, indices])
acc_score = accuracy_score(y_test, y_pred)
print(X_train[:, indices].shape, acc_score)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10642201834862386, 'fraction_numerical': 0.008256880733944955, 'mean_word_length': 7.388461538461539, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '384463', 'license': 'MIT', 'n_tokens_mistral': 749, 'n_tokens_neox': 728, 'n_words': 187, 'path': 'FeatureSelection_DataScience/Demo212_Selection_LogisticCoefficients.ipynb', 'repo_name': 'mahnooranjum/Programming_DataScience', 'size': '2180'}