Kaggle competition: What's Cooking? (Kernels Only)
<SOS> metric: CategorizationAccuracy Kaggle data source: whats-cooking?-(kernels-only)<split>
init_notebook_mode(connected=True)
 %matplotlib inline
color = sns.color_palette()
train_features_real = train_all_real.iloc[:len(train_target)]
real_data = train_all_real.iloc[len(train_target):len(train_all_real)]<set_options>
train = pd.read_json('.. /input/train.json')
 test = pd.read_json('.. /input/test.json')
 sub = pd.read_csv('.. /input/sample_submission.csv' )
del train_all_real
gc.collect()<concatenate>
total = train.isnull().sum().sort_values(ascending = False)
 percent =(train.isnull().sum() /train.isnull().count() *100 ).sort_values(ascending = False)
 missing_train_data = pd.concat([total, percent], axis=1, keys=['Total missing', 'Percent missing'])
 missing_train_data.head(20 )
train_all_fake = pd.concat([train_features,fake_data], axis = 0 )<count_duplicates>
total = test.isnull().sum().sort_values(ascending = False)
 percent =(test.isnull().sum() /test.isnull().count() *100 ).sort_values(ascending = False)
 missing_test_data = pd.concat([total, percent], axis=1, keys=['Total missing', 'Percent missing'])
 missing_test_data.head(20 )
for f in train_all_fake.columns[0:200]:
train_all_fake[f+'duplicate'] = train_all_fake.duplicated(f,False ).astype(int )<feature_engineering>
tfhash = [("tfidf", TfidfVectorizer(stop_words='english',max_df=.95)) , 
("hashing", HashingVectorizer(stop_words='english',ngram_range=(1,2)))]
X_train = FeatureUnion(tfhash ).fit_transform(train.ingredients.str.join(' '))
X_test = FeatureUnion(tfhash ).transform(test.ingredients.str.join(' '))
y = train.cuisine
sub['id'] = test.sort_values(by='id' , ascending=True)
 sub['cuisine'] = LinearSVC(C = 0.499, dual=False ).fit(X_train,y ).predict(X_test)
 sub[['id' , 'cuisine' ]].to_csv("svc.csv", index=False )