Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package.json
package-lock.json
build/
plugins/
node_modules/
.DS_Store
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"liveServer.settings.port": 5501
}
1 change: 1 addition & 0 deletions experiment-descriptor.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"unit-type": "lu",
"label": "",
"basedir": ".",
"LaTeXinMD": "true",
"units": [
{
"unit-type": "aim"
Expand Down
27 changes: 25 additions & 2 deletions experiment/aim.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
### Understanding Classification Approaches

#### Discriminative vs Generative Classifiers
1. **Discriminative Classifiers** (e.g., Linear Perceptrons)
- Learn decision boundaries directly
- Effective for well-separated classes
- Focus on class separation
- Simpler to implement

Linear perceptrons allow us to learn a decision boundary that would separate two classes. They are very effective when there are only two classes, and they are well separated. Such classifiers are referred to as discriminative classifiers.
2. **Generative Classifiers** (Bayesian Approach)
- Model each class as a random vector
- Use probability distributions/density functions
- Consider class likelihoods
- More flexible in handling complex data

In contrast, generative classifiers consider each sample as a random vector, and explicity model each class by their distribution or density functions. To carry out the classification, we compute the likelihood that a given sample belong to each of the candidate classes, and assign the sample to the class that is most likely. In other words, we need to compute P(ωi/x) for each class ωi. However, the density functions provide only the likelihood of seeing a particular sample, given that the sample belongs to a specific class. i.e., the density functions provide us p(x/ωi). The Bayes rule provides us with an approach to compute the likelihood of the class for a given sample, from the density functions and related information.
### Bayesian Classification
The experiment focuses on understanding how Bayesian classification:
- Computes class probabilities using Bayes' rule
- Combines prior knowledge with observed evidence
- Makes decisions based on posterior probabilities
- Handles uncertainty in classification

### Key Concepts
- Prior probabilities
- Likelihood functions
- Posterior probabilities
- Decision boundaries
- Class density functions
36 changes: 28 additions & 8 deletions experiment/assignment.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
1. The covariance matrix is always
### Question 1: Covariance Matrix Properties
The covariance matrix is always:

a) Square
a) Square
b) Positive Semidefinite
c) Positive Definite
d) Symmetric
e) None of the above

b) Positive Semidefinite
For each of the properties you selected, describe what would happen if the covariance matrix does not satisfy that property.

c) Positive Definite
### Question 2: Decision Boundaries
Describe the possible set of decision boundaries that can be generated using Gaussian density functions in a two-class problem.

d) Symmetric
### Question 3: Bayesian Classification Components
Consider a two-class classification problem using Bayesian approach:

e) None of the above.
For each of the properties you selected, describe what would happen if the covariance matrix does not satisfy that property.
a) Explain how the prior probabilities affect the decision boundary when:
- Both classes have equal priors
- One class has a higher prior than the other

2. Describe the possible set of decision boundaries that can be generated using gaussian density functions in a two class problem.
b) How does the likelihood function influence the classification decision when:
- The classes have similar covariance matrices
- The classes have different covariance matrices

### Question 4: Practical Application
Given a dataset with two classes, where:
- Class 1: Mean = (2, 3), Covariance = [[1, 0], [0, 1]]
- Class 2: Mean = (4, 5), Covariance = [[2, 0], [0, 2]]
- Prior probabilities: P(Class 1) = 0.6, P(Class 2) = 0.4

a) Calculate the posterior probability for a test point (3, 4)
b) Determine the class assignment for this point
c) Explain how the decision would change if the prior probabilities were equal
3 changes: 0 additions & 3 deletions experiment/objective.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
The high level goals of the experiment are:

1. To understand the computation of likelihood of a class, given a sample.

2. To understand the the use of density/distribution functions to model a class.
3. To understand the effect of prior probabilities in Bayesian classification.

4. To understand how two (or more) density functions interact in the feature space to decide a decision boundary between classes.

5. To understand how the decision boundary varies based on nature of the density functions.

39 changes: 20 additions & 19 deletions experiment/procedure.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
**Stage 1:**
### Set Class Parameters
In the **Parameters** section on the left side:

1. Lauch the experiment and clear the pane. Assign differnt means and covariances for each of the classes and observe the resulting densities. Use the mark-all button to observe the decision boundaries.
* You will see parameters for **Class 1** and **Class 2**.
* Each class has fields to set:

2. Note down your observations on the relationship between the decision boundaries and the density functions.
* Mean values (`Mean X`, `Mean Y`)
* Covariance matrix values (`Covariance XX`, `Covariance XY`, `Covariance YY`)
* Prior Probability (the probability of each class before seeing data)

**Stage 2:**
### Adjust Parameters as Desired

1. Repeat the above procedure for different values of prior probabilities.
* Modify any of the values by clicking on the input box and typing new numbers.
* The means define the center location of each class’s distribution.
* The covariance matrix controls the shape and orientation of the distribution.
* The prior probability defines how likely each class is, used for classification decisions.

2. Observe the change in the scaled density functions and decision boundaries
### Visualize Classification

3. Note down your observations regarding the change of decision boundaries
After setting the parameters, the visualization will automatically reflect these changes on the plot canvas (600x600 pixels) on the right.

**Stage 3:**
#### Use Buttons to Interact with the Plot

Generate the following types of decision boundaries by varying the means and covariance matrices.
* **Mark All:** Click the **Mark All** button to classify and mark all points in the visualization area based on the current parameters.
* **Clear:** Click the **Clear** button to remove all marks and reset the plot display.

1. Straight line

2. Parallel Straight lines

3. Concentric circles
4. Parabola
5. Hyperbola
6. Four Quadrants

Explain why these shapes are generated in each case.
#### Interpret the Visualization
* The plot shows the 2D distributions for Class 1 and Class 2 based on your parameter inputs.
* Points or areas marked correspond to the classification regions according to Bayesian decision rules.
Binary file removed experiment/simulation/Exp5.tar.gz
Binary file not shown.
Binary file removed experiment/simulation/Exp5.zip
Binary file not shown.
Binary file removed experiment/simulation/Exp5/Exp5.jar
Binary file not shown.
19 changes: 0 additions & 19 deletions experiment/simulation/Exp5/Exp5.jnlp

This file was deleted.

15 changes: 0 additions & 15 deletions experiment/simulation/Exp5/README.txt

This file was deleted.

Binary file removed experiment/simulation/Exp5/lib/Jama-1.0.2.jar
Binary file not shown.
Binary file removed experiment/simulation/Exp5/lib/jcommon-1.0.16.jar
Binary file not shown.
Binary file removed experiment/simulation/Exp5/lib/jfreechart-1.0.13.jar
Binary file not shown.
Binary file removed experiment/simulation/Exp5/lib/junit.jar
Binary file not shown.
Binary file removed experiment/simulation/Exp5/lib/libsvm.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions experiment/simulation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
the files used for simulation are:
- index.html
- script.js
- style.css

rest of the files are NOT USED for this version
97 changes: 88 additions & 9 deletions experiment/simulation/index.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,95 @@
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<!-- Add CSS at the head of HTML file -->
<link rel="stylesheet" href="./css/main.css">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="description" content="Interactive Bayesian Classification Simulation">
<meta name="theme-color" content="#3498db">
<title>Bayesian Classification Simulation</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<!-- Your code goes here-->
<p><li>This simulation has some <a href="../../../Introduction.html" target="PARENT">software dependencies</a>. We highly recommend you to use our customized <a href="https://vlead.vlabs.ac.in/development/#virtual-box" target="blank">VirtualBox</a> for the smooth running of these simulations.</li></p>
<p><li>Click <a href="Exp5.tar.gz">here</a> to open the Experiment for Linux systems</li></p>
<p><li>Click <a href="Exp5.zip">here</a> to open the Experiment for Windows</li></p>
<div class="container">
<header>
<h1>Bayesian Classification Simulation</h1>
</header>

<!-- Add JS at the bottom of HTML file -->
<!--<script src="./js/main.js"></script>-->
<div class="main-content">
<div class="control-panel">
<div class="experiment-controls">
<h2>Parameters</h2>

<div class="class-params">
<h3>Class 1 Parameters</h3>
<div class="param-group">
<label>Mean X:</label>
<input type="text" id="mean1x" value="-2">
</div>
<div class="param-group">
<label>Mean Y:</label>
<input type="text" id="mean1y" value="-2">
</div>
<div class="param-group">
<label>Covariance XX:</label>
<input type="text" id="cov1xx" value="1">
</div>
<div class="param-group">
<label>Covariance XY:</label>
<input type="text" id="cov1xy" value="0">
</div>
<div class="param-group">
<label>Covariance YY:</label>
<input type="text" id="cov1yy" value="1">
</div>
<div class="param-group">
<label>Prior Probability:</label>
<input type="text" id="prior1" value="0.5">
</div>
</div>

<div class="class-params">
<h3>Class 2 Parameters</h3>
<div class="param-group">
<label>Mean X:</label>
<input type="text" id="mean2x" value="2">
</div>
<div class="param-group">
<label>Mean Y:</label>
<input type="text" id="mean2y" value="2">
</div>
<div class="param-group">
<label>Covariance XX:</label>
<input type="text" id="cov2xx" value="1">
</div>
<div class="param-group">
<label>Covariance XY:</label>
<input type="text" id="cov2xy" value="0">
</div>
<div class="param-group">
<label>Covariance YY:</label>
<input type="text" id="cov2yy" value="1">
</div>
<div class="param-group">
<label>Prior Probability:</label>
<input type="text" id="prior2" value="0.5">
</div>
</div>

<div class="buttons">
<button style="display: none;" id="generate-btn">Generate Data</button>
<button id="mark-all-btn">Mark All</button>
<button id="clear-btn">Clear</button>
</div>
</div> </div>

<div class="visualization">
<canvas id="plot-canvas" width="600" height="600"></canvas>
</div>
</div>


</div>

<script src="script.js"></script>
</body>
</html>
Loading