def training_data(classifier, tfidf, df):
'''Here we split our data set into train
and test. We take the data and split the
tweets and labels into 2 parts. The bigger
part is used for training and the rest is
used to testing the data '''
# Split data set:
tweet_train, tweet_test, signal_train, signal_test = train_test_split(tfidf, df[8], test_size=0.3, #'Label
random_state=42)
classify = classifier # Load trainer model.
cls = classify.fit(tweet_train, signal_train) # Train data.
predict = cls.predict(tweet_test) # Predict data.
# Save the model to disk
filename = str(classifier).split('(',1)[0] + '.sav'
pickle.dump(cls, open(filename, 'wb'))
print(filename + ' result:')
return classification_report(signal_test, predict) # Give report or evaluation.
Повідомлення def training_data(classifier, tfidf, df):
16 січня 2018Поруч у стрічці
Pце повідомлення
P