Challenge: One-Class SVM for Novelty Detection
Task
Swipe to start coding
You are given a 2D dataset of normal points and a few anomalies. Your task is to train a One-Class SVM model to detect novelties, visualize prediction results, and print anomaly proportions.
Follow these steps:
- Import and initialize
OneClassSVMfromsklearn.svm.- Use
kernel='rbf',gamma=0.1,nu=0.05.
- Use
- Fit the model on normal data only (
X_train). - Predict labels for test data (
X_test).- Label meaning:
1β normal,-1β novel/anomalous.
- Label meaning:
- Compute the fraction of anomalies in
X_test. - Print:
- Shapes of train/test sets.
- Number and fraction of anomalies detected.
Solution
Everything was clear?
Thanks for your feedback!
SectionΒ 5. ChapterΒ 3
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Suggested prompts:
Can you explain this in simpler terms?
What are the main takeaways from this?
Can you give me an example?
Awesome!
Completion rate improved to 4.55
Challenge: One-Class SVM for Novelty Detection
Swipe to show menu
Task
Swipe to start coding
You are given a 2D dataset of normal points and a few anomalies. Your task is to train a One-Class SVM model to detect novelties, visualize prediction results, and print anomaly proportions.
Follow these steps:
- Import and initialize
OneClassSVMfromsklearn.svm.- Use
kernel='rbf',gamma=0.1,nu=0.05.
- Use
- Fit the model on normal data only (
X_train). - Predict labels for test data (
X_test).- Label meaning:
1β normal,-1β novel/anomalous.
- Label meaning:
- Compute the fraction of anomalies in
X_test. - Print:
- Shapes of train/test sets.
- Number and fraction of anomalies detected.
Solution
Everything was clear?
Thanks for your feedback!
SectionΒ 5. ChapterΒ 3
single