Introdução ao Processamento de Linguagem Natural (PLN) Usando Python

Professor Fernando Vieira da Silva MSc.

Problema de Classificação

Neste tutorial vamos trabalhar com um exemplo prático de problema de classificação de texto. O objetivo é identificar uma sentença como escrita "formal" ou "informal".

1. Obtendo o corpus

Para simplificar o problema, vamos continuar utilizando o corpus Gutenberg como textos formais e vamos usar mensagens de chat do corpus nps_chat como textos informais.

Antes de tudo, vamos baixar o corpus nps_chat:


In [1]:
import nltk

nltk.download('nps_chat')


[nltk_data] Downloading package nps_chat to
[nltk_data]     /home/fernando/nltk_data...
[nltk_data]   Unzipping corpora/nps_chat.zip.
Out[1]:
True

In [2]:
from nltk.corpus import nps_chat

print(nps_chat.fileids())


['10-19-20s_706posts.xml', '10-19-30s_705posts.xml', '10-19-40s_686posts.xml', '10-19-adults_706posts.xml', '10-24-40s_706posts.xml', '10-26-teens_706posts.xml', '11-06-adults_706posts.xml', '11-08-20s_705posts.xml', '11-08-40s_706posts.xml', '11-08-adults_705posts.xml', '11-08-teens_706posts.xml', '11-09-20s_706posts.xml', '11-09-40s_706posts.xml', '11-09-adults_706posts.xml', '11-09-teens_706posts.xml']

Agora vamos ler os dois corpus e armazenar as sentenças em uma mesma ndarray. Perceba que também teremos uma ndarray para indicar se o texto é formal ou não. Começamos armazenando o corpus em lists. Vamos usar apenas 500 elementos de cada, para fins didáticos.


In [3]:
import nltk

x_data_nps = []

for fileid in nltk.corpus.nps_chat.fileids():
    x_data_nps.extend([post.text for post in nps_chat.xml_posts(fileid)])

y_data_nps = [0] * len(x_data_nps)

x_data_gut = []
for fileid in nltk.corpus.gutenberg.fileids():
    x_data_gut.extend([' '.join(sent) for sent in nltk.corpus.gutenberg.sents(fileid)])
    
y_data_gut = [1] * len(x_data_gut)

x_data_full = x_data_nps[:500] + x_data_gut[:500]
print(len(x_data_full))
y_data_full = y_data_nps[:500] + y_data_gut[:500]
print(len(y_data_full))


1000
1000

Em seguida, transformamos essas listas em ndarrays, para usarmos nas etapas de pré-processamento que já conhecemos.


In [4]:
import numpy as np

x_data = np.array(x_data_full, dtype=object)
#x_data = np.array(x_data_full)
print(x_data.shape)
y_data = np.array(y_data_full)
print(y_data.shape)


(1000,)
(1000,)

2. Dividindo em datasets de treino e teste

Para que a pesquisa seja confiável, precisamos avaliar os resultados em um dataset de teste. Por isso, vamos dividir os dados aleatoriamente, deixando 80% para treino e o demais para testar os resultados em breve.


In [5]:
train_indexes = np.random.rand(len(x_data)) < 0.80

print(len(train_indexes))
print(train_indexes[:10])


1000
[ True  True  True  True  True  True False False False  True]

In [6]:
x_data_train = x_data[train_indexes]
y_data_train = y_data[train_indexes]

print(len(x_data_train))
print(len(y_data_train))


808
808

In [7]:
x_data_test = x_data[~train_indexes]
y_data_test = y_data[~train_indexes]

print(len(x_data_test))
print(len(y_data_test))


192
192

3. Treinando o classificador

Para tokenização, vamos usar a mesma função do tutorial anterior:


In [8]:
from nltk import pos_tag
from nltk.corpus import stopwords
from nltk.stem import WordNetLemmatizer
from nltk.tokenize import word_tokenize
import string
from nltk.corpus import wordnet

stopwords_list = stopwords.words('english')

lemmatizer = WordNetLemmatizer()

def my_tokenizer(doc):
    words = word_tokenize(doc)
    
    pos_tags = pos_tag(words)
    
    non_stopwords = [w for w in pos_tags if not w[0].lower() in stopwords_list]
    
    non_punctuation = [w for w in non_stopwords if not w[0] in string.punctuation]
    
    lemmas = []
    for w in non_punctuation:
        if w[1].startswith('J'):
            pos = wordnet.ADJ
        elif w[1].startswith('V'):
            pos = wordnet.VERB
        elif w[1].startswith('N'):
            pos = wordnet.NOUN
        elif w[1].startswith('R'):
            pos = wordnet.ADV
        else:
            pos = wordnet.NOUN
        
        lemmas.append(lemmatizer.lemmatize(w[0], pos))

    return lemmas

Mas agora vamos criar um pipeline contendo o vetorizador TF-IDF, o SVD para redução de atributos e um algoritmo de classificação. Mas antes, vamos encapsular nosso algoritmo para escolher o número de dimensões para o SVD em uma classe que pode ser utilizada com o pipeline:


In [9]:
from sklearn.decomposition import TruncatedSVD

class SVDDimSelect(object):
    def fit(self, X, y=None):               
        self.svd_transformer = TruncatedSVD(n_components=X.shape[1]/2)
        self.svd_transformer.fit(X)
        
        cummulative_variance = 0.0
        k = 0
        for var in sorted(self.svd_transformer.explained_variance_ratio_)[::-1]:
            cummulative_variance += var
            if cummulative_variance >= 0.5:
                break
            else:
                k += 1
                
        self.svd_transformer = TruncatedSVD(n_components=k)
        return self.svd_transformer.fit(X)
    
    def transform(self, X, Y=None):
        return self.svd_transformer.transform(X)
        
    def get_params(self, deep=True):
        return {}

Finalmente podemos criar nosso pipeline:


In [10]:
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.pipeline import Pipeline
from sklearn import neighbors

clf = neighbors.KNeighborsClassifier(n_neighbors=10, weights='uniform')

my_pipeline = Pipeline([('tfidf', TfidfVectorizer(tokenizer=my_tokenizer)),\
                       ('svd', SVDDimSelect()), \
                       ('clf', clf)])

Estamos quase lá... Agora vamos criar um objeto RandomizedSearchCV que fará a seleção de hiper-parâmetros do nosso classificador (aka. parâmetros que não são aprendidos durante o treinamento). Essa etapa é importante para obtermos a melhor configuração do algoritmo de classificação. Para economizar tempo de treinamento, vamos usar um algoritmo simples o K nearest neighbors (KNN).


In [11]:
from sklearn.grid_search import RandomizedSearchCV
import scipy

par = {'clf__n_neighbors': range(1, 60), 'clf__weights': ['uniform', 'distance']}


hyperpar_selector = RandomizedSearchCV(my_pipeline, par, cv=3, scoring='accuracy', n_jobs=2, n_iter=20)


/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/cross_validation.py:44: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. Also note that the interface of the new CV iterators are different from that of this module. This module will be removed in 0.20.
  "This module will be removed in 0.20.", DeprecationWarning)
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/grid_search.py:43: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. This module will be removed in 0.20.
  DeprecationWarning)

E agora vamos treinar nosso algoritmo, usando o pipeline com seleção de atributos:


In [12]:
#print(hyperpar_selector)

hyperpar_selector.fit(X=x_data_train, y=y_data_train)


/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:242: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  Q = random_state.normal(size=(A.shape[1], size))
/media/fernando/DADOS/lib/anaconda3-lubuntu/lib/python3.6/site-packages/sklearn/utils/extmath.py:384: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  return V[:n_components, :].T, s[:n_components], U[:, :n_components].T
Out[12]:
RandomizedSearchCV(cv=3, error_score='raise',
          estimator=Pipeline(steps=[('tfidf', TfidfVectorizer(analyzer='word', binary=False, decode_error='strict',
        dtype=<class 'numpy.int64'>, encoding='utf-8', input='content',
        lowercase=True, max_df=1.0, max_features=None, min_df=1,
        ngram_range=(1, 1), norm='l2', preprocessor=None, smooth_idf=True,
 ...wski',
           metric_params=None, n_jobs=1, n_neighbors=10, p=2,
           weights='uniform'))]),
          fit_params={}, iid=True, n_iter=20, n_jobs=2,
          param_distributions={'clf__n_neighbors': range(1, 60), 'clf__weights': ['uniform', 'distance']},
          pre_dispatch='2*n_jobs', random_state=None, refit=True,
          scoring='accuracy', verbose=0)

In [13]:
print("Best score: %0.3f" % hyperpar_selector.best_score_)
print("Best parameters set:")
best_parameters = hyperpar_selector.best_estimator_.get_params()
for param_name in sorted(par.keys()):
    print("\t%s: %r" % (param_name, best_parameters[param_name]))


Best score: 0.635
Best parameters set:
	clf__n_neighbors: 3
	clf__weights: 'distance'

4. Testando o classificador

Agora vamos usar o classificador com o nosso dataset de testes, e observar os resultados:


In [14]:
from sklearn.metrics import *

y_pred = hyperpar_selector.predict(x_data_test)

print(accuracy_score(y_data_test, y_pred))


0.734375

5. Serializando o modelo


In [15]:
import pickle

string_obj = pickle.dumps(hyperpar_selector)

In [16]:
model_file = open('model.pkl', 'wb')

model_file.write(string_obj)

model_file.close()

6. Abrindo e usando um modelo salvo


In [17]:
model_file = open('model.pkl', 'rb')
model_content = model_file.read()

obj_classifier = pickle.loads(model_content)

model_file.close()

res = obj_classifier.predict(["what's up bro?"])

print(res)


[0]

In [18]:
res = obj_classifier.predict(x_data_test)
print(accuracy_score(y_data_test, res))


0.734375

In [19]:
res = obj_classifier.predict(x_data_test)

print(res)


[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1
 0 0 1 0 1 1 0 1 1 0 0 1 0 0 0 0 0 1 0 0 1 1 0 0 1 0 0 1 1 0 0 1 1 0 0 0 0
 0 0 0 0 1 0 0 0 0 1 1 0 0 1 1 1 1 1 1 1 1 1 0 0 0 1 0 0 0 1 0 1 0 0 1 0 1
 0 1 1 1 0 0 0]

In [20]:
formal = [x_data_test[i] for i in range(len(res)) if res[i] == 1]

for txt in formal:
    print("%s\n" % txt)


i already wrote what i wanted you to read.

Sorrow came -- a gentle sorrow -- but not at all in the shape of any disagreeable consciousness .-- Miss Taylor married .

I could not walk half so far ."

He will be able to tell her how we all are ."

Mr . Knightley had a cheerful manner , which always did him good ; and his many inquiries after " poor Isabella " and her children were answered most satisfactorily .

When this was over , Mr . Woodhouse gratefully observed , " It is very kind of you , Mr . Knightley , to come out at this late hour to call upon us .

" Well !

" By the bye -- I have not wished you joy .

" But , Mr . Knightley , she is really very sorry to lose poor Miss Taylor , and I am sure she _will_ miss her more than she thinks for ."

You made a lucky guess ; and _that_ is all that can be said ."

Poor Mr . Elton !

You like Mr . Elton , papa ,-- I must look about for a wife for him .

Captain Weston was a general favourite ; and when the chances of his military life had introduced him to Miss Churchill , of a great Yorkshire family , and Miss Churchill fell in love with him , nobody was surprized , except her brother and his wife , who had never seen him , and who were full of pride and importance , which the connexion would offend .

His coming to visit his father had been often talked of but never achieved .

" I suppose you have heard of the handsome letter Mr . Frank Churchill has written to Mrs . Weston ?

She knew that at times she must be missed ; and could not think , without pain , of Emma ' s losing a single pleasure , or suffering an hour ' s ennui , from the want of her companionableness : but dear Emma was of no feeble character ; she was more equal to her situation than most girls would have been , and had sense , and energy , and spirits that might be hoped would bear her well and happily through its little difficulties and privations .

She would be very glad to stay ."

Serle understands boiling an egg better than any body .

Two such could never be granted .

Her first attempts at usefulness were in an endeavour to find out who were the parents , but Harriet could not tell .

Mrs . Martin had told her one day ( and there was a blush as she said it ,) that it was impossible for any body to be a better son , and therefore she was sure , whenever he married , he would make a good husband .

Martin !"

Mrs . Goddard had dressed it on a Sunday , and asked all the three teachers , Miss Nash , and Miss Prince , and Miss Richardson , to sup with her ."

He does not read ?"

I thought him very plain at first , but I do not think him so plain now .

But did you never see him ?

He has passed you very often ."

" To be sure .

I know , indeed , that he is so , and , as such , wish him well .

Mr . Martin looked as if he did not know what manner was .

You might not see one in a hundred with _gentleman_ so plainly written as in Mr . Knightley .

" Will he , indeed ?

On the contrary , I think a young man might be very safely recommended to take Mr . Elton as a model .

She feared it was what every body else must think of and predict .

CHAPTER V

Emma must do Harriet good : and by supplying her with a new object of interest , Harriet may be said to do Emma good .

" There is hardly any desiring to refresh such a memory as _that_ ,"-- said Mr . Knightley , feelingly ; and for a moment or two he had done .


In [22]:
informal = [x_data_test[i] for i in range(len(res)) if res[i] == 0]

for txt in informal:
    print("%s\n" % txt)


10-19-20sUser7 is a gay name.

.ACTION gives 10-19-20sUser121 a golf clap.

:)

don't golf clap me.

fuck you 10-19-20sUser121:@

whats everyone up to?

PART

JOIN

ewwwww lol

r u serious

JOIN

I'll take one, please.

26/m

JOIN

JOIN

Anyone from Tennessee in here?

10-19-20sUser121 is missing a B in her name

and i don't complain about things being hard very often.

JOIN

PART

brb

JOIN

PART

hey any guys with cams wanna play?

hey 10-19-20sUser126

PART

what did you but on e-bay

yeee haw 10-19-20sUser30

wb 10-19-20sUser139

PART

you should make it 'iamahotnip', 10-19-20sUser44

hi 10-19-20sUser139.

ahah "iamahotniplickme"

Hi 10-19-20sUser121

10-19-20sUser136.. get the hell outta my freaking PM box.. Im with my fiance!!!!!!!!!!!!!!!!

I like it when you do it, 10-19-20sUser83

uh huh 

i have one already 10-19-20sUser7... yayayayayyy!!

OOooOO:)

'iamahotnipwithhotnippics

lmao!!!

I just laughed

finger?

10-19-20sUser141... get outta my PM Box.. didnt ya hear!!!!

you can forward the pervs to me.

yes 10-19-20sUser121??

aww 10-19-20sUser6 have fun

forwads away from 10-19-20sUser121

PART

what, 10-19-20sUser92.

beeehave

i love myself

girl jerks??

10-19-20sUser116

PART

Guess what

Hmm

aw 10-19-20sUser115 whys that

Your phone sexs is the best

I am ugly?

phone 10-19-20sUser92?

hmph.

10-19-20sUser6

lol 10-19-20sUser83

PART

JOIN

lets

woohoo!

JOIN

he's in PM land now though

ah ok

i wont bug em then

i need to go this summer.

LOL

K-Fed got his ass kicked.. Lol

.ACTION laughs.

i got a first class ticket to hell

lol 10-19-20sUser7

10-19-20sUser6

PART

yes 10-19-20sUser92???

Cum to my shower.

.ACTION 10-19-20sUser1370 watches ur nad with a stick.

PART

JOIN

PART

does anyone want to talk to me on the phone?  I don't charge

IL

.ACTION licks 10-19-20sUser92's neck.

Meep

.ACTION is resisting.

ur female right

lol 10-19-20sUser115

beeeeehave

no 

go wash your hands now!

1-900-anal-sex is 10-19-20sUser121's number

dang it. just as i predicted.  no one pm's me.

charge that is 1.99/min.

LOLOLOLLL 10-19-20sUser12

is like

no it's not 10-19-20sUser12, you shut yo mouth.

erm

10-19-20sUser23 how old r u

24  u

Mr . Weston was a man of unexceptionable character , easy fortune , suitable age , and pleasant manners ; and there was some satisfaction in considering with what self - denying , generous friendship she had always wished and promoted the match ; but it was a black morning ' s work for her .

The evil of the actual disparity in their ages ( and Mr . Woodhouse had not married early ) was much increased by his constitution and habits ; for having been a valetudinarian all his life , without activity of mind or body , he was a much older man in ways than in years ; and though everywhere beloved for the friendliness of his heart and his amiable temper , his talents could not have recommended him at any time .

" A house of her own !-- But where is the advantage of a house of her own ?

You got Hannah that good place .

Nobody thought of Hannah till you mentioned her -- James is so obliged to you !"

The backgammon - table was placed ; but a visitor immediately afterwards walked in and made it unnecessary .

It is a beautiful moonlight night ; and so mild that I must draw back from your great fire ."

" Especially when _one_ of those two is such a fanciful , troublesome creature !"

Oh no ; we all felt that we were going to be only half a mile apart , and were sure of meeting every day ."

" We should not like her so well as we do , sir , if we could suppose it ; but she knows how much the marriage is to Miss Taylor ' s advantage ; she knows how very acceptable it must be , at Miss Taylor ' s time of life , to be settled in a home of her own , and how important to her to be secure of a comfortable provision , and therefore cannot allow herself to feel so much pain as pleasure .

It is the greatest amusement in the world !

Some people even talked of a promise to his wife on her deathbed , and others of the son and the uncle not letting him .

All manner of solemn nonsense was talked on the subject , but I believed none of it .

What are you proud of ?

And as to my poor word ` success ,' which you quarrel with , I do not know that I am so entirely without any claim to it .

" A straightforward , open - hearted man like Weston , and a rational , unaffected woman like Miss Taylor , may be safely left to manage their own concerns .

" With a great deal of pleasure , sir , at any time ," said Mr . Knightley , laughing , " and I agree with you entirely , that it will be a much better thing .

Invite him to dinner , Emma , and help him to the best of the fish and the chicken , but leave him to chuse his own wife .

It was an unsuitable connexion , and did not produce much happiness .

Some scruples and some reluctance the widower - father may be supposed to have felt ; but as they were overcome by other considerations , the child was given up to the care and the wealth of the Churchills , and he had only his own comfort to seek , and his own situation to improve as he could .

Mr . Woodhouse saw the letter , and he says he never saw such a handsome letter in his life ."

It was , indeed , a highly prized letter .

With such an opinion , in confirmation of his own , Mr . Woodhouse hoped to influence every visitor of the newly married pair ; but still the cake was eaten ; and there was no rest for his benevolent nerves till it was all gone .

The simplicity and cheerfulness of her nature , her contented and grateful spirit , were a recommendation to every body , and a mine of felicity to herself .

It was no wonder that a train of twenty young couple now walked after her to church .

These were the ladies whom Emma found herself very frequently able to collect ; and happy was she , for her father ' s sake , in the power ; though , as far as she was herself concerned , it was no remedy for the absence of Mrs . Weston .

A very gracious invitation was returned , and the evening no longer dreaded by the fair mistress of the mansion .

Somebody had placed her , several years back , at Mrs . Goddard ' s school , and somebody had lately raised her from the condition of scholar to that of parlour - boarder .

She was so busy in admiring those soft blue eyes , in talking and listening , and forming all these schemes in the in - betweens , that the evening flew away at a very unusual rate ; and the supper - table , which always closed such parties , and for which she had been used to sit and watch the due time , was all set out and ready , and moved forwards to the fire , before she was aware .

Upon such occasions poor Mr . Woodhouses feelings were in sad warfare .

Ours are all apple - tarts .

A _small_ half - glass , put into a tumbler of water ?

Quick and decided in her ways , Emma lost no time in inviting , encouraging , and telling her to come very often ; and as their acquaintance increased , so did their satisfaction in each other .

Altogether she was quite convinced of Harriet Smith ' s being exactly the young friend she wanted -- exactly the something which her home required .

But the Martins occupied her thoughts a good deal ; she had spent two very happy months with them , and now loved to talk of the pleasures of her visit , and describe the many comforts and wonders of the place .

She was very fond of singing .

" I wish you may not get into a scrape , Harriet , whenever he does marry ;-- I mean , as to being acquainted with his wife -- for though his sisters , from a superior education , are not to be altogether objected to , it does not follow that he might marry any body at all fit for you to notice .

They met Mr . Martin the very next day , as they were walking on the Donwell road .

Emma was not sorry to have such an opportunity of survey ; and walking a few yards forward , while they talked together , soon made her quick eye sufficiently acquainted with Mr . Robert Martin .

They remained but a few minutes together , as Miss Woodhouse must not be kept waiting ; and Harriet then came running to her with a smiling face , and in a flutter of spirits , which Miss Woodhouse hoped very soon to compose .

He thought we walked towards Randalls most days .

I should be surprized if , after seeing them , you could be in company with Mr . Martin again without perceiving him to be a very inferior creature -- and rather wondering at yourself for having ever thought him at all agreeable before .

" There is no saying , indeed ," replied Harriet rather solemnly .

And I have no doubt that he _will_ thrive , and be a very rich man in time -- and his being illiterate and coarse need not disturb _us_ ."

They might be more safely held up as a pattern .

She thought it would be an excellent match ; and only too palpably desirable , natural , and probable , for her to have much merit in planning it .

The longer she considered it , the greater was her sense of its expediency .

" But I ," he soon added , " who have had no such charm thrown over my senses , must still see , hear , and remember .

At ten years old , she had the misfortune of being able to answer questions which puzzled her sister at seventeen .

In her mother she lost the only person able to cope with her .


In [21]:
res2 = obj_classifier.predict(["Emma spared no exertions to maintain this happier flow of ideas , and hoped , by the help of backgammon , to get her father tolerably through the evening , and be attacked by no regrets but her own"])

print(res2)


[1]

In [ ]: