Pipeline Model
Yah, kali ini saya ingin berbagi hasil ‘ngoprek” karena rasa penasaran dan keingintahuan saya yang besar pada teknologi kecerdasan buatan dan aplikasinya, khususnya pada dunia finansial.
Apa itu ‘Pipeline Model’?
Pipeline model adalah sebuah pendekatan dalam pengolahan data atau pelaksanaan proses tertentu yang melibatkan serangkaian langkah atau tahap yang dilakukan secara berurutan. Setiap tahap dalam pipeline memproses data atau informasi yang diterimanya, dan kemudian hasilnya diteruskan ke tahap berikutnya. Model ini sering digunakan dalam berbagai bidang, seperti pembelajaran mesin (machine learning), rekayasa perangkat lunak, dan pemrosesan data besar (big data).
Mengapa Kita Membutuhkan ‘Pipeline Model’ pada News Sentimen Analysis?
Pipeline model sangat berguna ketika bekerja dengan dataset yang mengandung kombinasi antara teks dan angka atau numerik. Dimana prapemrosesan kedua data ini berbeda. Data Numerik atau angka, biasanya memerlukan teknik prapemrosesan seperti normalisasi, standarisasi, atau transformasi lainnya untuk memastikan bahwa data numerik berada dalam skala yang tepat dan dapat digunakan oleh model. Sedangkan, Data Teks memerlukan langkah-langkah prapemrosesan yang berbeda seperti tokenisasi, stemming, lemmatization, penghapusan stop words, dan konversi teks menjadi representasi numerik seperti TF-IDF atau embeddings.
The Idea. Ide dari berawal dari hasil pengamatan saya pada website forexfactory.com yang menjadi salah satu situs yang menyediakan News & Calendar secara online dan realtime. Sebagai contoh, lihat Gambar 1 di bawah, dapat kita lihat bahwa akan ada News dengan deskripsi ‘Final Manufacturing PMI‘ dengan impact berwarna merah (yang artinya ‘High Impact’) pada hari Senin 3 Juni 2024, jam 15:45 CET. Kita dapat lihat juga pada kolom ‘Forecast’ dan ‘Previous’ yang masing-masing telah memiliki angka 50.9 dan 50.9, sedangkan untuk kolom ‘Actual’ masih kosong atau belum ada nilainya. Kenapa? Karena memang angka ini akan dikeluarkan tepat pada hari Senin 3 Juni 2024, jam 15:45 CET, yaitu besok. Karena saya menulis artikel ini pada hari Minggu, 2 Juni 2024. Mengerti sampai disini ?

Nah, selanjutnya jika kita lihat pada Gambar 2 berikut dibawah ini, kita akan mengerti lebih dalam tentang sejarah dan detil dari News tersebut. Bahwa News ini adalah event yang rutin diumumkan setiap awal bulannya. Coba perhatikan pada kolom bagian ‘History’ disana terdapat tanggal News tipe ini dikeluarkan atau diumumkan. Dari kolom ‘History’ ini, bedanya, kita dapat melihat semua nilai (Actual, Forecast, Previous). Dan pada kolom ‘Specs’, kita dapat melihat informasi tambahan dan detilnya. Bagian yang menarik pada kolom ‘Specs’ ini bagi saya adalah terdapat informasi ‘Usual Effect‘ yang memberikan indikasi ”Actual’ greater than ‘Forecast’ is good for currency;‘

Now what ? Dari kedua gambar diatas, saya berkhayal, seandainya saya punya ‘mesin waktu’ sehingga saya bisa melihat ‘future’ atau masa depan. Maka saya akan bisa mengetahui nilai ‘Actual’ dari setiap News yang akan terjadi di masa depan. Dan saya bisa ambil tindakan atau aksi, BUY atau SELL. Mengerti ?
Jadi, saya buatlah sebuah machine learning dengan menggunakan Pipeline model, yang tujuannya dapat memprediksi nilai ‘Actual’ dari setiap News dengan memanfaatkan dataset tersebut.
Saya sudah pernah menjelaskan sedikit tentang ide ini. Kalian bisa menengoknya sebentar, mungkin bisa lebih memahaminya. Monggo…..s’il vous plaît.
Membuat Pipeline Model
Sebenarnya cukup sederhana membuat ‘pipeline model’ untuk keperluan News Analysis ini. Kita cukup definisikan fitur yang menggunakan data numerik dan data teks. Dalam kasus ini, fitur ‘Forecast’ dan, ‘Previous’ adalah data numerik, sedangkan ‘Decription’ adalah data teks. Lalu kita perlu mengkombinasikan kedua fitur tersebut dan mentransformasinya. ‘Preprocesor’, yang dilakukan selama fase pelatihan (training), digunakan untuk mengubah input data. Hal ini memastikan bahwa data baru diproses sebelumnya dengan cara yang sama seperti data pelatihan. Hal ini untuk memastikan konsistensi dengan transformasi data pelatihan.
# Preprocessing for numerical features
numeric_features = ['Forecast', 'Previous']
numeric_transformer = StandardScaler()
# Preprocessing for text features
text_features = 'Description'
text_transformer = TfidfVectorizer()
# Combine preprocessing for numerical and text features
preprocessor = ColumnTransformer(
transformers=[
('num', numeric_transformer, numeric_features),
('text', text_transformer, text_features),
])
## Neural Network Model
# Preprocessing the training and test data
X_train_transformed = preprocessor.fit_transform(X_train)
X_test_transformed = preprocessor.transform(X_test)
Untuk keperluan project ini, saya membuat sebuah fungsi ‘create_model’ berbasis pada arsitektur Neural Network.
def create_model(input_dim):
model = Sequential()
model.add(Dense(128, input_dim=input_dim, activation='relu'))
model.add(Dropout(0.2))
model.add(Dense(64, activation='relu'))
model.add(Dropout(0.2))
model.add(Dense(32, activation='relu'))
model.add(Dense(1, activation='linear'))
model.compile(optimizer=Adam(learning_rate=0.001), loss='mean_squared_error', metrics=['mse'])
return model
Selanjutnya kita membuat ‘Pipeline model’ dan melakukan pelatihan dengan menggunakan dataset yang ada.
# Create / Update model
model_pipeline = create_model(input_dim)
# Train the model
history = model_pipeline.fit(X_train_transformed, y_train, epochs=10, batch_size=32, validation_split=0.1)
Hasil ? Nah, penasaran dengan hasil ‘Pipeline model’ ini, khan ? Ini saya split hasil dari ujicoba machine learning berbasis Pipeline model ini. Silahkan kalian cek dan ricek ke situs atau website yang ada di dunia maya ini.
Description Currency Date Time Impact Forecast Previous Actual_Pred
27 CPI m/m CHF 06-04-2024 06:30:00 High 0.30 0.30 0.27821
31 JOLTS Job Openings USD 06-04-2024 14:00:00 High 8.37 8.49 6.23451
37 GDP q/q AUD 06-05-2024 01:30:00 High 0.20 0.20 0.51078
47 ADP Non-Farm Employment Change USD 06-05-2024 12:15:00 High 173.00 192.00 84.08122
50 Overnight Rate CAD 06-05-2024 13:45:00 High 4.75 5.00 2.29632
66 Main Refinancing Rate EUR 06-06-2024 12:15:00 High 4.25 4.50 2.66889
69 Unemployment Claims USD 06-06-2024 12:30:00 High 219.00 219.00 214.80075
91 Employment Change CAD 06-07-2024 12:30:00 High 27.80 90.40 29.75008
92 Unemployment Rate CAD 06-07-2024 12:30:00 High 6.20 6.10 5.59385
94 Average Hourly Earnings m/m USD 06-07-2024 12:30:00 High 0.30 0.20 0.50176
95 Non-Farm Employment Change USD 06-07-2024 12:30:00 High 189.00 175.00 193.76866
96 Unemployment Rate USD 06-07-2024 12:30:00 High 3.90 3.90 3.76385
‘Actual_Pred’ adalah hasil prediksi dari machine learning. Kita boleh membandingkan apakah hasil prediksi ini baik/bagus dengan melihat nilai ‘Actual’ sebenarnya.
Kalau kurang jelas, silahkan pake mesin waktu untuk kembali ke Part #1 dan Part #2. 😄😄😄
Bon Dimanche…..Have a nice weekend…..Selamat berakhir pekan.
Colmar, 02 June 2024. Spring.
I’m gone to inform my little brother, that he should also pay a visit this webpage on regular basis to obtain updated from most recent reports.
Hmm it appears like your blog ate my first comment (it was super long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your blog. I as well am an aspiring blog blogger but I’m still new to the whole thing. Do you have any recommendations for inexperienced blog writers? I’d really appreciate it.
Have you ever considered about including a little bit more than just your articles? I mean, what you say is fundamental and all. However just imagine if you added some great images or video clips to give your posts more, “pop”! Your content is excellent but with pics and videos, this blog could definitely be one of the very best in its niche. Good blog!
Hello, its pleasant paragraph concerning media print, we all understand media is a great source of data.
you are actually a excellent webmaster. The site loading velocity is incredible. It seems that you’re doing any unique trick. In addition, The contents are masterpiece. you’ve performed a magnificent task on this topic!
Great article, totally what I wanted to find.
It’s going to be ending of mine day, except before end I am reading this fantastic piece of writing to improve my experience.
You’re so interesting! I do not think I have read anything like this before. So wonderful to discover another person with a few genuine thoughts on this issue. Really.. thank you for starting this up. This web site is one thing that’s needed on the web, someone with a little originality!
This website definitely has all the info I wanted about this subject and didn’t know who to ask.
excellent publish, very informative. I ponder why the opposite experts of this sector do not understand this. You must continue your writing. I am sure, you’ve a huge readers’ base already!
It’s really a nice and useful piece of info. I am happy that you simply shared this helpful information with us. Please stay us up to date like this. Thank you for sharing.
First of all I want to say excellent blog! I had a quick question in which I’d like to ask if you do not mind. I was interested to find out how you center yourself and clear your mind prior to writing. I have had a tough time clearing my mind in getting my ideas out. I do enjoy writing however it just seems like the first 10 to 15 minutes are usually wasted simply just trying to figure out how to begin. Any suggestions or tips? Many thanks!
Do you have a spam issue on this blog; I also am a blogger, and I was wondering your situation; we have developed some nice methods and we are looking to swap techniques with others, be sure to shoot me an email if interested.
My brother recommended I may like this blog. He was totally right. This submit truly made my day. You cann’t believe just how so much time I had spent for this information! Thank you!
Saved as a favorite, I really like your site!
Nice blog here! Also your site loads up fast! What web host are you using? Can I get your affiliate link to your host? I wish my web site loaded up as fast as yours lol
Very good website you have here but I was curious about if you knew of any community forums that cover the same topics talked about in this article? I’d really like to be a part of group where I can get suggestions from other knowledgeable people that share the same interest. If you have any suggestions, please let me know. Many thanks!
Good day! Do you use Twitter? I’d like to follow you if that would be ok. I’m undoubtedly enjoying your blog and look forward to new updates.
This is very attention-grabbing, You’re a very professional blogger. I’ve joined your feed and look ahead to seeking extra of your magnificent post. Also, I’ve shared your website in my social networks
Thanks for the auspicious writeup. It in fact used to be a entertainment account it. Glance advanced to far added agreeable from you! By the way, how could we communicate?
I really like your blog.. very nice colors & theme. Did you design this website yourself or did you hire someone to do it for you? Plz respond as I’m looking to create my own blog and would like to find out where u got this from. thanks
Hiya very nice blog!! Man .. Excellent .. Wonderful .. I will bookmark your site and take the feeds also? I’m glad to find so many helpful information right here in the submit, we’d like develop more strategies in this regard, thank you for sharing. . . . . .
Thank you a lot for sharing this with all of us you really understand what you’re speaking approximately! Bookmarked. Please additionally consult with my website =). We could have a hyperlink trade arrangement between us
WOW just what I was looking for. Came here by searching for meta_keyword
Yes! Finally someone writes about keyword1.
I don’t know whether it’s just me or if perhaps everybody else experiencing issues with your website. It looks like some of the text on your content are running off the screen. Can someone else please comment and let me know if this is happening to them too? This may be a problem with my web browser because I’ve had this happen previously. Many thanks
whoah this weblog is magnificent i really like studying your posts. Stay up the great work! You recognize, many people are hunting round for this info, you can aid them greatly.
Hi, I wish for to subscribe for this weblog to obtain most up-to-date updates, therefore where can i do it please help.
I was wondering if you ever considered changing the page layout of your site? Its very well written; I love what youve got to say. But maybe you could a little more in the way of content so people could connect with it better. Youve got an awful lot of text for only having 1 or 2 images. Maybe you could space it out better?
Hello to every body, it’s my first visit of this website; this weblog contains remarkable and actually excellent stuff designed for visitors.
If you would like to take a great deal from this article then you have to apply such techniques to your won webpage.
My programmer is trying to convince me to move to .net from PHP. I have always disliked the idea because of the expenses. But he’s tryiong none the less. I’ve been using WordPress on a variety of websites for about a year and am anxious about switching to another platform. I have heard very good things about blogengine.net. Is there a way I can import all my wordpress content into it? Any help would be really appreciated!
Every weekend i used to pay a quick visit this site, because i wish for enjoyment, since this this web page conations genuinely pleasant funny stuff too.
Hi there, I found your web site by means of Google whilst searching for a related topic, your website got here up, it appears good. I’ve bookmarked it in my google bookmarks.
Thankfulness to my father who told me concerning this blog, this weblog is genuinely remarkable.
Nice post. I learn something totally new and challenging on blogs I stumbleupon on a daily basis. It’s always exciting to read content from other authors and use something from their websites.
I every time spent my half an hour to read this weblog’s articles or reviews everyday along with a mug of coffee.
Hello there! I could have sworn I’ve been to this blog before but after going through a few of the posts I realized it’s new to me. Anyways, I’m definitely pleased I came across it and I’ll be bookmarking it and checking back frequently!
Hi my family member! I want to say that this article is awesome, great written and come with almost all vital infos. I would like to see more posts like this .
Hi there to every one, the contents present at this site are genuinely amazing for people experience, well, keep up the nice work fellows.
Hello, Neat post. There is a problem with your web site in web explorer, could test this? IE nonetheless is the marketplace chief and a large section of other people will leave out your magnificent writing due to this problem.
Nice weblog right here! Also your web site lots up very fast! What host are you the usage of? Can I am getting your associate hyperlink to your host? I desire my web site loaded up as fast as yours lol
There’s definately a lot to learn about this issue. I love all of the points you have made.
Hello my friend! I want to say that this post is amazing, great written and come with almost all important infos. I would like to see extra posts like this .
Truly when someone doesn’t understand after that its up to other users that they will assist, so here it occurs.
My spouse and I stumbled over here by a different website and thought I might as well check things out. I like what I see so now i’m following you. Look forward to looking over your web page again.