Está en la página 1de 19

Maestría Ciencia de datos y análisis de datos

masivos Big Data

Equipo
Magdaleno Arroyo Dulce María
000-00- 4830

Niño Peña Christiam Alejandro


000-00- 5220

Cuellar Perez Lina Marcela


000-00- 5204

2.2 Practica. Análisis, implementación y evaluación


de Sentimientos en la Red Social Twitter Utilizando
Python

Unidad 2

Dr Humberto Muñoz Bautista


25 de junio de 2023
INTRODUCCIÓN
El análisis de sentimientos en Twitter es un proceso que permite determinar la
polaridad emocional respecto a los mensajes publicados en dicha plataforma, esto
quiere decir, si un tweet expresa sentimientos positivos, negativos o neutrales.
Esta información puede ser relevante o valiosa si se quiere detectar tendencias,
comprender la opinión del público, analizar los mercados, evaluar la satisfacción
del cliente entré otros

Por esta razón el propósito de esta actividad fue realizar un análisis de


sentimientos usando para ello el lenguaje de programación Python y la técnica de
scraping la cual se utiliza para extraer información de sitios web de manera
automatizada.

DESARROLLO
Python siendo un lenguaje de programación versátil y muy popular proporciona
una gama amplia de herramientas y bibliotecas que se utilizan para este análisis
de sentimientos, utilizando Twitter entre las cuales se incluyen: Tweepy: Biblioteca
de Python que facilita la interacción con la API de Twitter para recopilar tweets y
realizar consultas en tiempo real. TextBlob: Es una biblioteca que utiliza NLTK
para realizar análisis de sentimientos en texto. Ofrece una interfaz sencilla para
calcular la polaridad y la subjetividad de un texto. (Loria, 2020).

Primera fase: Se detectaron patrones relacionados con el análisis de sentimientos


en la red social Twitter importando las bibliotecas necesarias (ver figura 1),
snscrape.modules.twitter para realizar la búsqueda de tweets en la red social
Twitter y TextBlob que facilita el procesamiento y análisis de texto, permitiendo
trabajar con texto de manera más eficiente y accesible, por lo cual es usada en
modelos de aprendizaje automático entrenados en grandes conjuntos de datos
para asignar una polaridad (positiva, negativa o neutra) y una subjetividad a un
texto determinado (Loria, 2020; TextBlob, 2021).
Figura 1. Fase inicial del estudio de sentimientos en la red social Twitter por la palabra "Python"
Segunda fase: Se definió la función analyze_sentiment que utiliza TextBlob para
analizar el sentimiento de un texto (en este caso, un tweet) y a partir de esta se
realizó una búsqueda de tweets utilizando Snscrape y almacenando los textos de
los tweets en una lista (Anexo a) (figura 2).

Figura 2. Fase de búsqueda de tweets para el estudio de sentimientos en la red social Twitter por la palabra "Python"

Tercera fase: sobre la lista de tweets se analizó el sentimiento de cada uno


utilizando la función analyze_sentiment y se mostraron los resultados (figura 3)
Figura 3. Fase de análisis de sentimientos en la red social Twitter por la palabra "Python"

Cuarta Fase: Después de analizar el sentimiento de cada tweet, se realizó el


conteo de tweets positivos, neutros y negativos utilizando el método count() de las
listas, para luego, crear un gráfico de barras utilizando Matplotlib, donde en el eje x
se muestran las etiquetas de sentimiento y en el eje y se muestra la cantidad de
tweets correspondiente (figura 4).

Figura 4. Fase de presentación de resultados del estudio de sentimientos de la palabra "Python" en la red social Twitter
Lectura de resultados

En el estudio de sentimientos realizado sobre la palabra "Python" en la red social


Twitter, se analizaron un total de 1000 tweets. De estos, se encontró que 302
tweets fueron clasificados como positivos, 126 como negativos, mientras que el
resto se consideraron neutros. Estos resultados indican que la mayoría de los
tweets analizados en relación a "Python" tuvieron una connotación positiva,
seguidos por una proporción menor de tweets negativos, mientras que un número
significativo se consideró neutro en términos de sentimiento. Vale la pena destacar
que estos resultados se obtuvieron a partir del análisis de una muestra específica
de tweets y pueden no representar la totalidad de las opiniones o sentimientos
asociados a la palabra "Python" en la plataforma de Twitter en su conjunto.

Estos hallazgos proporcionan una visión general de la percepción de los usuarios


de Twitter hacia "Python" y podrían ser útiles para comprender las tendencias y la
opinión pública relacionada con el tema en particular, objeto de estudio.
CONCLUSIÓN

Basado en los resultados obtenidos en el estudio de sentimientos de la palabra


"Python" en la red social Twitter utilizando la técnica de scraping y la biblioteca
TextBlob de Python, se pueden obtener algunas conclusiones, sin embargo, por
su relevancia se puede observar que la mayoría de los tweets analizados
relacionados con "Python" fueron clasificados como positivos, sugiriendo que hay
una percepción generalmente favorable hacia el lenguaje de programación en la
comunidad de usuarios de Twitter, la cual podría deberse a las características y
ventajas asociadas con Python, como su legibilidad, versatilidad y amplio uso en
diversos campos como el desarrollo web, la ciencia de datos y la inteligencia
artificial.

En términos generales, el uso de la técnica de scraping junto con la biblioteca


TextBlob de Python permitió obtener para este caso información sobre el
sentimiento asociado a la palabra "Python" en Twitter. Estos resultados pueden
ser útiles para comprender la opinión pública, identificar tendencias y evaluar la
recepción de "Python" en la comunidad de usuarios de esta red social. Sin
embargo, es importante tener en cuenta las limitaciones del estudio, como el
tamaño de la muestra y la naturaleza dinámica de los sentimientos en las redes
sociales.
REFERENCIAS

Loria, S. (2020), TextBlob: Simplified Text Processing, recuperado,


https://textblob.readthedocs.io/en/latest

TextBlob. (2021). [Computer software]. Recuperado de


https://textblob.readthedocs.io/
ANEXO (a)

Muestra: Listado de Tweets analizados

Tweet: @Cazzi83 @AugustaLees @guardian 😂😂😂😂 Jesus, I've stumbled on an

episode of Monty Python that was lost! Who are they trying to kid? Bloody hell!! 🙈
Sentimiento: negativo

Tweet: @usa_usa0427 おはようございます(゚▽゚)/


Sentimiento: neutro

Tweet: @pasochkapan Наприклад?


Sentimiento: neutro

Tweet: Le conseil que j'aurais aimé qu'on me donne :

1. N'entrez pas dans la tech sans emploi, se former peut coûter cher.

2. Ne vous précipitez pas :


"Apprenez Python en une semaine"
La syntaxe oui, mais vous ne saurez résoudre aucun problème.
Sentimiento: neutro

Tweet: @ogu_olivia Data analysis is for you. Just follow this steps Sha so you
won't be overwhelmed
Power bi
Tableau
SQL
R
Python
Sentimiento: neutro

Tweet: @timokonkwo_ I'd appreciate if you could post internship opportunities for
python devs at for a least once
Sentimiento: negativo

Tweet: @ExJohnHonestyy I’m at a loss for words man how can someone be THIS
bad
Sentimiento: negativo

Tweet: @hashimoto_0522 橋本さんおはようございます

繁殖して皆さんに配りますね🤣
Sentimiento: neutro
Tweet: @s_sayaka1105 おはようございます(゚▽゚)/
Sentimiento: neutro

Tweet: @6F0project @PicturesFoIder Monty Python comedy was completely


overrated by stoned teenage boys of the 70s.
Sentimiento: positivo

Tweet: @FanBushranger @KLtweeet @python_fili @Cobratate A video of the


suspect admitting to his crimes and explaining how he did it, in detail, and teaching
others how to do it, released in a time before deepfakes could be a valid
explanation for it being fake, is like a prosecutor’s wet dream. I mean seriously
what is wrong with you
Sentimiento: negativo

Tweet: Right from the very first minute that I ever laid my eyes upon Tobias during
last year's preseason, I swear to god I just knew I was witnessing the worst right
back EVER

This guy legit plays like Jonathan Woodgate with potatoes up his buttcrack
https://t.co/NZWpXzUjJK
Sentimiento: negativo

Tweet: いつも思うけど、バイクにしても車にしても MT とかの集まりきて端っこ


でスマホ触り続けてる子って何しに来てるん😹
前は『カスタムを学びに集まり来てる』が多かった気がするけど
今は『(承認欲求満たすために)見せに集まり来てる』って感じする
当然後者の方はスマホ触り続けてるよね
Sentimiento: neutro

Tweet: You heard correctly https://t.co/jdOipJqeDc


Sentimiento: neutro

Tweet: @Iampatelajeet @neetcode1 His accent fooled everyone 🤣. On top of that


he's solving in python while majority indian youtubers solve on c++/java. Who

could've imagined this😂


Sentimiento: positivo

Tweet: chatGPT、プログラミングに興味を持ち始めて一つ思ったのが、
やはり『プログラミング「言語」』である以上『ポキャブラリー』が必要なのか
なと思った。
『Python』の関数?をひたすら解説するコピペ作った…:) https://t.co/eAQ82g5zVK
Sentimiento: positivo

Tweet: @Nadjapm @FlavioDarin @guilhermedpb https://t.co/D0JoXFh2MQ


Sentimiento: neutro
Tweet: @Abdulmogeeb Python:
for i in range(10,26,1):
print(i)
for i in range(25,-1,-1):
print(i)
Sentimiento: neutro

Tweet: @BFelipe22 Manda o burro Zago embora, contrata um técnico para já ir


preparando elenco da série B essa é a nossa realidade! Falta apenas os
SAFados começarem a trabalhar!
Sentimiento: neutro

Tweet: @pasochkapan Так, різко обривати було не найкращою ідеєю. Але я


виправлюсь.
Sentimiento: neutro

Tweet: @adambloomie2 Don't want this to turn into a Monty Python sketch but ...

Luxury. I was once billed as 'Walsh comedian Wayne Jones'. Walsh? 🙂


Sentimiento: neutro

Tweet: @3rdemayaz Python ve Go yazdığımdan beri NodeJS'in yüzüne


bakmamıştım. NodeJS'e yüz çevirerek nankörlük etmişim 🥲
Sentimiento: neutro

Tweet: @jonpa_draws @jpalmiotti @AmandaRantsAlot Thanks I appreciate this so


much I'm gonna use it as a variant cover!
Sentimiento: positivo

Tweet: @mika_guildla おはようございます(゚▽゚)/


Sentimiento: neutro

Tweet: @airi_kijima おはようございます(゚▽゚)/


Sentimiento: neutro

Tweet: Don’t know what made me think of this

Monty Python - Execution in Russia https://t.co/xLYASvhbbu via @YouTube


Sentimiento: neutro

Tweet: @FanBushranger @KLtweeet @python_fili @Cobratate Like let’s be real


here and assume for a second that he is guilty, what evidence would you need to
believe it besides him doing it right in front of you IRL? Ignoring everything else, if
an old video of him literally snitching on HIMSELF isn’t enough then what the fuck
is?
Sentimiento: negativo

Tweet: 工エエェェ(´д`)ェェエエ工
Python 学習初めて最大の謎の解答が最高に意味不明でこういうの大好き。
https://t.co/GoLSjptefu
Sentimiento: neutro

Tweet: Python for Beginners

Learn Python, the language behind Instagram, Spotify, and Google. Write
programs, solve math problems, create art, and send secret messages! Modules
cover program writing, calculations, decision-making, loops, data representation,
functions, and more. Join us in Sydney, NSW to unleash your coding potential!

https://t.co/fPoq3oALcZ

#Python #CodingBeginner #LearnToCode #Jobs


Sentimiento: negativo

Tweet: Dear Twitter,


In this coding course I'm essentially learning JavaScript and Python at the same
time, side by side, under very challenging time constraints, and my head hurts.
Sentimiento: positivo

Tweet: @mxjxn @DepecheNode_ second on python. they make stuff for kids to
work on projects etc.

and Lego has some projects also.


Sentimiento: neutro

Tweet: @yacine1607 On est d'accord. Entraîneur qui ne propose rien


Sentimiento: neutro

Tweet: @Coritiba Rumo a Série B, time lixo, SAFados, #forazago


Sentimiento: neutro

Tweet: @svenlatham If Flask implies Python, then I'd use Pelican.

Write some stand-alone script that pulls from the database and uses Jinja2 to
create either HTML, ReST, or Markdown; drop the those where Pelican can find
them, et voila.
Sentimiento: neutro

Tweet: @MoureDev Según tu experiencia, para que tipo de desarrollos esta


orientado python?
Sentimiento: neutro
Tweet: @Coritiba Não faz falta nenhuma jogando
Sentimiento: neutro

Tweet: Продовжувати писати "такі" треди мої маленькі дрочери?


Sentimiento: neutro

Tweet: Відточую майстерність писати.

Тому пройдіть опитування нижче⬇️


Sentimiento: neutro

Tweet: Turns out PrettyTables didn't work on my Python 3.11.4, but luckily I had
version 3.9.13 installed, which resolved the error. Phew!
Sentimiento: positivo

Tweet: This python tool did most of what I needed. It didn't preserve the permalink
so I wrote a custom script to restore the path from Medium and put it in the
permalink: front-matter for Jekyll. That's basically it.https://t.co/0w5xKRidWB
Sentimiento: positivo

Tweet: Yep; it was the libffi's pkgconfig/libffi.pc files, just as I suspected.

Now the i86pc and sparc platforms have identical functionality. And the latest
version of Python.

Honest to goodness, if Mercurial weren't written in Python, I'd ditch this ridiculous
language long ago... https://t.co/ZgWOvjLWm2
Sentimiento: positivo

Tweet: @Don_Zizou5 @MadridXtra These randoms will be the end of me


Sentimiento: neutro

Tweet: Day 16 & 16.1 of #100daysofcode

Finally started Object Oriented Programming! 🚀

Link to the 100 Days of Code (Python) Repo: https://t.co/kdpx4rB0uh


https://t.co/8F2jQymR0t
Sentimiento: neutro

Tweet: #Blockchain for Executives Certificate

Blockchain is a technology…
…that enables the creation of a shared, immutable ledger. It allows for transactions
to be recorded and verified without the need for a third party.
https://t.co/qbUZZgs2k7

#python #CEOs #AI #DataScience


Sentimiento: neutro

Tweet: @DigitalGanon @FamosoNatty Bah si, c'est littéralement installé sur toutes
les machines, c'est peut-être le langage le plus adapté pour faire des petits
programmes simples facile à exécuter ! Si tu fais du js ou du php, tu passes
facilement sur du python
Sentimiento: neutro

Tweet: @tactKoBb2 @mata1177 KoBA さんおはようございます

今週もよろしくです😊
Sentimiento: neutro

Tweet: @FanBushranger @KLtweeet @python_fili @Cobratate The matrix you’re


describing is literally Tate himself then. That’s the only person I’m basing my
judgement on, his words in his videos, nothing else.

“The matrix” is Tate fan’s version of “God does things in mysterious ways”, it’s a
go-to phrase for when you have no comeback
Sentimiento: neutro

Tweet: Consegui fazer um bot no python, pensa na alegria


Sentimiento: neutro

Tweet: Pelo menos tem python pra integrar, dá pra usar quando tô com preguiça
Sentimiento: neutro

Tweet: Python Basics - I have just completed this room! Check it out:
https://t.co/1W5S1vhxj4 #tryhackme #python #programming #bitcoin
#pythonbasics a través de @realtryhackme
Sentimiento: neutro

Tweet: @fbsavasciruhu Utandım şunu görünce siz neleri yarıştırıyosuz böyle.


Sentimiento: neutro

Tweet: かっくいい~欲しい~ #タイムセール #アマゾン #amazon #家電 #


楽天市場 #楽天スーパーセール #python #立直平和胃痛満貫 話題 now #乃木
坂工事中 https://t.co/Skz15niLwP
Sentimiento: neutro

Tweet: @JUNlPER Okay but this is sick actually. I love it?


Sentimiento: positivo
Tweet: @DigitalGanon @FamosoNatty Ah oui, nous nous étions mal compris.
Enfin, python c'est aussi du haut niveau, rien de très complexe
Sentimiento: neutro

Tweet: @karawalk @E_Sheninger Big Error !!


Sentimiento: neutro

Tweet: #Metatime, #MetaAirdrop #AirDrop.

🤔 Interesting project...
Sentimiento: positivo

Tweet: おはようございます😁

また1週間頑張りますか😅
まーたさん(@mata1177 )からザビエル君ペアで譲り受けた
繁殖頑張ってみるか🤣

忘れ物はございませんね
今日も元気に行ってらっしゃい😊

#ボールパイソン https://t.co/NTd2nwm4Bf
Sentimiento: neutro

Tweet: ♛ IT Exam Guide ♛IT Exam Tools: Object-oriented Programming in


Python https://t.co/7wXYbsL01W
Sentimiento: neutro

Tweet: Day 5 completed #100DaysOfCode in python using pygame


https://t.co/DhZQu4Q59g
Sentimiento: neutro

Tweet: "What it means to be human in a world in AI."

👉 People used to think AI was robots. Amazing where we've come.

👉 He talked about code that it wrote for him --


NOTE: When my kids had ChatGPT write TicTacToe games in Python -- only 8 out
of 10 works. Still a tad clunky #ISTELive
Sentimiento: positivo

Tweet: @MadridXtra You are the worst footballer of all time


Sentimiento: negativo

Tweet: @TateTheTalisman @python_fili @Cobratate So someone else hired them


for u ? Lol
Sentimiento: positivo

Tweet: Programmer YouTubers should be called the oracle because they have all
the answers.

#Python #javascript #programming #programminghumor #programmingmemes


https://t.co/2EngtCujzK
Sentimiento: neutro

Tweet: @xaviersythe mainly make/made game engines by hand, but spent ~3


years as a very seriously focused hobby post-college.

commercial engines: Unity, UE4 (rusty)


languages: C, C++, Rust, C#, Python

formerly: UE2 (UT2003 modding), UE (UT99 modding), GoldSrc (modding), Game


Maker (child)
Sentimiento: negativo

Tweet: @CryptidPolitics Oh. Wow! He touched a python. That's all I need to know
about his qualifications to lead a country. How about the rest of you. Touch a
snake, become a President. He'll probably get a 100M votes.
Sentimiento: positivo

Tweet: @python_fili @TateTheTalisman 1100 followers vs the brother of the most

followed man in the world with 1 million plus followers. You are the nobody 🤣🤣🤣
Sentimiento: positivo

Tweet: Python かなり特殊というかなんか妙なクセがあるのは同意


Sentimiento: neutro

Tweet: I need a job in tech please help me secure an intern or a gig.

I specialize on python, backend dev, restful API's, full stack web, web creation and
deployment, data scientist and few others.

Please I'm in dire need of a job, I need to sustain myself in these hard times.
https://t.co/xty1KmLe6b
Sentimiento: positivo

Tweet: @leonardonam Todavia no me ha convencido, lo que me gusta es que es


un clon de laravel en python y yo se laravel. En django es un poco distinto todo, y
flask por ejemplo es más parecido a express y es más mínimo todo, me gustan
para hacer servicios, esos que mencionas no los conozco
Sentimiento: neutro
Tweet: Title :Shadow Broker SMB Scanner [PYTHON] [https://t.co/Sne5aM7nWP]
Links : https://t.co/xL905apcZ9
Description: Use shadow broker SMBTOUCH tools to scan for vulnerable smb
services so these machines can be identified and patched. Comes with x86
libraries. https://t.co/Hkv0shlJOh
Sentimiento: negativo

Tweet: @LEE_JUYEON @LEE_JUYEON @LEE_JUYEON @LEE_JUYEON


@LEE_JUYEON @LEE_JUYEON
Sentimiento: neutro

Tweet: @kroellaki Να ρωτήσουμε τον Λιγνάδη αυτός δεν θα είναι υπουργός.. ??


Sentimiento: neutro

Tweet: Anybody have any good examples of soundings with multiple DGZs or
LFCs?

I'm making yet another python sounding plotter and want to test it against edge
cases
Sentimiento: positivo

Tweet: @Steadfast_wtf @clcoding wow. python on vscode is very lovely. The


interface is just so cool
You could try it out bro
Sentimiento: positivo

Tweet: @NickKen99156276 Monty Python.


Sentimiento: neutro

Tweet: @malicecide Hii


Sentimiento: neutro

Tweet: @DennisKBerlin Von Monty Python gibt es die Nummer über Menschen,
die es gelernt haben, nicht gesehen zu werden.
Sentimiento: neutro

Tweet: @molly0xFFF They have advanced techniques. https://t.co/8y8X27sNgJ


Sentimiento: positivo

Tweet: @PardiZoltan .... a gas station beating the crap out of the united west and
their Ukrainian pawns, while the EU is going down like Monthy Python's suicide
squad.
Sentimiento: negativo

Tweet: @Coritiba #forazago


Sentimiento: neutro
Tweet: @sodaflrt SAVE SOME FOR MEEEEE https://t.co/YhqTV0gXAR
Sentimiento: neutro

Tweet: @darreoncollin @mg6 nah this is true and if it isn't make everyone else's
fatal blow slower
Sentimiento: positivo

Tweet: @energeiofaga Και κρυφολαμογια ε..ότι φάμε ότι πιούμε κ ότι αρπάξει ο
κωλος μας..
Sentimiento: neutro

Tweet: Django Core | A Reference Guide to Core Django Concepts


#udemycoupon https://t.co/pX6T5684Ff

#webdevelopment #Django #Nodejs #Laravel #Python #bootstrap4 #MongoDB


#javascript30 #angular7 #React #PHP #css3 #HTML5 #WordPress #vuejs #Redux
#100DaysOfCode
Sentimiento: neutro

Tweet: @21_parthh I have also started learning Python recently. From where are
you learning?
Sentimiento: neutro

Tweet: @ClickCoxa Apaga esse post que ainda dá tempo!


Sentimiento: neutro

Tweet: @PJUllrich I was looking at discord careers page https://t.co/7KNu1JkjXE, I


don't find any of their jobs on elixir - mostly rust, python, typescript, go .. i wonder
have they changed their backend from elixir to something else?
Sentimiento: positivo

Tweet: @ClickCoxa Leva o Zago e mais metade do time para sua casa, esse time
é lixo puro!
Sentimiento: neutro

Tweet: @KLtweeet @jkelly0112 @python_fili @Cobratate there's no convincing


the ones lost to the matrix. don't waist your time.
Sentimiento: negativo

Tweet: @jrs_mesh @ScottTheGeo @MERICANOil I like my setup bc everything


can be accessed anywhere with a simple connection string… python scripts, excel,
access, qgis, arc, etc can all reach into db and pull data on the fly, at home or
wherever. Over 1mm wells and associated dst/perf/etc data, and 10x faster than
Petra
Sentimiento: positivo
Tweet: Pour partager avec des pairs sur les librairies Python pour les robots
Spike !
Sentimiento: neutro

Tweet: Gamificação é muito importante pra mim, ou eu faço ou eu não realizo uma
atividade monótona que tenho que fazer, ao mesmo tempo é muito difícil imaginar
que estou na Terra Média minerando e forjando machados quando o que estou
fazendo na realidade é programar em Python.
Sentimiento: neutro

Tweet: Anybody else raised to believe that nerdy shit was supposed to be smarter?
I would have absolutely loved football over Monty fucking Python
Sentimiento: negativo

Tweet: Only 5 days left to enter this awesome giveaway from FAFO Industries!
Use this link https://t.co/GGm3H2jtoD
for your chances to win one of Colt Firearms legendary 357 magnum Python
revolvers. Check it out and enter to win it.
Sentimiento: positivo

Tweet: @MOULEOFFICIAL I had no idea you were a python wielding maths

genius! Mind blown!! 🕷️🐱💕 https://t.co/iy4fd5QvsH


Sentimiento: neutro

Tweet: @To_pouli_tou_Ro Ναι ρε φίλε να το πάμε με κόμματα από κάθε νομό..να


δούμε ποιοι θα βγούνε οι χειρότεροι..
Sentimiento: neutro

Tweet: @sisamon Python discrepa fuerte


Sentimiento: neutro

Tweet: Thinking about this image


Sentimiento: neutro

Tweet: Ooo… lady gagita


Sentimiento: neutro

También podría gustarte