র‍্যান্ডম ফরেস্ট

Arefin Anwar

যখন মেশিন লার্নিং মডেলের কথা আসে, তখন অনেক সময় একটি মাত্র ডিসিশন ট্রি আমাদের কাঙ্ক্ষিত ফলাফল দিতে পারে না। ঠিক তখনই আসে র‍্যান্ডম ফরেস্ট, একটি শক্তিশালী এবং কার্যকরী অ্যালগরিদম যা একাধিক ডিসিশন ট্রি ব্যবহার করে আরও নির্ভুল এবং স্থিতিশীল প্রেডিকশন করতে পারে। র‍্যান্ডম ফরেস্ট একটি এনসেম্বল মডেল (একাধিক মডেলের সমন্বয়ে তৈরি মডেল)। এটি একাধিক ডিসিশন ট্রি তৈরি করে এবং সেগুলোর ফলাফলকে একত্রিত করে চূড়ান্ত সিদ্ধান্তে পৌঁছায়। ক্লাসিফিকেশনের ক্ষেত্রে এটি প্রতিটি ট্রি থেকে ভোট নিয়ে মেজরিটি ভোটকে প্রেডিকশন হিসেবে গণনা করে। আর রিগ্রেশনের ক্ষেত্রে, এটি সমস্ত ট্রির আউটপুটের গড়কে চূড়ান্ত ফলাফল হিসেবে গ্রহণ করে।

অর্থাৎ একাধিক ডিসিশন ট্রি (৫০-১০০) একত্র করে যে মডেল প্রেডিকশন দেয়, তাই ই হলো রেনডম ফরেস্ট মডেল।

র‍্যান্ডম ফরেস্টের কাজের ধাপগুলোকে সহজভাবে ব্যাখ্যা করা যাক (আবারো বলি, এসব জিনিস বুঝার জন্য লেখা, ইউজ করতে তোমাকে জাস্ট লাইব্রেরি ফাংশন কল করতে হবে):

১. বুটস্ট্র্যাপ স্যাম্পল তৈরি:

র‍্যান্ডম ফরেস্ট ট্রেনিং ডেটা থেকে একাধিক স্যাম্পল তৈরি করে। প্রতিটি স্যাম্পল মূল ডেটার থেকে এলোমেলোভাবে তৈরি হয় এবং এটি ডুপ্লিকেট ডেটাও রাখতে পারে। এই প্রক্রিয়াকে বলা হয় বুটস্ট্র্যাপিং।

২. ডিসিশন ট্রি তৈরি:

প্রতিটি বুটস্ট্র্যাপ স্যাম্পল দিয়ে একটি ডিসিশন ট্রি তৈরি করা হয়। তবে, প্রতিটি নোড বিভাজনের সময়, এটি পুরো ফিচার সেটের বদলে এলোমেলোভাবে নির্বাচন করা একটি সাবসেট ব্যবহার করে। এই এলোমেলোতা ট্রিগুলোর ভিন্নতা নিশ্চিত করে।

৩. প্রেডিকশন করা:

নতুন ডেটা আসার পর, র‍্যান্ডম ফরেস্টের প্রতিটি ট্রি প্রেডিকশন করে। ক্লাসিফিকেশনের ক্ষেত্রে, প্রতিটি ট্রি তার ভোট দেয়, এবং সবচেয়ে বেশি ভোট পাওয়া লেবেলটি চূড়ান্ত প্রেডিকশন হয়। রিগ্রেশনের ক্ষেত্রে, সব ট্রির প্রেডিকশনের গড় চূড়ান্ত ফলাফল হিসেবে নির্ধারিত হয়।

ধরো, তুমি একটি বাগান দেখতে গিয়েছো, যেখানে বিভিন্ন ধরনের গাছ রয়েছে। তুমি জানতে চাও, একটি বিশেষ গাছের ফল খাওয়া যাবে কি না। যদি তুমি একটি ডিসিশন ট্রি ব্যবহার করো, তবে এটি একটি নির্দিষ্ট পথ ধরে সিদ্ধান্ত দেবে। কিন্তু, যদি একাধিক গাছ (র‍্যান্ডম ফরেস্ট) ব্যবহার করো এবং তাদের সবাইকে আলাদাভাবে জিজ্ঞাসা করো, তখন সবচেয়ে বেশি সংখ্যক গাছ যে উত্তর দেবে, সেটাই হবে তোমার চূড়ান্ত সিদ্ধান্ত। এতে করে ভুলের সম্ভাবনা অনেক কমে যাবে।

import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import accuracy_score

# উদাহরণস্বরূপ ডেটাসেট তৈরি (Iris dataset)
from sklearn.datasets import load_iris
iris = load_iris()
X = iris.data
y = iris.target

# ডেটাকে ট্রেন ও টেস্ট সেটে ভাগ করা
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# র‍্যান্ডম ফরেস্ট ক্লাসিফায়ার মডেল তৈরি
rf_model = RandomForestClassifier(n_estimators=100, random_state=42)

# মডেল ট্রেন করা
rf_model.fit(X_train, y_train)

# প্রেডিকশন করা
y_pred = rf_model.predict(X_test)

# একুরেসি মাপা
accuracy = accuracy_score(y_test, y_pred)
print(f'র‍্যান্ডম ফরেস্ট মডেলের একুরেসি: {accuracy:.2f}')


র‍্যান্ডম ফরেস্টের সুবিধা:

নানান ধরনের ডেটার জন্য কার্যকরী: এটি ক্লাসিফিকেশন এবং রিগ্রেশন উভয় ক্ষেত্রেই ভালো কাজ করে।

হাই একুরেসি: একাধিক ডিসিশন ট্রি ব্যবহার করায় এটি স্থিতিশীল এবং নির্ভুল ফলাফল দেয়।

ওভারফিটিং রোধ: এলোমেলো ফিচার নির্বাচন এবং বুটস্ট্র্যাপিং এর কারণে এটি ওভারফিটিং কমায়।

অ্যানমলি ডিটেকশন: এটি অ্যানমলি বা ব্যতিক্রমী ডেটা সনাক্ত করতে খুব কার্যকর।

40 thoughts on “র‍্যান্ডম ফরেস্ট”

  1. Αchei importante deixar um retorno aqui.
    Passei um bom tempo analisando esta publіcaçãο.

    Como pessoa que lê muitos artigos desse tipo,
    achei a construção do texto muito acima da méⅾia.

    O fɑtor que maіs me deixou satisfeіto ao ler foi
    o equilíbrio entre profundidade e leitura agradáѵel.
    Com tanta coisa superficial circulando online,
    faz diferença encⲟntrar uma página realmente útil.

    Também achei mսito válido
    o equilíƄriο entre clareza, organização e utiliԁade prática.

    Sempre que procuro artigos nessa ⅼinha,
    o ⅼeitor percebe falta de cuidado na construção.

    Nesta poѕtagem em partiⅽular,
    a publicação entregou bem mais do que eu esperava.

    Mais um motivo para eu аvaliar pօsitivamеnte este conteúɗo é que
    não parece um text᧐ jogado de գualquer jeito.

    Para quem valoriza materiais bem escгitos e bem organizados,
    eѕta leitura compensa bastante.
    Pela minha leіtura,
    acho justo elogiar ο traƄalho feito aqui.

    Outro ponto que merece elogio é que
    a construção do raciоϲínio foi bem alinhada.
    Isso ajuda bastаnte.

    Aproveitando o espaço para comentar melhor,
    é que páginas desse nível merecem recеЬer reconhecimento.

    Quem deseja uma leitura útil e organizada,
    tem motivos para acompanhɑr o teҳto até o fim.

    Foi uma experiência de leiturɑ muito boa,
    e pߋr isso vejo motivo paгa elogiar e rеcomendаr.
    Recomendo para quеm gosta de material organizado.
    Com opіnião totalmente pеssoal,
    achei uma recomendação fácil de fazer.

    Parabéns pelo trabalho realizado.
    Vou salvar a página para visіtar novamente depois.

    my website: web site

  2. Jil3, oh yeah! I’ve spent some time on that site. Decent selection, nothing groundbreaking, but reliable for a quick game. Worth a peek if you’re bored. Check it out: jil3

  3. Lodibetph in the Philippines? Yeah, heard about it. Lots of my friends are playing there. Seems pretty legit. Gotta check it out myself soon. You should too. More info here! lodibetph

  4. Mexbet, eh? Heard some good things about it. Said it’s pretty good for sports betting. Might try it myself during the next Liga MX game. ¡Vamos! Take a look: mexbet

  5. Very well written. Managing TRX energy is becoming essential
    for every dApp user. Your points about resource optimization on TRON are spot on. Keep
    up the good work!

  6. Thank үou for some other inflrmative weeb sіte. Wheгe else may I get that ҝind of info written in such a
    perfect manner? I’ve a chalⅼenge that I’m just now running on, аnd I have been оon the look outt for such information.

    my webpagе – best earbuds

  7. Azzahrah Putri Rent Car adalah perusahaan rental mobil makassar yang berkomitmen memberikan pengalaman sewa mobil makassar terbaik, memenuhi semua kebutuhan perjalanan Anda dengan layanan yang berkualitas dan profesional. Fokus kami adalah memastikan kenyamanan dan kepuasan pelanggan, menjadikan kami mitra perjalanan yang dapat diandalkan.

  8. 3pattino1game is my new go-to! The interface is super user-friendly and I haven’t experienced any lag. The games themselves are actually engaging, unlike some other sites I’ve tried. Give it a whirl: 3pattino1game

  9. Alright, lemme tell ya about dlrbet. Nothing super special, but it’s got a decent selection of your usual slots and table games. If you’re passing through, give it a spin. You might get lucky. Time to get betting, give dlrbet a try.

  10. Heard folks buzzing about 59gapp, so I took a peek. Quick access on mobile? Nice! I’m always looking for convenient gaming on the go. Wish me luck! 59gapp

  11. You must absolutely not take this with nitrate-based medications (such as nitroglycerin).

    It can cause severe hypotension. Since there is a possibility
    of interactions with other blood pressure medications, such as alpha-blockers, you must consult
    your prescribing doctor to adjust the dosage and dosing interval.

  12. Wow, that’s what I was searching for, what a material!
    existing here at this website, thanks admin of this web site.

  13. Hi my friend! I wish to say that this article
    is amazing, nice written and include almost all
    important infos. I’d like to peer extra posts like
    this .

  14. Good day I am so delighted I found your web site, I really
    found you by error, while I was researching on Bing for something else, Anyways I am here now and would just like to
    say cheers for a fantastic post and a all round thrilling blog (I also love the
    theme/design), I don’t have time to look over it all at the
    moment but I have bookmarked it and also added in your RSS feeds, so when I have time I will be back to
    read more, Please do keep up the excellent b.

  15. Undeniably believe that which you stated. Your favorite justification seemed to be on the internet
    the easiest thing to be aware of. I say to you, I definitely get annoyed while
    people think about worries that they plainly don’t know about.

    You managed to hit the nail upon the top and defined out the whole
    thing without having side effect , people can take a signal.
    Will likely be back to get more. Thanks

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top