-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[Concept Entry] Sklearn multiclass-classification #5814
base: main
Are you sure you want to change the base?
[Concept Entry] Sklearn multiclass-classification #5814
Conversation
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.
Hey @SaviDahegaonkar , thank you for contributing to Codecademy Docs, the entry is nicely written! 😄
I've suggested a few changes, could you please review and modify those at your earliest convenience? Thank you! 😃
content/sklearn/concepts/multiclass-classification/multiclass-classification.md
Outdated
Show resolved
Hide resolved
content/sklearn/concepts/multiclass-classification/multiclass-classification.md
Outdated
Show resolved
Hide resolved
from sklearn.model_selection import train_test_split | ||
from sklearn.datasets import load_iris | ||
from sklearn.ensemble import RandomForestClassifier | ||
|
||
# Load dataset | ||
data = load_iris() | ||
X, y = data.data, data.target | ||
|
||
# Split data into training and testing sets | ||
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42) | ||
|
||
# Create the model | ||
model = RandomForestClassifier() | ||
|
||
# Train the model | ||
model.fit(X_train, y_train) | ||
|
||
# Make predictions | ||
predictions = model.predict(X_test) | ||
|
||
# Evaluate the model | ||
accuracy = model.score(X_test, y_test) | ||
print("Accuracy:", accuracy) | ||
``` | ||
- `load_iris()`: Function that loads the popular `iris`dataset with three classes for multiclass classification. | ||
- `train_test_split()`: Divides the dataset into training and testing subsets. | ||
- `RandomForestClassifier()`: Algorithm that is used for multiclass classification. Other classifiers like `LogisticRegression`, `SVC`, can also be used for the same. | ||
- `fit()`: Method used to train the model on training data. | ||
- `predict()`: Method makes predicitions on the test 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.
You can simply add the syntax of RandomForestClassifier:
please refer to this: https://scikit-learn.org/1.5/modules/generated/sklearn.ensemble.RandomForestClassifier.html#sklearn.ensemble.RandomForestClassifier
|
||
## Syntax | ||
|
||
Here's a syntax for using multi-class classification in sklearn: |
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.
please mention that:
It demonstrates one way to effectively perform multi-class classification, while there are many algorithms in Scikit-learn for multi-class classification.
content/sklearn/concepts/multiclass-classification/multiclass-classification.md
Show resolved
Hide resolved
…classification.md Co-authored-by: Mamta Wardhani <[email protected]>
…classification.md Co-authored-by: Mamta Wardhani <[email protected]>
…classification.md Co-authored-by: Mamta Wardhani <[email protected]>
Hey @mamtawardhani , Thanks, |
Description
Created a new concept entry on the Multiclass Classification concept under Sklearn.
Issue Solved
#4966
Type of Change
Checklist
main
branch.Issues Solved
section.