text_plain_output_1.png
from sklearn.linear_model import LogisticRegression, LogisticRegressionCV

from sklearn.model_selection import StratifiedShuffleSplit

import numpy as np

import os

import pandas as pd

train = pd.read_csv('../input/train.csv')
test = pd.read_csv('../input/test.csv')

train.drop('subject', axis=1, inplace=True)
test.drop('subject', axis=1, inplace=True)

object_feature = train.dtypes == np.object
object_feature = train.columns[object_feature]
object_feature
train['Activity']

train.Activity.sample(5)

feature_cols = train.columns[:-1]
correlated_values = train[feature_cols].corr()
correlated_values = correlated_values.stack().to_frame().reset_index().rename(columns={'level_0': 'Feature_1', 'level_1': 'Feature_2', 0: 'Correlations'})

split_data = StratifiedShuffleSplit(n_splits=1, test_size=0.3, random_state=42)
train_idx, val_idx = next(split_data.split(train[feature_cols], train.Activity))
x_train = train.loc[train_idx, feature_cols]
y_train = train.loc[train_idx, 'Activity']
x_val = train.loc[val_idx, feature_cols]
y_val = train.loc[val_idx, 'Activity']

lr_l2 = LogisticRegressionCV(cv=4, penalty='l2', max_iter=1000, n_jobs=-1)
lr_l2 = lr_l2.fit(x_train, y_train)