Kaggle competition: Sarcasmo
df_all = concat_df(df_train,df_test )<drop_column>
df_train = pd.read_csv('.. /input/train.csv')
 df_valid = pd.read_csv('.. /input/valid.csv')
 df_sample_submission = pd.read_csv('.. /input/sample_submission.csv' )
drop_list.append('tic_rate')
 drop_list.append('Sur_rate')
 drop_list.append('tic_count')
 drop_list.append('Sur_count' )<drop_column>
df_train.drop(['article_link'], axis=1)
 df_valid.drop(['article_link'], axis=1 )
df_all.drop(drop_list,inplace=True, axis=1)
 drop_list = []<drop_column>
from sklearn.feature_extraction.text import TfidfVectorizer
drop_list.append('Name')
 df_all.drop(drop_list,inplace=True, axis=1)
 drop_list = [] 
<drop_column>
TfidfVec = TfidfVectorizer()
drop_list.append('Ticket')
 drop_list.append('Surname')
 df_all.drop(drop_list,inplace=True, axis=1)
 drop_list = []<define_variables>
all_headlines = pd.DataFrame()
all_headlines = pd.concat([df_train, df_valid] )
def non_numeric_features(df):
alist = []
for col in df.columns:
if 'float' not in str(df[col].dtype)and 'int' not in str(df[col].dtype):
alist.append(col)
 return alist
non_num_list = non_numeric_features(df_all )<categorify>
Tfidf_vectorized_data = TfidfVec.fit_transform(all_headlines.headline )
df_train, df_test = divide_df(df_all)
 dfs =[df_train,df_test]
for df in dfs:
for feature in non_num_list:
df[feature] = LabelEncoder().fit_transform(df[feature] )<categorify>
df_train_vec = Tfidf_vectorized_data[:18696]
df_valid_vec = Tfidf_vectorized_data[18696:]
cat_features = ['Embarked', 'Sex', 'Family', 'Title','Pclass','Deck']
for i,df in enumerate(dfs):
for feature in cat_features:
df = pd.concat([df,pd.get_dummies(df[feature], prefix=feature)],axis=1 ).drop([feature],axis=1)
 dfs[i] = df<import_modules>
y_train = df_train.is_sarcastic
from sklearn.ensemble import RandomForestClassifier, AdaBoostClassifier, GradientBoostingClassifier, ExtraTreesClassifier
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
from sklearn.linear_model import LogisticRegression
from sklearn.neighbors import KNeighborsClassifier
from sklearn.tree import DecisionTreeClassifier
from sklearn.svm import SVC
from sklearn.model_selection import GridSearchCV, cross_val_score, StratifiedKFold<train_model>
from sklearn.linear_model import SGDClassifier
from sklearn.model_selection import train_test_split
from sklearn.metrics import roc_auc_score
df_train = dfs[0]
df_train.name = 'training'
df_test = dfs[1]
df_test.name = 'testing'
display_missing(df_train)
 display_missing(df_test )<normalization>
df_train_1, df_train_2 = train_test_split(df_train_vec, test_size=0.1)
 df_y_1, df_y_2 = train_test_split(y_train, test_size=0.1 )
X_train = StandardScaler().fit_transform(df_train.drop('Survived',axis=1))
y_train = df_train['Survived']
X_test = StandardScaler().fit_transform(df_test)
 print('X_train shape: {}'.format(X_train.shape))
print('y_train shape: {}'.format(y_train.shape))
print('X_test shape: {}'.format(X_test.shape))<choose_model_class>
model = SGDClassifier(n_jobs=-1, loss='hinge', random_state=42 )
single_best_model = RandomForestClassifier(criterion='gini',
n_estimators=1100,
max_depth=5,
min_samples_split=4,
min_samples_leaf=5,
max_features='auto',
oob_score=True,
random_state=SEED,
n_jobs=-1,
verbose=1)
<predict_on_test>
pred = model.predict(df_valid_vec )
<save_to_csv><EOS> 
my_submission=pd.DataFrame({'ID': df_valid['ID'], 'is_sarcastic': pred})
 my_submission.to_csv('fepas_submission_3.csv',index=False )