-
-
Notifications
You must be signed in to change notification settings - Fork 109
Menambahkan Algoritma pengklasifikasi Hutan Acak #271 #272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
for more information, see https://pre-commit.ci
slowy07
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think that's problem from linting check (flake8), can you fix that by format and follow the guideline from CONTIRBUTING.md, thanks !
| """ | ||
| Algoritme hutan acak bekerja dengan membuat ansambel pohon keputusan, di mana setiap pohon dilatih pada subset acak dari data pelatihan. | ||
| Selama prediksi, setiap pohon di hutan secara independen memprediksi label untuk sampel masukan yang diberikan, dan prediksi akhir ditentukan oleh suara terbanyak. | ||
| Pendekatan ansambel ini membantu meningkatkan akurasi dan ketahanan model secara keseluruhan. | ||
| """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long, must be < 100 char
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay
| # Kelas DecisionTree mewakili pohon keputusan tunggal di hutan acak. | ||
| # Itu diinisialisasi dengan parameter max_depth (kedalaman maksimum pohon) dan min_samples_leaf (jumlah minimum sampel yang diperlukan untuk membuat simpul daun).# |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long, must be < 100 char
| def fit(self, X, y): | ||
| self.tree = self.build_tree(X, y, depth=0) | ||
|
|
||
| # Fungsi build_tree secara rekursif membagi data berdasarkan fitur dan nilai terbaik, dengan mempertimbangkan perolehan informasi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long, must be < 100 char
| entropy = -np.sum(probabilities * np.log2(probabilities + 1e-10)) | ||
| return entropy | ||
|
|
||
| # Metode prediksi memprediksi label untuk sekumpulan sampel input dengan memanggil fungsi predict_sample untuk setiap sampel. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long, must be < 100 char
| def prediksi(self, X): | ||
| return np.array([self.predict_sample(x) for x in X]) | ||
|
|
||
| # Fungsi predict_sample menelusuri pohon keputusan untuk menentukan label prediksi untuk satu sampel masukan. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long, must be < 100 char
| # Kelas RandomForest mewakili ansambel hutan acak. | ||
| # Itu diinisialisasi dengan parameter num_trees (jumlah pohon di hutan), max_depth (kedalaman maksimum setiap pohon), dan min_samples_leaf (jumlah minimum sampel yang diperlukan untuk membuat simpul daun). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long, must be < 100 char
| self.min_samples_leaf = min_samples_leaf | ||
| self.trees = [] | ||
|
|
||
| # Metode fit melatih hutan acak dengan membuat pohon keputusan num_trees dan menyesuaikannya pada himpunan bagian acak dari data. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long, must be < 100 char
| tree.fit(X[indices], y[indices]) | ||
| self.trees.append(tree) | ||
|
|
||
| # Metode prediksi membuat prediksi untuk satu set sampel input dengan menggabungkan prediksi dari setiap pohon dan mengambil suara mayoritas. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long, must be < 100 char
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the guidance.
…itma random forest classifier. bellshade#272
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
|
Please review it. |
slowy07
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for contribution @ShubhamZoro !
linked issue #246
|
LGTM I will look into this issue. |
Deskripsi (Description)
Checklist:
Umum:
Contributor Requirements (Syarat Kontributor) dan Lain-Lain:
Unit Testing dan Linting:
Environment
Saya menggunakan (I'm using):
os=linux / windows / macOSpython=python3 -V (unix) / py -3 -V (Windows-Python launcher)linked issue #NOMOR_ISSUE