Skip to content
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

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

SaviDahegaonkar
Copy link
Collaborator

Description

Created a new concept entry on the Multiclass Classification concept under Sklearn.

Issue Solved

#4966

Type of Change

  • Adding a new entry

Checklist

  • All writings are my own.
  • My entry follows the Codecademy Docs style guide.
  • My changes generate no new warnings.
  • I have performed a self-review of my own writing and code.
  • I have checked my entry and corrected any misspellings.
  • I have made corresponding changes to the documentation if needed.
  • I have confirmed my changes are not being pushed from my forked main branch.
  • I have confirmed that I'm pushing from a new branch named after the changes I'm making.
  • I have linked any issues that are relevant to this PR in the Issues Solved section.

@mamtawardhani mamtawardhani self-assigned this Dec 14, 2024
@mamtawardhani mamtawardhani added new entry New entry or entries status: under review Issue or PR is currently being reviewed sklearn Sklearn labels Dec 14, 2024
Copy link
Collaborator

@mamtawardhani mamtawardhani left a 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! 😃

Comment on lines 27 to 55
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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


## Syntax

Here's a syntax for using multi-class classification in sklearn:
Copy link
Collaborator

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.

@SaviDahegaonkar
Copy link
Collaborator Author

Hey @mamtawardhani ,
Incorporated the changes suggested by you.

Thanks,
Savi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants