CoolFace
Apppublic

shwetashweta05/Support_Vector_Machine

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
Support_Vector_Machine.py84 linesDownload Raw Back to pages
1import streamlit as st2 3st.title(":red[Support Vector Machine (SVM)]")4 5st.markdown("""6SVM is a powerful algorithm used to classify data by finding the **optimal hyperplane** that separates different classes.7 8---9 10### Key Concepts:11- **Hyperplane**: A boundary that divides the feature space.12- **Support Vectors**: Critical points that define the margin.13- **Margin**: Distance between hyperplane and closest points.14 15---16 17###  Why SVM?18- Works well for **high-dimensional spaces**19- Effective when number of features > number of samples20- Can handle **non-linearly separable** data using **kernels**21 22""")23 24st.subheader("Support Vector Classification (SVC)")25 26# Introduction27st.markdown("""28### What is SVC?29 30SVC is a type of **supervised machine learning algorithm** used for **classification tasks**.31 32It tries to find the best **hyperplane** (in 2D, a line) that separates the data into classes.33 34It looks for the **maximum margin** between classes โ€” the widest possible "gap" between different class data points.35 36The **support vectors** are the data points closest to the decision boundary (they *support* the hyperplane).37 38SVC can work with both **linear** and **non-linear** data using **kernels**.39""")40 41# When to use SVC42st.markdown("""43###  When to use SVC?44 45-  When you need a **robust classifier** for **small- to medium-sized datasets**.46-  When the data is **not linearly separable** (you can use **kernels** to handle that).47-  When **accuracy is more important** than training time (SVC can be slower on large datasets).48""")49 50st.subheader(":blue[**Hard Margin SVM Explained**]")51st.markdown("""52### ๐Ÿ“Œ What is Hard Margin SVM?53 54Hard Margin SVM is the original SVM algorithm used when the data is **perfectly linearly separable**.55 56It finds the **maximum-margin hyperplane** that separates the classes **without allowing any errors or overlaps**.57 58#### Key Points:59- No misclassification allowed.60- Only works when the data is **perfectly separable**.61- Very **sensitive to outliers** and **not ideal for real-world noisy data**.62 63""")64st.subheader(":blue[**Soft Margin SVM Explained**]")65 66# Description67st.markdown("""68###  What is Soft Margin SVM?69 70Soft Margin SVM allows some **classification errors** to achieve a **better generalization** when data is **not perfectly separable**.71 72This is done by introducing a **regularization parameter `C`** that controls the trade-off between a wide margin and classification errors.73 74#### Key Benefits:75- Works well with **noisy or overlapping data**.76- **Balances** margin maximization with error minimization.77- The model can **generalize better** in real-world scenarios.78 79""")80 81st.write("What is Cosine Distance?")82st.write("Cosine Distance (or cosine dissimilarity) is a measure of how different two vectors are in terms of direction, not magnitude.It is derived from Cosine Similarity, which measures the cosine of the angle between two vectors in a multidimensional space.")83 84