Archivo de pruebas, se muestran reportes de matriz de confusión para distintos clasificadores

parent 5305f943
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import re\n",
"from nltk.corpus import stopwords\n",
"import csv, operator\n",
"import pickle\n",
"from wordcloud import WordCloud\n",
"import matplotlib.pyplot as plt\n",
"import string\n",
"from collections import Counter\n",
"import numpy as np\n",
"from sklearn.feature_extraction.text import CountVectorizer \n",
"from sklearn.neighbors import KNeighborsClassifier\n",
"from sklearn import svm\n",
"from sklearn.naive_bayes import MultinomialNB\n",
"from sklearn.ensemble import RandomForestClassifier\n",
"from sklearn.feature_extraction.text import TfidfTransformer\n",
"from sklearn.metrics import classification_report, confusion_matrix, accuracy_score\n",
"\n",
"\n",
"def limpiartexto(s):\n",
" s = re.sub(r\"[,|\\.|:|;|?|=|​|\\n|<|>|\\-|“|”|–]\", ' ', s)\n",
" s = s.lower()\n",
" s = ' '.join([word for word in s.split() if word not in stopwords.words('spanish')])\n",
" return s\n",
"\n",
"path = './Train/' #Carpeta donde se encuentran los archivos de TRAIN\n",
"\n",
"with open(path + 'cultura_new.csv') as csvdata: \n",
" dataCultura = pd.DataFrame(csv.DictReader(csvdata))\n",
"with open(path + 'espectaculos_new.csv') as csvdata: \n",
" dataEspectaculos = pd.DataFrame(csv.DictReader(csvdata))\n",
"with open(path + 'deportes_new.csv') as csvdata: \n",
" dataDeportes = pd.DataFrame(csv.DictReader(csvdata))\n",
"with open(path + 'politica_new.csv') as csvdata: \n",
" dataPolitica = pd.DataFrame(csv.DictReader(csvdata))\n",
"with open(path + 'TrainPolitica.csv') as csvdata: \n",
" dataPolitica = pd.DataFrame(csv.DictReader(csvdata))"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
"data_ciencia = []\n",
"target_ciencia = []\n",
"targetname_ciencia = []\n",
"for reg in range(len(dataCiencia)):\n",
" data_ciencia.append(limpiartexto(dataCiencia['NOTA'][reg]))\n",
" target_ciencia.append(0)\n",
" targetname_ciencia.append('CIENCIA')\n",
"\n",
"data_cultura = []\n",
"target_cultura = []\n",
"targetname_cultura = []\n",
"for reg in range(len(dataCultura)):\n",
" data_cultura.append(limpiartexto(dataCultura['NOTA'][reg]))\n",
" target_cultura.append(0)\n",
" targetname_cultura.append('CULTURA')\n",
"\n",
"data_deportes = []\n",
"target_deportes = []\n",
"targetname_deportes = []\n",
"for reg in range(len(dataDeportes)):\n",
" data_deportes.append(limpiartexto(dataDeportes['NOTA'][reg]))\n",
" target_deportes.append(1)\n",
" targetname_deportes.append('DEPORTES')\n",
"\n",
"data_espectaculos = []\n",
"target_espectaculos = []\n",
"targetname_espectaculos = []\n",
"for reg in range(len(dataEspectaculos)):\n",
" data_espectaculos.append(limpiartexto(dataEspectaculos['NOTA'][reg]))\n",
" target_espectaculos.append(2)\n",
" targetname_espectaculos.append('ESPECTACULOS')\n",
"\n",
"data_politica = []\n",
"target_politica = []\n",
"targetname_politica = []\n",
"for reg in range(len(dataPolitica)):\n",
" data_politica.append(limpiartexto(dataPolitica['NOTA'][reg]))\n",
" target_politica.append(3)\n",
" targetname_politica.append('POLITICA')\n",
" \n",
"data = data_ciencia + data_cultura + data_deportes + data_espectaculos + data_politica \n",
"target = target_ciencia + target_cultura + target_deportes + target_espectaculos + target_politica\n",
"target_names = targetname_ciencia + targetname_cultura + targetname_deportes + targetname_espectaculos + targetname_politica\n",
"\n",
"news = np.array([data_news, target_news, target_names_news]).T\n",
"pd_news = pd_news[pd_news.data_news == pd_news.data_news] ####verifica que la nota no sea NaN\n",
"pd_news = pd.DataFrame(news, columns=['data_news','target_news','target_names_news']).sample(len(news))"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"predict knn = [0, 0, 2, 4, 4, 4, 2, 3, 0, 1, 3, 0, 3, 4, 4, 1, 0, 3, 3, 0, 3, 0, 2, 4, 4, 0, 2, 3, 4, 2]\n",
"predict svm = [1, 0, 2, 4, 4, 4, 2, 3, 1, 3, 1, 0, 3, 4, 4, 1, 0, 3, 3, 0, 3, 0, 2, 4, 4, 0, 2, 3, 4, 2]\n",
"test target = [1, 3, 2, 4, 4, 4, 2, 3, 1, 3, 3, 0, 1, 4, 4, 3, 0, 3, 3, 0, 3, 0, 2, 4, 4, 0, 2, 3, 4, 2]\n",
"confusion_matrix=\n",
" [[5 0 0 0 0]\n",
" [0 2 0 1 0]\n",
" [0 0 5 0 0]\n",
" [1 2 0 6 0]\n",
" [0 0 0 0 8]]\n",
"Resultados de la clasificación=\n",
" precision recall f1-score support\n",
"\n",
" 0 0.83 1.00 0.91 5\n",
" 1 0.50 0.67 0.57 3\n",
" 2 1.00 1.00 1.00 5\n",
" 3 0.86 0.67 0.75 9\n",
" 4 1.00 1.00 1.00 8\n",
"\n",
" micro avg 0.87 0.87 0.87 30\n",
" macro avg 0.84 0.87 0.85 30\n",
"weighted avg 0.88 0.87 0.87 30\n",
"\n",
"acc_score= 0.8666666666666667\n"
]
}
],
"source": [
"pd_news = pd.read_csv('./noticias_train.csv')\n",
"pd_news = pd_news.sample(len(pd_news))\n",
"\n",
"\n",
"train = pd_news.data_news[:-30]\n",
"train_target = pd_news.target_news[:-30]\n",
"test = pd_news.data_news[-30:]\n",
"test_target = pd_news.target_news[-30:]\n",
"\n",
"##################TRAIN###################\n",
"count_vect = CountVectorizer()\n",
"train_vect = count_vect.fit_transform(train)\n",
"tfidf_transformer = TfidfTransformer()\n",
"train_tfidf = tfidf_transformer.fit_transform(train_vect)\n",
"#################TEST######################\n",
"test_vect = count_vect.transform(test)\n",
"test_tfidf = tfidf_transformer.transform(test_vect)\n",
"\n",
"clf_knn = KNeighborsClassifier(n_neighbors=8)\n",
"clf_mNB = MultinomialNB()\n",
"clf_svm = svm.SVC(gamma='scale')\n",
"clf_RFC = RandomForestClassifier(n_estimators=100)\n",
"clf_knn.fit(train_tfidf, train_target)\n",
"clf_mNB.fit(train_tfidf, train_target)\n",
"clf_svm.fit(train_tfidf, train_target)\n",
"clf_RFC.fit(train_tfidf, train_target)\n",
"###############PREDICT################\n",
"predict_knn = list(clf_knn.predict(test_tfidf))\n",
"predict_mNB = list(clf_mNB.predict(test_tfidf))\n",
"predict_svm = list(clf_svm.predict(test_tfidf))\n",
"predict_RFC = list(clf_RFC.predict(test_tfidf))\n",
"\n",
"print('predict knn =', predict_knn)\n",
"print('predict mNB =', predict_mNB)\n",
"print('predict svm =', predict_svm)\n",
"print('predict RFC =', predict_RFC)\n",
"print('test target =', list(test_target))\n",
"print(set(zip(target_news, target_names_news)))\n",
"\n",
"print('confusion_matrix=\\n', confusion_matrix(test_target,predict_svm)) \n",
"print('Resultados de la clasificación=\\n', classification_report(test_target,predict_svm)) \n",
"print('acc_score=', accuracy_score(test_target, predict_svm))\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>0</th>\n",
" <th>1</th>\n",
" <th>2</th>\n",
" <th>3</th>\n",
" <th>4</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>4</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>0</td>\n",
" <td>6</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>4</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>6</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>8</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" 0 1 2 3 4\n",
"0 4 0 0 0 0\n",
"1 0 6 0 0 0\n",
"2 0 0 4 0 0\n",
"3 0 1 0 6 0\n",
"4 0 0 1 0 8"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pd.DataFrame(confusion_matrix(test_target,predict_knn)) "
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>data_news</th>\n",
" <th>target_news</th>\n",
" <th>target_names_news</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>84</th>\n",
" <td>partido directo mantener categoría puerto vera...</td>\n",
" <td>1</td>\n",
" <td>DEPORTES</td>\n",
" </tr>\n",
" <tr>\n",
" <th>76</th>\n",
" <td>sevilla sacó ventaja ausencia lionel messi ven...</td>\n",
" <td>1</td>\n",
" <td>DEPORTES</td>\n",
" </tr>\n",
" <tr>\n",
" <th>104</th>\n",
" <td>junto gobernador alejandro moreno cárdens espo...</td>\n",
" <td>2</td>\n",
" <td>ESPECTACULOS</td>\n",
" </tr>\n",
" <tr>\n",
" <th>100</th>\n",
" <td>ciclismo quedó luto octubre empañarse gran fon...</td>\n",
" <td>1</td>\n",
" <td>DEPORTES</td>\n",
" </tr>\n",
" <tr>\n",
" <th>121</th>\n",
" <td>feria nacional libro infantil juvenil morelos ...</td>\n",
" <td>2</td>\n",
" <td>ESPECTACULOS</td>\n",
" </tr>\n",
" <tr>\n",
" <th>61</th>\n",
" <td>[email protected] años edad francisco vargas p...</td>\n",
" <td>1</td>\n",
" <td>DEPORTES</td>\n",
" </tr>\n",
" <tr>\n",
" <th>53</th>\n",
" <td>cruz azul salir mercado adquirir suplente iván...</td>\n",
" <td>1</td>\n",
" <td>DEPORTES</td>\n",
" </tr>\n",
" <tr>\n",
" <th>159</th>\n",
" <td>nueva york jugando afirmó donald trump ayer ju...</td>\n",
" <td>3</td>\n",
" <td>POLITICA</td>\n",
" </tr>\n",
" <tr>\n",
" <th>13</th>\n",
" <td>gentrificación desalojos fenómenos víctimas pe...</td>\n",
" <td>0</td>\n",
" <td>CULTURA</td>\n",
" </tr>\n",
" <tr>\n",
" <th>30</th>\n",
" <td>museo palacio bellas artes continúa actividade...</td>\n",
" <td>0</td>\n",
" <td>CULTURA</td>\n",
" </tr>\n",
" <tr>\n",
" <th>154</th>\n",
" <td>coordinadora nacional trabajadores educación c...</td>\n",
" <td>3</td>\n",
" <td>POLITICA</td>\n",
" </tr>\n",
" <tr>\n",
" <th>65</th>\n",
" <td>cruz azul buscará primer triunfo torneo améric...</td>\n",
" <td>1</td>\n",
" <td>DEPORTES</td>\n",
" </tr>\n",
" <tr>\n",
" <th>27</th>\n",
" <td>hace tiempo méxico veía exhibición arte griego...</td>\n",
" <td>0</td>\n",
" <td>CULTURA</td>\n",
" </tr>\n",
" <tr>\n",
" <th>120</th>\n",
" <td>actor héctor bonilla guionista alicia garciadi...</td>\n",
" <td>2</td>\n",
" <td>ESPECTACULOS</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>[email protected] colección arte pinos conform...</td>\n",
" <td>0</td>\n",
" <td>CULTURA</td>\n",
" </tr>\n",
" <tr>\n",
" <th>23</th>\n",
" <td>inicia 2019 podrás alimentar agenda cultural p...</td>\n",
" <td>0</td>\n",
" <td>CULTURA</td>\n",
" </tr>\n",
" <tr>\n",
" <th>158</th>\n",
" <td>presidente junta coordinación política cámara ...</td>\n",
" <td>3</td>\n",
" <td>POLITICA</td>\n",
" </tr>\n",
" <tr>\n",
" <th>16</th>\n",
" <td>noche miércoles museos capitalinos turistas po...</td>\n",
" <td>0</td>\n",
" <td>CULTURA</td>\n",
" </tr>\n",
" <tr>\n",
" <th>49</th>\n",
" <td>[email protected] pies futbolista pueden hacer...</td>\n",
" <td>1</td>\n",
" <td>DEPORTES</td>\n",
" </tr>\n",
" <tr>\n",
" <th>131</th>\n",
" <td>[email protected] elba esther gordillo morales...</td>\n",
" <td>3</td>\n",
" <td>POLITICA</td>\n",
" </tr>\n",
" <tr>\n",
" <th>103</th>\n",
" <td>organizador enrique moreno pajarito confía con...</td>\n",
" <td>2</td>\n",
" <td>ESPECTACULOS</td>\n",
" </tr>\n",
" <tr>\n",
" <th>135</th>\n",
" <td>bancada partido trabajo calificó equivocación ...</td>\n",
" <td>3</td>\n",
" <td>POLITICA</td>\n",
" </tr>\n",
" <tr>\n",
" <th>34</th>\n",
" <td>katia rejón foto @museo_macay jornada maya mér...</td>\n",
" <td>0</td>\n",
" <td>CULTURA</td>\n",
" </tr>\n",
" <tr>\n",
" <th>54</th>\n",
" <td>presidente estadounidense donald trump recibió...</td>\n",
" <td>1</td>\n",
" <td>DEPORTES</td>\n",
" </tr>\n",
" <tr>\n",
" <th>41</th>\n",
" <td>valladolid yucatán enero promoviendo expresion...</td>\n",
" <td>0</td>\n",
" <td>CULTURA</td>\n",
" </tr>\n",
" <tr>\n",
" <th>156</th>\n",
" <td>concluir nueva reunión titular secretaría educ...</td>\n",
" <td>3</td>\n",
" <td>POLITICA</td>\n",
" </tr>\n",
" <tr>\n",
" <th>80</th>\n",
" <td>boca veracruz puntos distancia puebla tabla co...</td>\n",
" <td>1</td>\n",
" <td>DEPORTES</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>años creación cumplen febrero instituto nacion...</td>\n",
" <td>0</td>\n",
" <td>CULTURA</td>\n",
" </tr>\n",
" <tr>\n",
" <th>88</th>\n",
" <td>actor daniel radcliffe interpreta harry potter...</td>\n",
" <td>1</td>\n",
" <td>DEPORTES</td>\n",
" </tr>\n",
" <tr>\n",
" <th>86</th>\n",
" <td>milagro gulfstream park florida caballo mexica...</td>\n",
" <td>1</td>\n",
" <td>DEPORTES</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>74</th>\n",
" <td>gran indignación causado mundo deporte divulga...</td>\n",
" <td>1</td>\n",
" <td>DEPORTES</td>\n",
" </tr>\n",
" <tr>\n",
" <th>73</th>\n",
" <td>luisa defendió liga pesar serie escándalos imp...</td>\n",
" <td>1</td>\n",
" <td>DEPORTES</td>\n",
" </tr>\n",
" <tr>\n",
" <th>60</th>\n",
" <td>mexicana linda ochoa anunció redes sociales ab...</td>\n",
" <td>1</td>\n",
" <td>DEPORTES</td>\n",
" </tr>\n",
" <tr>\n",
" <th>26</th>\n",
" <td>ballet folklórico amalia hernández proyectos i...</td>\n",
" <td>0</td>\n",
" <td>CULTURA</td>\n",
" </tr>\n",
" <tr>\n",
" <th>128</th>\n",
" <td>méxico ratificó unidos negativa convertirse te...</td>\n",
" <td>3</td>\n",
" <td>POLITICA</td>\n",
" </tr>\n",
" <tr>\n",
" <th>15</th>\n",
" <td>convocatoria otorgamiento becas international ...</td>\n",
" <td>0</td>\n",
" <td>CULTURA</td>\n",
" </tr>\n",
" <tr>\n",
" <th>25</th>\n",
" <td>2019 damaris disner fusionará grandes pasiones...</td>\n",
" <td>0</td>\n",
" <td>CULTURA</td>\n",
" </tr>\n",
" <tr>\n",
" <th>140</th>\n",
" <td>dirección política coordinadora nacional traba...</td>\n",
" <td>3</td>\n",
" <td>POLITICA</td>\n",
" </tr>\n",
" <tr>\n",
" <th>118</th>\n",
" <td>realizador mexicano alfonso cuarón ganó oscar ...</td>\n",
" <td>2</td>\n",
" <td>ESPECTACULOS</td>\n",
" </tr>\n",
" <tr>\n",
" <th>138</th>\n",
" <td>redes sociales progresistas arrancó aquí proce...</td>\n",
" <td>3</td>\n",
" <td>POLITICA</td>\n",
" </tr>\n",
" <tr>\n",
" <th>48</th>\n",
" <td>guadalajara regresa televisión abierta chivas ...</td>\n",
" <td>1</td>\n",
" <td>DEPORTES</td>\n",
" </tr>\n",
" <tr>\n",
" <th>105</th>\n",
" <td>reina mexicana belleza kristal silva presentad...</td>\n",
" <td>2</td>\n",
" <td>ESPECTACULOS</td>\n",
" </tr>\n",
" <tr>\n",
" <th>146</th>\n",
" <td>magisterio disidente rechazó dictamen aprobado...</td>\n",
" <td>3</td>\n",
" <td>POLITICA</td>\n",
" </tr>\n",
" <tr>\n",
" <th>56</th>\n",
" <td>mediocentro portugués stephen eustáquio llegó ...</td>\n",
" <td>1</td>\n",
" <td>DEPORTES</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>director general bibliotecas marx arriaga info...</td>\n",
" <td>0</td>\n",
" <td>CULTURA</td>\n",
" </tr>\n",
" <tr>\n",
" <th>126</th>\n",
" <td>ahora trabajo reconocimiento extranjero hace s...</td>\n",
" <td>2</td>\n",
" <td>ESPECTACULOS</td>\n",
" </tr>\n",
" <tr>\n",
" <th>130</th>\n",
" <td>titular secretaría educación pública esteban m...</td>\n",
" <td>3</td>\n",
" <td>POLITICA</td>\n",
" </tr>\n",
" <tr>\n",
" <th>119</th>\n",
" <td>aunque nominada diez categorías entrega premio...</td>\n",
" <td>2</td>\n",
" <td>ESPECTACULOS</td>\n",
" </tr>\n",
" <tr>\n",
" <th>109</th>\n",
" <td>ariel avilés marín 1970 1971 marcado vida méxi...</td>\n",
" <td>2</td>\n",
" <td>ESPECTACULOS</td>\n",
" </tr>\n",
" <tr>\n",
" <th>85</th>\n",
" <td>rocky filmó 1985 película rocky balboa vencía ...</td>\n",
" <td>1</td>\n",
" <td>DEPORTES</td>\n",
" </tr>\n",
" <tr>\n",
" <th>87</th>\n",
" <td>semana tras semana temporada regular futbol am...</td>\n",
" <td>1</td>\n",
" <td>DEPORTES</td>\n",
" </tr>\n",
" <tr>\n",
" <th>95</th>\n",
" <td>cristian insaurralde cerrojo ciclo jugador águ...</td>\n",
" <td>1</td>\n",
" <td>DEPORTES</td>\n",
" </tr>\n",
" <tr>\n",
" <th>51</th>\n",
" <td>[email protected] manny pacquiao regresa años ...</td>\n",
" <td>1</td>\n",
" <td>DEPORTES</td>\n",
" </tr>\n",
" <tr>\n",
" <th>136</th>\n",
" <td>coordinadores parlamentarios oposición cámara ...</td>\n",
" <td>3</td>\n",
" <td>POLITICA</td>\n",
" </tr>\n",
" <tr>\n",
" <th>66</th>\n",
" <td>race champions solo carrera exhibición papel c...</td>\n",
" <td>1</td>\n",
" <td>DEPORTES</td>\n",
" </tr>\n",
" <tr>\n",
" <th>28</th>\n",
" <td>mérida enero 2019 compromiso afianzar sinergia...</td>\n",
" <td>0</td>\n",
" <td>CULTURA</td>\n",
" </tr>\n",
" <tr>\n",
" <th>32</th>\n",
" <td>petición ciudadanía ayer regresaron centro ciu...</td>\n",
" <td>0</td>\n",
" <td>CULTURA</td>\n",
" </tr>\n",
" <tr>\n",
" <th>132</th>\n",
" <td>dirigentes coordinadora nacional trabajadores ...</td>\n",
" <td>3</td>\n",
" <td>POLITICA</td>\n",
" </tr>\n",
" <tr>\n",
" <th>67</th>\n",
" <td>pilotos participarán trigésima edición race ch...</td>\n",
" <td>1</td>\n",
" <td>DEPORTES</td>\n",
" </tr>\n",
" <tr>\n",
" <th>94</th>\n",
" <td>[email protected] pasado condiciones agua albe...</td>\n",
" <td>1</td>\n",
" <td>DEPORTES</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>161 rows × 3 columns</p>\n",
"</div>"
],
"text/plain": [
" data_news target_news \\\n",
"84 partido directo mantener categoría puerto vera... 1 \n",
"76 sevilla sacó ventaja ausencia lionel messi ven... 1 \n",
"104 junto gobernador alejandro moreno cárdens espo... 2 \n",
"100 ciclismo quedó luto octubre empañarse gran fon... 1 \n",
"121 feria nacional libro infantil juvenil morelos ... 2 \n",
"61 [email protected] años edad francisco vargas p... 1 \n",
"53 cruz azul salir mercado adquirir suplente iván... 1 \n",
"159 nueva york jugando afirmó donald trump ayer ju... 3 \n",
"13 gentrificación desalojos fenómenos víctimas pe... 0 \n",
"30 museo palacio bellas artes continúa actividade... 0 \n",
"154 coordinadora nacional trabajadores educación c... 3 \n",
"65 cruz azul buscará primer triunfo torneo améric... 1 \n",
"27 hace tiempo méxico veía exhibición arte griego... 0 \n",
"120 actor héctor bonilla guionista alicia garciadi... 2 \n",
"7 [email protected] colección arte pinos conform... 0 \n",
"23 inicia 2019 podrás alimentar agenda cultural p... 0 \n",
"158 presidente junta coordinación política cámara ... 3 \n",
"16 noche miércoles museos capitalinos turistas po... 0 \n",
"49 [email protected] pies futbolista pueden hacer... 1 \n",
"131 [email protected] elba esther gordillo morales... 3 \n",
"103 organizador enrique moreno pajarito confía con... 2 \n",
"135 bancada partido trabajo calificó equivocación ... 3 \n",
"34 katia rejón foto @museo_macay jornada maya mér... 0 \n",
"54 presidente estadounidense donald trump recibió... 1 \n",
"41 valladolid yucatán enero promoviendo expresion... 0 \n",
"156 concluir nueva reunión titular secretaría educ... 3 \n",
"80 boca veracruz puntos distancia puebla tabla co... 1 \n",
"4 años creación cumplen febrero instituto nacion... 0 \n",
"88 actor daniel radcliffe interpreta harry potter... 1 \n",
"86 milagro gulfstream park florida caballo mexica... 1 \n",
".. ... ... \n",
"74 gran indignación causado mundo deporte divulga... 1 \n",
"73 luisa defendió liga pesar serie escándalos imp... 1 \n",
"60 mexicana linda ochoa anunció redes sociales ab... 1 \n",
"26 ballet folklórico amalia hernández proyectos i... 0 \n",
"128 méxico ratificó unidos negativa convertirse te... 3 \n",
"15 convocatoria otorgamiento becas international ... 0 \n",
"25 2019 damaris disner fusionará grandes pasiones... 0 \n",
"140 dirección política coordinadora nacional traba... 3 \n",
"118 realizador mexicano alfonso cuarón ganó oscar ... 2 \n",
"138 redes sociales progresistas arrancó aquí proce... 3 \n",
"48 guadalajara regresa televisión abierta chivas ... 1 \n",
"105 reina mexicana belleza kristal silva presentad... 2 \n",
"146 magisterio disidente rechazó dictamen aprobado... 3 \n",
"56 mediocentro portugués stephen eustáquio llegó ... 1 \n",
"6 director general bibliotecas marx arriaga info... 0 \n",
"126 ahora trabajo reconocimiento extranjero hace s... 2 \n",
"130 titular secretaría educación pública esteban m... 3 \n",
"119 aunque nominada diez categorías entrega premio... 2 \n",
"109 ariel avilés marín 1970 1971 marcado vida méxi... 2 \n",
"85 rocky filmó 1985 película rocky balboa vencía ... 1 \n",
"87 semana tras semana temporada regular futbol am... 1 \n",
"95 cristian insaurralde cerrojo ciclo jugador águ... 1 \n",
"51 [email protected] manny pacquiao regresa años ... 1 \n",
"136 coordinadores parlamentarios oposición cámara ... 3 \n",
"66 race champions solo carrera exhibición papel c... 1 \n",
"28 mérida enero 2019 compromiso afianzar sinergia... 0 \n",
"32 petición ciudadanía ayer regresaron centro ciu... 0 \n",
"132 dirigentes coordinadora nacional trabajadores ... 3 \n",
"67 pilotos participarán trigésima edición race ch... 1 \n",
"94 [email protected] pasado condiciones agua albe... 1 \n",
"\n",
" target_names_news \n",
"84 DEPORTES \n",
"76 DEPORTES \n",
"104 ESPECTACULOS \n",
"100 DEPORTES \n",
"121 ESPECTACULOS \n",
"61 DEPORTES \n",
"53 DEPORTES \n",
"159 POLITICA \n",
"13 CULTURA \n",
"30 CULTURA \n",
"154 POLITICA \n",
"65 DEPORTES \n",
"27 CULTURA \n",
"120 ESPECTACULOS \n",
"7 CULTURA \n",
"23 CULTURA \n",
"158 POLITICA \n",
"16 CULTURA \n",
"49 DEPORTES \n",
"131 POLITICA \n",
"103 ESPECTACULOS \n",
"135 POLITICA \n",
"34 CULTURA \n",
"54 DEPORTES \n",
"41 CULTURA \n",
"156 POLITICA \n",
"80 DEPORTES \n",
"4 CULTURA \n",
"88 DEPORTES \n",
"86 DEPORTES \n",
".. ... \n",
"74 DEPORTES \n",
"73 DEPORTES \n",
"60 DEPORTES \n",
"26 CULTURA \n",
"128 POLITICA \n",
"15 CULTURA \n",
"25 CULTURA \n",
"140 POLITICA \n",
"118 ESPECTACULOS \n",
"138 POLITICA \n",
"48 DEPORTES \n",
"105 ESPECTACULOS \n",
"146 POLITICA \n",
"56 DEPORTES \n",
"6 CULTURA \n",
"126 ESPECTACULOS \n",
"130 POLITICA \n",
"119 ESPECTACULOS \n",
"109 ESPECTACULOS \n",
"85 DEPORTES \n",
"87 DEPORTES \n",
"95 DEPORTES \n",
"51 DEPORTES \n",
"136 POLITICA \n",
"66 DEPORTES \n",
"28 CULTURA \n",
"32 CULTURA \n",
"132 POLITICA \n",
"67 DEPORTES \n",
"94 DEPORTES \n",
"\n",
"[161 rows x 3 columns]"
]
},
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pd_news"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment