Kaggle competition: Team ISTE's Datathon
lemma=WordNetLemmatizer()
def clean_review(review_col):
review_corpus=[]
for i in range(0,len(review_col)) :
review=str(review_col[i])
 review=re.sub('[^a-zA-Z]',' ',review)
 review=[lemma.lemmatize(w)for w in word_tokenize(str(review ).lower())]
review=' '.join(review)
 review_corpus.append(review)
 return review_corpus<feature_engineering>
df = pd.read_csv('.. /input/train.csv' )
trainData['clean_ingredients']=clean_review(trainData.ingredients.values)
 testData['clean_ingredients']=clean_review(testData.ingredients.values)
 trainData.head()<feature_engineering>
y = df['Volume']
X = df.drop(['Volume','Date'],axis=1 )
tfidf=TfidfVectorizer()
xtrain=tfidf.fit_transform(trainData.clean_ingredients ).toarray()
xtest=tfidf.transform(testData.clean_ingredients ).toarray()<categorify>
from sklearn.linear_model import LinearRegression
lb = LabelEncoder()
yTrain = lb.fit_transform(trainData['cuisine'] )<compute_test_metric>
reg = LinearRegression()
vclf=VotingClassifier(estimators=[('clf1',LogisticRegression(C=10,dual=False)) ,('clf2',SVC(C=100,gamma=1,kernel='rbf',probability=True)) ],voting='soft',weights=[1,2])
 vclf.fit(xtrain , yTrain)
 vclf.score(xtrain , yTrain )<predict_on_test>
reg.fit(X,y )
pred = vclf.predict(xtest)
 ypred = lb.inverse_transform(pred )<save_to_csv>
test = pd.read_csv('.. /input/test.csv' )
sub = pd.DataFrame({'id': testData['id'], 'cuisine': ypred})
 sub.to_csv('svm_output.csv', index=False )<set_options>
testdf = test.drop(['Date'],axis=1 )
pd.options.display.max_colwidth = 110<count_values>
prediction = reg.predict(testdf )
df = pd.read_json('.. /input/train.json' ).set_index('id')
 df_test = pd.read_json('.. /input/test.json' ).set_index('id')
 df.head(10)
 df['cuisine'].unique()
df['cuisine'].value_counts()
df[df['ingredients'].str.len() < 2]<drop_column>
serial = test['Date']
data = {'Date': serial, 'Volume': prediction}
submission = pd.DataFrame(data)
 submission.to_csv('Submission.csv', index=False )