Uh oh!
There was an error while loading. Please reload this page.
Menambahkan Algoritma pengklasifikasi Hutan Acak #271 - #272
Merged
Conversation
for more information, see https://pre-commit.ci
slowy07
requested changes
Jun 5, 2023
slowy07
left a comment
Member
There was a problem hiding this comment.
i think that's problem from linting check (flake8), can you fix that by format and follow the guideline from CONTIRBUTING.md, thanks !
Comment on lines
+1
to
+5
| """ | ||
| 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. | ||
| """ |
Comment on lines
+9
to
+10
| # 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).# |
| 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 |
| 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. |
| 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. |
Comment on lines
+112
to
+113
| # 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). |
| 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. |
| 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. |
ContributorAuthor
There was a problem hiding this comment.
Thanks for the guidance.
Uh oh!
There was an error while loading. Please reload this page.
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
ShubhamZoro
commented
Jun 5, 2023
ContributorAuthor
Please review it. |
slowy07
approved these changes
Jun 6, 2023
slowy07
left a comment
Member
There was a problem hiding this comment.
LGTM, thanks for contribution @ShubhamZoro !
linked issue #246
ContributorAuthor
LGTM I will look into this issue. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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