Kaggle competition: Ghouls, Goblins, and Ghosts... Boo!
sample = pd.read_csv('/kaggle/input/google-quest-challenge/sample_submission.csv')
 sample.head(3 )<load_from_csv>
data_frame_train = pd.read_csv('.. /input/train.csv')
 data_frame_test = pd.read_csv(".. /input/test.csv" )
train = pd.read_csv('/kaggle/input/google-quest-challenge/train.csv')
 train.head(3 )<load_from_csv>
print(data_frame_train.dtypes )
test = pd.read_csv('/kaggle/input/google-quest-challenge/test.csv')
 test.head(3 )<define_variables>
class_count = data_frame_train.groupby('type' ).size()
print(class_count )
targets = [
'question_asker_intent_understanding',
'question_body_critical',
'question_conversational',
'question_expect_short_answer',
'question_fact_seeking',
'question_has_commonly_accepted_answer',
'question_interestingness_others',
'question_interestingness_self',
'question_multi_intent',
'question_not_really_a_question',
'question_opinion_seeking',
'question_type_choice',
'question_type_compare',
'question_type_consequence',
'question_type_definition',
'question_type_entity',
'question_type_instructions',
'question_type_procedure',
'question_type_reason_explanation',
'question_type_spelling',
'question_well_written',
'answer_helpful',
'answer_level_of_information',
'answer_plausible',
'answer_relevance',
'answer_satisfaction',
'answer_type_instructions',
'answer_type_procedure',
'answer_type_reason_explanation',
'answer_well_written'
] 
<feature_engineering>
df = data_frame_train["type"]
indexes_test = data_frame_test["id"]
data_frame_train = data_frame_train.drop(["type","color","id"],axis=1)
 data_frame_test = data_frame_test.drop(["color","id"],axis=1 )
stopwords=stopwords.words('english')
 train['que_stopwords']=train['question_body'].apply(lambda x : [x for x in x.split() if x in stopwords])
 train['ans_stopwords']=train['answer'].apply(lambda x: [x for x in x.split() if x in stopwords] )<count_unique_values>
data_frame_train = pd.get_dummies(data_frame_train)
 data_frame_test = pd.get_dummies(data_frame_test )
def common_ngrams(col,common=10):
corpus=[]
for question in train[col].values:
words=[str(x[0]+' '+x[1])for x in ngrams(question.split() ,2)]
corpus.append(words)
 flatten=[x for one in corpus for x in one]
counter=Counter(flatten)
 most_common=counter.most_common(common)
 string,value=zip(*(most_common))
return string,value 
<set_options>
x_train, x_test, y_train, y_test = train_test_split(data_frame_train, df, test_size=0.3, random_state=0 )
np.set_printoptions(suppress=True )<load_from_csv>
lr = LogisticRegression(penalty='l2',C=1000000)
 lr.fit(x_train,y_train)
 y_pred= lr.predict(x_test)
 print(classification_report(y_pred,y_test))
<string_transform><EOS> 
y_pred = lr.predict(data_frame_test)
 Y = pd.DataFrame()
Y["id"] = indexes_test
Y["type"] = y_pred
Y.to_csv("submission.csv",index=False )