text_html_output_1.png
from scipy.stats import pearsonr

import pandas as pd

import seaborn as sns

import tensorflow as tf

def getCorr(x, y):
    corr, _ = pearsonr(x, y)
    return corr

def getSlope(df):
    return abs(df['slope'])

dftrain = pd.read_csv('../input/dont-overfit-ii/train.csv')
dftest = pd.read_csv('../input/dont-overfit-ii/test.csv')

y=sns.regplot(x='1',y='target',data=dftrain)

detailed_features=[]
for feature in range(300):
    y=sns.regplot(x=str(feature),y='target',data=dftrain)
    detailed_features.append({'feature':feature,'slope':getCorr(dftrain['target'],dftrain[str(feature)])})

detailed_features.sort(key=getSlope, reverse=True)

features_to_save = []
for iteration in range(6):
    features_to_save.append(detailed_features[iteration]['feature'])

def getDfProcessed(df_toProcess, features_to_save):
    df_processed = pd.DataFrame()
    for iteration in features_to_save:
        feature = df_toProcess[str(iteration)].values
        df_processed[str(iteration)] = feature
    return df_processed

dftrain_processed = getDfProcessed(dftrain, features_to_save)

y_train = dftrain.pop('target')

model = tf.keras.models.Sequential([tf.keras.layers.Flatten(), tf.keras.layers.Dense(7, activation=tf.nn.relu), tf.keras.layers.Dense(2, activation=tf.nn.softmax)])

model.compile(loss='binary_crossentropy', optimizer='Adam', metrics=['accuracy'])

model.fit(dftrain_processed, y_train, epochs=10)