In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [1]:
import pandas as pd

train=pd.read_csv("kaggle-sentiment/train.tsv", delimiter='\t')
y=train['Sentiment'].values
X=train['Phrase'].values

pred_vec = bigram_tv_v3 # 60.4


test = pd.read_csv("kaggle-sentiment/test.tsv", delimiter='\t')
k_id = test['PhraseId']
k_text = test['Phrase']

# k_vec = bigram_tv_v3.transform(k_text)
# k_vec

def get_kaggle_test_train_vec(X,y,vectorizer):
    X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=None, random_state=0)
    X_train_vec = vectorizer.fit_transform(X_train)
#     X_test_vec = vectorizer.transform(X_test)
    return X_train_vec, y_train,

def do_the_kaggle(X,y,vec):
    X_train_vec, y_train = get_kaggle_test_train_vec(X,y,vec)
    svm_clf = LinearSVC(C=1)
    k_vec = pred_vec.transform(k_text)
    print(len(X), X_train_vec.shape, k_vec.shape)

    prediction = svm_clf.fit(X_train_vec,y_train).predict(k_vec)
    kaggle_submission = zip(k_id, prediction)
    outf=open('kaggle_submission_linearSVC_v8.csv', 'w')
    outf.write('PhraseId,Sentiment\n')
    for x, value in enumerate(kaggle_submission): outf.write(str(value[0]) + ',' + str(value[1]) + '\n')
    outf.close()
    print('prediction complete')

do_the_kaggle(X,y,pred_vec)
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-1-ec0ffcc8cd61> in <module>
----> 1 train=pd.read_csv("kaggle-sentiment/train.tsv", delimiter='\t')
      2 y=train['Sentiment'].values
      3 X=train['Phrase'].values
      4 
      5 pred_vec = bigram_tv_v3 # 60.4

NameError: name 'pd' is not defined
In [ ]: