Senin, 11 Agustus 2025

WordCloud in PYTHON

WordCloud

Pada blog sebelumnya, kita sudah mempelajari tentang RandomForest yaitu untuk melakukan klasifikasi dan regresi secara akurat dengan menggabungkan banyak pohon keputusan, dan blog itu bisa dibaca disini. Nahhh buat kalian ni yg sering "menyelam" di internet, kalian mungkin ga asing sama WORDCLOUD. Keliatan keren kanDaripada klean cuma nikmatin kerjaan orang, mending kita bikin sendiri wordcloud pake PYTHON, nahh gimana buatnya? Wed wed pelan2, kita bahas dulu GIMANA SYSTEM WORDCLOUD? Yuk langsung aja kita bahas.

Apa itu Wordcloud?

Nahhh jadi gini le. Wordcloud itu kayak- yaaa wordcloud, kalian bisa cari di google atau kalau kalian MALAS nih ku kasi foto contoh wordcloud.
Nahhhh tu diatas tu, itulah wordcloud. Jadi wordcloud itu kayak kalian ngumpulin voting banyak orang masukin kata2, dan kata2 yg paling sering muncul akan muncul paling gede.

Wordcloud tu buat apa bang?

Tujuannya wordcloud itu sebenernya ya buat nunjukin kata-kata yang paling sering muncul di suatu teks secara visual, biasanya kata yang sering muncul ditulis lebih gede. Buat highlight keyword penting bisa, buat voting bisa, buat seru2an aja juga bisa. Intinya word cloud itu kaya snack, bukan makan utama — dia bukan analisis mendalam, tapi enak buat gambaran awal.

Kodenya gimana tu bang?

Nahhhhhh, niii gw kasi codenya MELEDAG BEGDAGGGGGG DUARRRR

# WordCloud

import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
from PIL import Image
from wordcloud import WordCloud, ImageColorGenerator

# creating the text variable
text1 = "My bloodshot, crusted eyes flickered open and I slowly became accustomed to the gloom. I slept, if you can call it sleep, standing in the corner of a classroom in a derelict school next to upturned desks and blood-spattered white-boards. I watched as others, standing next to me, some close, others a little away, made rasping sounds as they breathed, staring into nothing. We stood, not as one, not supporting or knowing each other but simply en-mass, waiting for something, something to happen, something to direct us. A sound, perhaps. A light. I don’t really know. It’s just a feeling.As the daylight outside faded to black, I wanted to escape from this dead building. I pushed past someone and he growled but then returned to his stupor, staring, panting. I shuffled outside and I smelled the air. Nothing but ash and dirt, rotting corpses and dried blood. There was nothing I wanted here. Nothing I needed. I moved further into the vast black night. There were no street lights anymore. Just darkness. Nothing moved. The streets were empty, devoid of anything of value. Just some burnt out cars and abandoned lorries. A school bus lay on its side; half burned with a charred body in the driver’s seat. A long-dead husk of its former glory. My walking was impaired. I shuffled, jerking from one foot to the other. A dance of death, you could say. I smiled at my little joke. It won’t be a pretty smile as I’ve lost some teeth. I cannot recall how I lost them. I just did. It may have something to do with the hole at the back of my head. But I can’t be sure. What was that? A sound. A voice? I tried to listen and locate the direction. There! There it is again. I smelled the air and, sure enough, I smelled meat. Fresh meat, at last. I started to shamble and shuffle in the direction I think the meat is located. But I am not alone. I heard the snarls and howls of my room-mates behind me. They have also heard the sounds and are coming towards me from different directions as rivers flow to the sea. All are moving now, jerking, lunging, growling, starving. All wanting the source of the sound so they can bite, tear, hack, kill. Eat. I will get something, of that, I am sure. At least, I won’t die of starvation. It’s much too late for that."
text1

# Creating word_cloud with text as argument in .generate() method

word_cloud1 = WordCloud(collocations = False, background_color = 'white',
                        width = 2048, height = 1080).generate(text1)
# saving the image
word_cloud1.to_file('got.png')

# Display the generated Word Cloud

plt.imshow(word_cloud1, interpolation='bilinear')
plt.axis("off")
plt.show()

Hasilnya gimana tu banh?

Nihhhh gwe kasi hasilnya JEDUARRRRRR

Nah jadi gitu. Udah kan? Boleh lah Subreknya wak😋
Ciao~ @GTx

Tidak ada komentar:

Posting Komentar

KODENAME ACC EXHAUST TRAPESIUM & TITANIUM

Ya halo cuy! Kembali lagi bersama gw di channel GTx. Kali ini gw mau share KODENAME ACC EXHAUST BUSSID V4.2, V4.3.4, V4.4.1 Credit Kodename:...