diff --git a/SRIP/Codes/Function.js b/SRIP/Codes/Function.js new file mode 100644 index 00000000..04aee9b9 --- /dev/null +++ b/SRIP/Codes/Function.js @@ -0,0 +1,1105 @@ +var canvas = document.getElementById("myChart"); +var ctx = canvas.getContext("2d"); +var PreviousX="NIL"; +var flag=-1; +//flag is the variable which tells which function among load and generate was atlast called. +var flag2=-1; +var flag3=-1; +var meanClass1X=0; +var meanClass1Y=0; +var pointsClass1=0; +var covarianceClass1=0; +var meanClass2X=0; +var meanClass2Y=0; +var pointsClass2=0; +var covarianceClass2=0; +function load() +{ + //x is the value selected by user from the list +var x=document.getElementById("s1").value; +var GridSize=50; +var XAxisDistanceGridLines = 10; +var YAxisDistanceGridLines = 2; + if(x==="T1") + { + GridSize=55; + if(flag===-1) + { + ctx.clearRect(-(50)* YAxisDistanceGridLines,-50*XAxisDistanceGridLines,canvas.width,canvas.height); + ctx.translate(-(50)* YAxisDistanceGridLines,-50*XAxisDistanceGridLines); + } + else if(PreviousX==="T2") + { + ctx.clearRect(-(50)* 10,-25*14,canvas.width,canvas.height); + ctx.translate(-(50)* 10,-25*14); + } + else if(PreviousX==="T1") + { + ctx.clearRect(-(GridSize)*5,-(GridSize)*6,canvas.width,canvas.height); + ctx.translate(-(GridSize)*5,-(GridSize)*6); + } + else if(PreviousX==="T3") + { + ctx.clearRect(-(30)* 10,-(30)*10,canvas.width,canvas.height); + ctx.translate(-(30)* 10,-(30)*10); + } + else + { + ctx.clearRect(-(40)* 7,-(40)*10,canvas.width,canvas.height); + ctx.translate(-(40)* 7,-(40)*10); + } + scriptForT1Dataset(0.125,0.125); + document.getElementById("t1").value=1; + document.getElementById("t2").value=0; + document.getElementById("t3").value=0; + document.getElementById("t4").value=0; + document.getElementById("t5").value=1; + document.getElementById("t6").value=0; + document.getElementById("t7").value=1; + document.getElementById("t8").value=0; + document.getElementById("t9").value=0; + document.getElementById("t10").value=1; + document.getElementById("t11").value=0; + document.getElementById("t12").value=1; + ctx.beginPath(); + ctx.arc((GridSize/0.125) *1,-(GridSize/0.125) * 0,(GridSize/0.125) *(1/2), 0, Math.PI * 2, true); + ctx.stroke(); + ctx.beginPath(); + ctx.arc((GridSize/0.125) *0,-(GridSize/0.125) * 0, (GridSize/0.125) *(1/2), 0, Math.PI * 2, true); + ctx.strokeStyle= "red"; + ctx.stroke(); + PreviousX=x; + } + else if (x==="T2") + { + GridSize=50; + if(flag===-1) + { + ctx.clearRect(-(50)* YAxisDistanceGridLines,-50*XAxisDistanceGridLines,canvas.width,canvas.height); + ctx.translate(-(50)* YAxisDistanceGridLines,-50*XAxisDistanceGridLines); + } + else if(PreviousX==="T2") + { + ctx.clearRect(-(50)* 10,-25*14,canvas.width,canvas.height); + ctx.translate(-(50)* 10,-25*14); + } + else if(PreviousX==="T1") + { + ctx.clearRect(-(55)*5,-(55)*6,canvas.width,canvas.height); + ctx.translate(-(55)*5,-(55)*6); + } + else if(PreviousX==="T3") + { + ctx.clearRect(-(30)* 10,-(30)*10,canvas.width,canvas.height); + ctx.translate(-(30)* 10,-(30)*10); + } + else + { + ctx.clearRect(-(40)* 7,-(40)*10,canvas.width,canvas.height); + ctx.translate(-(40)* 7,-(40)*10); + } + scriptForT2Dataset(0.125,0.125); + document.getElementById("t1").value=0; + document.getElementById("t2").value=0; + document.getElementById("t3").value=0; + document.getElementById("t4").value=0; + document.getElementById("t5").value=1.5; + document.getElementById("t6").value=0.5; + document.getElementById("t7").value=1.5; + document.getElementById("t8").value=-0.5; + document.getElementById("t9").value=0.5; + document.getElementById("t10").value=1.5; + document.getElementById("t11").value=-0.5; + document.getElementById("t12").value=1.5; + ctx.beginPath(); + ctx.ellipse(0,0,(GridSize/0.125)*(1.5/2),(25/0.125)*(1.5/2),0.5, 0, 2 * Math.PI); + ctx.strokeStyle= "red"; + ctx.stroke(); + ctx.beginPath(); + ctx.ellipse((GridSize/0.125)*0,-(GridSize/0.125)*0,0,(25/0.125)*(1.5/2),0.5, 0, 2 * Math.PI); + ctx.stroke(); + ctx.beginPath(); + ctx.ellipse((GridSize/0.125)*0,-(GridSize/0.125)*0,(GridSize/0.125)*(1.5/2),0,0.5, 0, 2 * Math.PI); + ctx.stroke(); + ctx.beginPath(); + ctx.ellipse(0,0,(GridSize/0.125)*(1.5/2),(25/0.125)*(1.5/2),-0.5, 0, 2 * Math.PI); + ctx.strokeStyle="black"; + ctx.stroke(); + ctx.beginPath(); + ctx.ellipse((GridSize/0.125)*0,-(GridSize/0.125)*0,0,(25/0.125)*(1.5/2),-0.5, 0, 2 * Math.PI); + ctx.stroke(); + ctx.beginPath(); + ctx.ellipse((GridSize/0.125)*0,-(GridSize/0.125)*0,(GridSize/0.125)*(1.5/2),0,-0.5, 0, 2 * Math.PI); + ctx.stroke(); + PreviousX=x; + } + else if (x==="T3") + { + GridSize=30; + if(flag===-1) + { + ctx.clearRect(-(50)* YAxisDistanceGridLines,-50*XAxisDistanceGridLines,canvas.width,canvas.height); + ctx.translate(-(50)* YAxisDistanceGridLines,-50*XAxisDistanceGridLines); + } + else if(PreviousX==="T2") + { + ctx.clearRect(-(50)* 10,-25*14,canvas.width,canvas.height); + ctx.translate(-(50)* 10,-25*14); + } + else if(PreviousX==="T1") + { + ctx.clearRect(-(55)*5,-(55)*6,canvas.width,canvas.height); + ctx.translate(-(55)*5,-(55)*6); + } + else if(PreviousX==="T3") + { + ctx.clearRect(-(30)* 10,-(30)*10,canvas.width,canvas.height); + ctx.translate(-(30)* 10,-(30)*10); + } + else + { + ctx.clearRect(-(40)* 7,-(40)*10,canvas.width,canvas.height); + ctx.translate(-(40)* 7,-(40)*10); + } + scriptForT3Dataset(0.125,0.125); + document.getElementById("t1").value=0; + document.getElementById("t2").value=0; + document.getElementById("t3").value=0; + document.getElementById("t4").value=0; + document.getElementById("t5").value=1; + document.getElementById("t6").value=0; + document.getElementById("t7").value=2; + document.getElementById("t8").value=0; + document.getElementById("t9").value=0; + document.getElementById("t10").value=1; + document.getElementById("t11").value=0; + document.getElementById("t12").value=2; + ctx.beginPath(); + ctx.arc((GridSize/0.125) *0,-(GridSize/0.125) * 0,(GridSize/0.125) *(1/2), 0, Math.PI * 2, true); + ctx.stroke(); + ctx.beginPath(); + ctx.arc((GridSize/0.125) *0,-(GridSize/0.125) * 0, (GridSize/0.125) *(2/2), 0, Math.PI * 2, true); + ctx.strokeStyle= "red"; + ctx.stroke(); + PreviousX=x; + } + else + { + GridSize=40; + if(flag===-1) + { + ctx.clearRect(-(50)* YAxisDistanceGridLines,-50*XAxisDistanceGridLines,canvas.width,canvas.height); + ctx.translate(-(50)* YAxisDistanceGridLines,-50*XAxisDistanceGridLines); + } + else if(PreviousX==="T2") + { + ctx.clearRect(-(50)* 10,-25*14,canvas.width,canvas.height); + ctx.translate(-(50)* 10,-25*14); + } + else if(PreviousX==="T1") + { + ctx.clearRect(-(55)*5,-(55)*6,canvas.width,canvas.height); + ctx.translate(-(55)*5,-(55)*6); + } + else if(PreviousX==="T3") + { + ctx.clearRect(-(30)* 10,-(30)*10,canvas.width,canvas.height); + ctx.translate(-(30)* 10,-(30)*10); + } + else + { + ctx.clearRect(-(40)* 7,-(40)*10,canvas.width,canvas.height); + ctx.translate(-(40)* 7,-(40)*10); + } + scriptForT4Dataset(0.125,0.125); + document.getElementById("t1").value=1.25; + document.getElementById("t2").value=0.625; + document.getElementById("t3").value=0; + document.getElementById("t4").value=0; + document.getElementById("t5").value=1.5; + document.getElementById("t6").value=0.5; + document.getElementById("t7").value=1; + document.getElementById("t8").value=0; + document.getElementById("t9").value=0.5; + document.getElementById("t10").value=1; + document.getElementById("t11").value=0; + document.getElementById("t12").value=1; + ctx.beginPath(); + ctx.ellipse((GridSize/0.125)*1.25,-(GridSize/0.125)*0.625,(GridSize/0.125)*(1.5/2),(GridSize/0.125)*(1/2),-0.5, 0, 2 * Math.PI); + ctx.stroke(); + ctx.beginPath(); + ctx.ellipse((GridSize/0.125)*1.25,-(GridSize/0.125)*0.625,0,(GridSize/0.125)*(1/2),-0.5, 0, 2 * Math.PI); + ctx.stroke(); + ctx.beginPath(); + ctx.ellipse((GridSize/0.125)*1.25,-(GridSize/0.125)*0.625,(GridSize/0.125)*(1.5/2),0,-0.5, 0, 2 * Math.PI); + ctx.stroke(); + ctx.beginPath(); + ctx.arc((GridSize/0.125) *0,-(GridSize/0.125) * 0, (GridSize/0.125) *(1/2), 0, Math.PI * 2, true); + ctx.strokeStyle= "red"; + ctx.stroke(); + PreviousX=x; + } + flag=0; +} +function generateForT2Dataset() +{ + var XAxisDistanceGridLines =14; + var YAxisDistanceGridLines = 10; + var XAxisStartingPoint =0.125; + var YAxisStartingPoint =0.125; + var GridSize=50; + if(flag===-1) + { + ctx.clearRect(-(GridSize)*2,-(GridSize)*10,canvas.width,canvas.height); + ctx.translate(-(GridSize)*2,-(GridSize)*10); + } + else + { + ctx.clearRect(-(GridSize)* YAxisDistanceGridLines,-25*XAxisDistanceGridLines,canvas.width,canvas.height); + ctx.translate(-(GridSize)* YAxisDistanceGridLines,-25*XAxisDistanceGridLines); + } + if(value1>0.625 || value2>1 || value3>0.625 || value4>1 ||value5>0.625 || value7>0.625 || value10>0.625 || value12>0.625) + { + XAxisStartingPoint=0.5; + YAxisStartingPoint=0.5; + } + scriptForT2Dataset(XAxisStartingPoint,YAxisStartingPoint); + var value1=document.getElementById("t1").value; + var value2=document.getElementById("t2").value; + var value3=document.getElementById("t3").value; + var value4=document.getElementById("t4").value; + var value5=document.getElementById("t5").value; + var value6=document.getElementById("t6").value; + var value7=document.getElementById("t7").value; + var value8=document.getElementById("t8").value; + var value9=document.getElementById("t9").value; + var value10=document.getElementById("t10").value; + var value11=document.getElementById("t11").value; + var value12=document.getElementById("t12").value; + var digit= /^\d+$/; + if((value1!=="" && value1.match(digit)) ||(value2!=="" && value2.match(digit)) ||(value3!=="" && value3.match(digit)) ||(value4!=="" && value4.match(digit)) ||(value5!=="" && value5.match(digit)) ||(value6!=="" && value6.match(digit)) ||(value7!=="" && value7.match(digit)) ||(value8!=="" && value8.match(digit)) ||(value9!=="" && value9.match(digit)) ||(value10!=="" && value10.match(digit)) ||(value11!=="" && value11.match(digit)) ||(value12!=="" && value12.match(digit)) ) + { + //condition to check whether circle is to be drawn or ellipse.For that the values of major and minor axis is compared.If equal then it is circle otherwise it is ellipse + //for class 1 + if (value5===value10 && value5===1) + { + load(); + } + else if(value5===value10 && value5>"0") + { + ctx.beginPath(); + ctx.arc((GridSize/XAxisStartingPoint) *value1,-(25/XAxisStartingPoint) * value2,(GridSize/XAxisStartingPoint) *(value5/2), 0, Math.PI * 2, true); + ctx.stroke(); + } + else + { + //for ellipse + if (value9===0 && value6===0) + { + if(value5value10) + { + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value1,-(25/XAxisStartingPoint)*value2,(GridSize/XAxisStartingPoint)*(value10/2),(25/XAxisStartingPoint)*(value5/2),0, 0, 2 * Math.PI); + ctx.stroke(); + } + else + { + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value1,-(25/XAxisStartingPoint)*value2,(GridSize/XAxisStartingPoint)*(value10/2),(25/XAxisStartingPoint)*(value5/2),-value6, 0, 2 * Math.PI); + ctx.stroke(); + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value1,-(25/XAxisStartingPoint)*value2,0,(25/XAxisStartingPoint)*(value5/2),-value6, 0, 2 * Math.PI); + ctx.stroke(); + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value1,-(25/XAxisStartingPoint)*value2,(GridSize/XAxisStartingPoint)*(value10/2),0,-value6, 0, 2 * Math.PI); + ctx.stroke(); + } + } + else if (value6===0) + { + if(value5value5) + { + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value1,-(25/XAxisStartingPoint)*value2,(GridSize/XAxisStartingPoint)*(value10/2),(25/XAxisStartingPoint)*(value5/2),-value9, 0, 2 * Math.PI); + ctx.stroke(); + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value1,-(25/XAxisStartingPoint)*value2,0,(25/XAxisStartingPoint)*(value5/2),-value9, 0, 2 * Math.PI); + ctx.stroke(); + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value1,-(25/XAxisStartingPoint)*value2,(GridSize/XAxisStartingPoint)*(value10/2),0,-value9, 0, 2 * Math.PI); + ctx.stroke(); + } + else + { + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value1,-(25/XAxisStartingPoint)*value2,(GridSize/XAxisStartingPoint)*(value5/2),(25/XAxisStartingPoint)*(value10/2),-value9, 0, 2 * Math.PI); + ctx.stroke(); + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value1,-(25/XAxisStartingPoint)*value2,0,(25/XAxisStartingPoint)*(value10/2),-value9, 0, 2 * Math.PI); + ctx.stroke(); + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value1,-(25/XAxisStartingPoint)*value2,(GridSize/XAxisStartingPoint)*(value5/2),0,-value9, 0, 2 * Math.PI); + ctx.stroke(); + } + + } + else + { + if(value5>value10) + { + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value1,-(25/XAxisStartingPoint)*value2,(GridSize/XAxisStartingPoint)*(value10/2),(25/XAxisStartingPoint)*(value5/2),-value9, 0, 2 * Math.PI); + ctx.stroke(); + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value1,-(25/XAxisStartingPoint)*value2,0,(25/XAxisStartingPoint)*(value5/2),-value9, 0, 2 * Math.PI); + ctx.stroke(); + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value1,-(25/XAxisStartingPoint)*value2,(GridSize/XAxisStartingPoint)*(value10/2),0,-value9, 0, 2 * Math.PI); + ctx.stroke(); + } + else + { + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value1,-(25/XAxisStartingPoint)*value2,(GridSize/XAxisStartingPoint)*(value5/2),(25/XAxisStartingPoint)*(value10/2),value6, 0, 2 * Math.PI); + ctx.stroke(); + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value1,-(25/XAxisStartingPoint)*value2,0,(25/XAxisStartingPoint)*(value10/2),value6, 0, 2 * Math.PI); + ctx.stroke(); + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value1,-(25/XAxisStartingPoint)*value2,(GridSize/XAxisStartingPoint)*(value5/2),0,value6, 0, 2 * Math.PI); + ctx.stroke(); + } + } + } + } + //for Class2 + if (value7===value12 && value7===1) + { + load(); + } + else if(value7===value12 && value7>"0") + { + ctx.beginPath(); + ctx.arc((GridSize/XAxisStartingPoint) *value3,-(25/XAxisStartingPoint) * value4,(GridSize/XAxisStartingPoint) *(value7/2), 0, Math.PI * 2, true); + ctx.strokeStyle= "red"; + ctx.stroke(); + } + else + { + //for ellipse + if (value8===0 && value11===0) + { + if(value7value12) + { + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value3,-(25/XAxisStartingPoint)*value4,(GridSize/XAxisStartingPoint)*(value12/2),(25/XAxisStartingPoint)*(value7/2),0, 0, 2 * Math.PI); + ctx.strokeStyle= "red"; + ctx.stroke(); + } + else + { + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value3,-(25/XAxisStartingPoint)*value4,(GridSize/XAxisStartingPoint)*(value12/2),(25/XAxisStartingPoint)*(value7/2),-value8, 0, 2 * Math.PI); + ctx.strokeStyle= "red"; + ctx.stroke(); + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value3,-(25/XAxisStartingPoint)*value4,0,(25/XAxisStartingPoint)*(value7/2),-value8, 0, 2 * Math.PI); + ctx.strokeStyle= "red"; + ctx.stroke(); + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value3,-(25/XAxisStartingPoint)*value4,(GridSize/XAxisStartingPoint)*(value12/2),0,-value8, 0, 2 * Math.PI); + ctx.strokeStyle= "red"; + ctx.stroke(); + } + } + else if (value8===0) + { + if(value7value12) + { + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value3,-(25/XAxisStartingPoint)*value4,(GridSize/XAxisStartingPoint)*(value12/2),(25/XAxisStartingPoint)*(value7/2),-value11, 0, 2 * Math.PI); + ctx.strokeStyle="red"; + ctx.stroke(); + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value3,-(25/XAxisStartingPoint)*value4,0,(25/XAxisStartingPoint)*(value7/2),-value11, 0, 2 * Math.PI); + ctx.strokeStyle="red"; + ctx.stroke(); + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value3,-(25/XAxisStartingPoint)*value4,(GridSize/XAxisStartingPoint)*(value12/2),0,-value11, 0, 2 * Math.PI); + ctx.strokeStyle="red"; + ctx.stroke(); + } + else + { + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value3,-(25/XAxisStartingPoint)*value4,(GridSize/XAxisStartingPoint)*(value7/2),(25/XAxisStartingPoint)*(value12/2),value8, 0, 2 * Math.PI); + ctx.strokeStyle="red"; + ctx.stroke(); + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value3,-(25/XAxisStartingPoint)*value4,0,(25/XAxisStartingPoint)*(value12/2),value8, 0, 2 * Math.PI); + ctx.strokeStyle="red"; + ctx.stroke(); + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value3,-(25/XAxisStartingPoint)*value4,(GridSize/XAxisStartingPoint)*(value7/2),0,value8, 0, 2 * Math.PI); + ctx.strokeStyle="red"; + ctx.stroke(); + } + } + } + + } +} +function generate() +{ + var GridSize=50; + var x=document.getElementById("s1").value; + var XAxisStartingPoint =0.125; + var YAxisStartingPoint =0.125; + var value1=document.getElementById("t1").value; + var value2=document.getElementById("t2").value; + var value3=document.getElementById("t3").value; + var value4=document.getElementById("t4").value; + var value5=document.getElementById("t5").value; + var value6=document.getElementById("t6").value; + var value7=document.getElementById("t7").value; + var value8=document.getElementById("t8").value; + var value9=document.getElementById("t9").value; + var value10=document.getElementById("t10").value; + var value11=document.getElementById("t11").value; + var value12=document.getElementById("t12").value; + if(x==="T1") + { + GridSize=55; + if(flag===-1) + { + ctx.clearRect(-(50)*2,-(50)*10,canvas.width,canvas.height); + ctx.translate(-(50)*2,-(50)*10); + } + else + { + ctx.clearRect(-(GridSize)*5,-(GridSize)*6,canvas.width,canvas.height); + ctx.translate(-(GridSize)*5,-(GridSize)*6); + } + if(value1>1 || value2>1 || value3>1 || value4>1 ||value5>1 || value7>1 || value10>1 || value12>1) + { + XAxisStartingPoint=1; + YAxisStartingPoint=2; + } + scriptForT1Dataset(XAxisStartingPoint,YAxisStartingPoint); + } + else if(x==="T3") + { + GridSize=30; + if(flag===-1) + { + ctx.clearRect(-(50)*2,-(50)*10,canvas.width,canvas.height); + ctx.translate(-(50)*2,-(50)*10); + } + else + { + ctx.clearRect(-(30)* 10,-(30)*10,canvas.width,canvas.height); + ctx.translate(-(30)* 10,-(30)*10); + } + if(value1>2 || value2>1.35 || value3>2 || value4>1.35 ||value5>2 || value7>2 || value10>2 || value12>2) + { + XAxisStartingPoint=0.5; + YAxisStartingPoint=0.5; + } + scriptForT3Dataset(XAxisStartingPoint,YAxisStartingPoint); + } + else if(x==="T4") + { + GridSize=40; + if(flag===-1) + { + ctx.clearRect(-(50)*2,-(50)*10,canvas.width,canvas.height); + ctx.translate(-(50)*2,-(50)*10); + } + else + { + ctx.clearRect(-(40)* 7,-(40)*10,canvas.width,canvas.height); + ctx.translate(-(40)* 7,-(40)*10); + } + if(value1>1.75 || value2>0.75 || value3>1.5 || value4>0.75 ||value5>2 || value7>2 || value10>2 || value12>2) + { + XAxisStartingPoint=0.5; + YAxisStartingPoint=0.5; + } + scriptForT4Dataset(XAxisStartingPoint,YAxisStartingPoint); + } + flag=1; + if(x!=="T2") + { + + var digit= /^\d+$/; + + if((value1!=="" && value1.match(digit)) ||(value2!=="" && value2.match(digit)) ||(value3!=="" && value3.match(digit)) ||(value4!=="" && value4.match(digit)) ||(value5!=="" && value5.match(digit)) ||(value6!=="" && value6.match(digit)) ||(value7!=="" && value7.match(digit)) ||(value8!=="" && value8.match(digit)) ||(value9!=="" && value9.match(digit)) ||(value10!=="" && value10.match(digit)) ||(value11!=="" && value11.match(digit)) ||(value12!=="" && value12.match(digit)) ) + { + //condition to check whether circle is to be drawn or ellipse.For that the values of major and minor axis is compared.If equal then it is circle otherwise it is ellipse + //for class 1 + if(value5===value10 && value5>'0' && value5!==1) + { + ctx.beginPath(); + ctx.arc((GridSize/XAxisStartingPoint) *value1,-(GridSize/XAxisStartingPoint) * value2,(GridSize/XAxisStartingPoint) *(value5/2), 0, Math.PI * 2, true); + ctx.stroke(); + } + else + { + //for ellipse + if (value9===0 && value6===0) + { + if(value5value10) + { + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value1,-(GridSize/XAxisStartingPoint)*value2,(GridSize/XAxisStartingPoint)*(value10/2),(GridSize/XAxisStartingPoint)*(value5/2),0, 0, 2 * Math.PI); + ctx.stroke(); + } + else + { + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value1,-(GridSize/XAxisStartingPoint)*value2,(GridSize/XAxisStartingPoint)*(value10/2),(GridSize/XAxisStartingPoint)*(value5/2),-value6, 0, 2 * Math.PI); + ctx.stroke(); + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value1,-(GridSize/XAxisStartingPoint)*value2,0,(GridSize/XAxisStartingPoint)*(value5/2),-value6, 0, 2 * Math.PI); + ctx.stroke(); + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value1,-(GridSize/XAxisStartingPoint)*value2,(GridSize/XAxisStartingPoint)*(value10/2),0,-value6, 0, 2 * Math.PI); + ctx.stroke(); + } + } + else if (value6===0) + { + if(value5value5) + { + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value1,-(GridSize/XAxisStartingPoint)*value2,(GridSize/XAxisStartingPoint)*(value10/2),(GridSize/XAxisStartingPoint)*(value5/2),-value9, 0, 2 * Math.PI); + ctx.stroke(); + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value1,-(GridSize/XAxisStartingPoint)*value2,0,(GridSize/XAxisStartingPoint)*(value5/2),-value9, 0, 2 * Math.PI); + ctx.stroke(); + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value1,-(GridSize/XAxisStartingPoint)*value2,(GridSize/XAxisStartingPoint)*(value10/2),0,-value9, 0, 2 * Math.PI); + ctx.stroke(); + } + else + { + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value1,-(GridSize/XAxisStartingPoint)*value2,(GridSize/XAxisStartingPoint)*(value5/2),(GridSize/XAxisStartingPoint)*(value10/2),-value9, 0, 2 * Math.PI); + ctx.stroke(); + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value1,-(GridSize/XAxisStartingPoint)*value2,0,(GridSize/XAxisStartingPoint)*(value10/2),-value9, 0, 2 * Math.PI); + ctx.stroke(); + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value1,-(GridSize/XAxisStartingPoint)*value2,(GridSize/XAxisStartingPoint)*(value5/2),0,-value9, 0, 2 * Math.PI); + ctx.stroke(); + } + + } + else + { + if(value5>value10) + { + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value1,-(GridSize/XAxisStartingPoint)*value2,(GridSize/XAxisStartingPoint)*(value10/2),(GridSize/XAxisStartingPoint)*(value5/2),-value9, 0, 2 * Math.PI); + ctx.stroke(); + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value1,-(GridSize/XAxisStartingPoint)*value2,0,(GridSize/XAxisStartingPoint)*(value5/2),-value9, 0, 2 * Math.PI); + ctx.stroke(); + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value1,-(GridSize/XAxisStartingPoint)*value2,(GridSize/XAxisStartingPoint)*(value10/2),0,-value9, 0, 2 * Math.PI); + ctx.stroke(); + } + else + { + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value1,-(GridSize/XAxisStartingPoint)*value2,(GridSize/XAxisStartingPoint)*(value5/2),(GridSize/XAxisStartingPoint)*(value10/2),value6, 0, 2 * Math.PI); + ctx.stroke(); + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value1,-(GridSize/XAxisStartingPoint)*value2,0,(GridSize/XAxisStartingPoint)*(value10/2),value6, 0, 2 * Math.PI); + ctx.stroke(); + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value1,-(GridSize/XAxisStartingPoint)*value2,(GridSize/XAxisStartingPoint)*(value5/2),0,value6, 0, 2 * Math.PI); + ctx.stroke(); + } + } + } + } + //for Class2 + if(value7===value12 && value7>'0' && value7!==1) + { + ctx.beginPath(); + ctx.arc((GridSize/XAxisStartingPoint) *value3,-(GridSize/XAxisStartingPoint) * value4,(GridSize/XAxisStartingPoint) *(value7/2), 0, Math.PI * 2, true); + ctx.strokeStyle= "red"; + ctx.stroke(); + } + else + { + //for ellipse + if (value8===0 && value11===0) + { + if(value7value12) + { + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value3,-(GridSize/XAxisStartingPoint)*value4,(GridSize/XAxisStartingPoint)*(value12/2),(GridSize/XAxisStartingPoint)*(value7/2),0, 0, 2 * Math.PI); + ctx.strokeStyle= "red"; + ctx.stroke(); + } + else + { + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value3,-(GridSize/XAxisStartingPoint)*value4,(GridSize/XAxisStartingPoint)*(value12/2),(GridSize/XAxisStartingPoint)*(value7/2),-value8, 0, 2 * Math.PI); + ctx.strokeStyle= "red"; + ctx.stroke(); + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value3,-(GridSize/XAxisStartingPoint)*value4,0,(GridSize/XAxisStartingPoint)*(value7/2),-value8, 0, 2 * Math.PI); + ctx.strokeStyle= "red"; + ctx.stroke(); + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value3,-(GridSize/XAxisStartingPoint)*value4,(GridSize/XAxisStartingPoint)*(value12/2),0,-value8, 0, 2 * Math.PI); + ctx.strokeStyle= "red"; + ctx.stroke(); + } + } + else if (value8===0) + { + if(value7value12) + { + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value3,-(GridSize/XAxisStartingPoint)*value4,(GridSize/XAxisStartingPoint)*(value12/2),(GridSize/XAxisStartingPoint)*(value7/2),-value11, 0, 2 * Math.PI); + ctx.strokeStyle="red"; + ctx.stroke(); + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value3,-(GridSize/XAxisStartingPoint)*value4,0,(GridSize/XAxisStartingPoint)*(value7/2),-value11, 0, 2 * Math.PI); + ctx.strokeStyle="red"; + ctx.stroke(); + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value3,-(GridSize/XAxisStartingPoint)*value4,(GridSize/XAxisStartingPoint)*(value12/2),0,-value11, 0, 2 * Math.PI); + ctx.strokeStyle="red"; + ctx.stroke(); + } + else + { + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value3,-(GridSize/XAxisStartingPoint)*value4,(GridSize/XAxisStartingPoint)*(value7/2),(GridSize/XAxisStartingPoint)*(value12/2),value8, 0, 2 * Math.PI); + ctx.strokeStyle="red"; + ctx.stroke(); + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value3,-(GridSize/XAxisStartingPoint)*value4,0,(GridSize/XAxisStartingPoint)*(value12/2),value8, 0, 2 * Math.PI); + ctx.strokeStyle="red"; + ctx.stroke(); + ctx.beginPath(); + ctx.ellipse((GridSize/XAxisStartingPoint)*value3,-(GridSize/XAxisStartingPoint)*value4,(GridSize/XAxisStartingPoint)*(value7/2),0,value8, 0, 2 * Math.PI); + ctx.strokeStyle="red"; + ctx.stroke(); + } + } + } + + } +} +else +{ + generateForT2Dataset(); +} +} +function markAllPoints() +{ + var SliderValue=document.getElementById("myRange").value; + var x=document.getElementById("s1").value; + var GridSize=50; + var XAxisDistanceGridLines =14; + var YAxisDistanceGridLines = 10; + load(); + if(x==="T1") + { + GridSize=55; + XAxisDistanceGridLines=6; + YAxisDistanceGridLines=5; + } + else if(x==="T3") + { + GridSize=30; + XAxisDistanceGridLines=10; + YAxisDistanceGridLines=10; + } + else if(x==="T4") + { + GridSize=40; + XAxisDistanceGridLines=10; + YAxisDistanceGridLines=7; + } + var XCoordinate=(Number(-((GridSize)* YAxisDistanceGridLines))+Number(SliderValue)); + if(x==="T2") + { + // Add behind elements. + ctx.globalCompositeOperation = "destination-over"; + ctx.fillStyle= "#A9A9A9"; + ctx.fillRect(-(GridSize)* YAxisDistanceGridLines,-25*XAxisDistanceGridLines,SliderValue,canvas.height); + ctx.fillStyle="#CD5C5C"; + ctx.fillRect(XCoordinate,-25*XAxisDistanceGridLines,canvas.width,canvas.height); + } + else + { + // Add behind elements. + ctx.globalCompositeOperation = "destination-over"; + ctx.fillStyle= "#A9A9A9"; + ctx.fillRect(-(GridSize)* YAxisDistanceGridLines,-(GridSize)*XAxisDistanceGridLines,SliderValue,canvas.height); + ctx.fillStyle="#CD5C5C"; + ctx.fillRect(XCoordinate,-(GridSize)*XAxisDistanceGridLines,canvas.width,canvas.height); + } +} +function clear() +{ + flag2=-1; + flag3=-1; + meanClass1X=0; + meanClass1Y=0; + pointsClass1=0; + covarianceClass1=0; + meanClass2X=0; + meanClass2Y=0; + pointsClass2=0; + covarianceClass2=0; + if(flag===0){ + load(); + } + else if(flag===1){ + generate(); + } +} +function marker(event) +{ + flag3=0; + markpoints(event); +} +function markpoints(event) +{ + if(flag!==-1 && flag2===0 && flag3===0) + { + var XCoordinate=event.clientX; + var YCoordinate=event.clientY; + var x=document.getElementById("s1").value; + if(x==="T1") + { + XCoordinate=Number(XCoordinate)-300; + YCoordinate=Number(YCoordinate)-400; + ctx.fillRect(XCoordinate,YCoordinate,10,10); + XCoordinate=(XCoordinate*0.125)/55; + YCoordinate=(YCoordinate*0.125)/55; + } + else if(x==="T2") + { + XCoordinate=Number(XCoordinate)-530; + YCoordinate=Number(YCoordinate)-415; + ctx.fillRect(XCoordinate,YCoordinate,10,10); + XCoordinate=(XCoordinate*0.125)/50; + YCoordinate=(YCoordinate*0.125)/50; + } + else if(x==="T3") + { + XCoordinate=Number(XCoordinate)-330; + YCoordinate=Number(YCoordinate)-370; + ctx.fillRect(XCoordinate,YCoordinate,10,10); + XCoordinate=(XCoordinate*0.125)/30; + YCoordinate=(YCoordinate*0.125)/30; + } + else + { + XCoordinate=Number(XCoordinate)-300; + YCoordinate=Number(YCoordinate)-470; + ctx.fillRect(XCoordinate,YCoordinate,10,10); + XCoordinate=(XCoordinate*0.125)/40; + YCoordinate=(YCoordinate*0.125)/40; + } + YCoordinate=YCoordinate*(-1); + if(ctx.fillStyle==="#000000") + { + pointsClass1++; + meanClass1X=(meanClass1X+Number(XCoordinate))/pointsClass1; + meanClass1Y=(meanClass1Y+Number(YCoordinate))/pointsClass1; + covarianceClass1=(covarianceClass1+Number((XCoordinate-Number(meanClass1X))*(YCoordinate-Number(meanClass1Y))))/pointsClass1; + } + else + { + pointsClass2++; + meanClass2X=(meanClass2X+Number(XCoordinate))/pointsClass2; + meanClass2Y=(meanClass2Y+Number(YCoordinate))/pointsClass2; + covarianceClass2=(covarianceClass2+Number((XCoordinate-Number(meanClass2X))*(YCoordinate-Number(meanClass2Y))))/pointsClass2; + } + // meanClass1X=meanClass1X.toFixed(2); + // meanClass1Y=meanClass1Y.toFixed(2); + // meanClass2X=meanClass2X.toFixed(2); + // meanClass2Y=meanClass2Y.toFixed(2); + // covarianceClass1=covarianceClass1.toFixed(2); + // covarianceClass2=covarianceClass2.toFixed(2); + // var answer="
Class1Class2
Mean"+meanClass1X+""+meanClass1Y+""+meanClass2X+""+meanClass2Y+"
Covariance"+covarianceClass1+""+covarianceClass2+"
"; + var answer="Mean and Covariance Results:-
"+"                        Class 1            Class2
Mean            
("+meanClass1X.toFixed(3)+","+meanClass1Y.toFixed(3)+")"+"      ("+meanClass2X.toFixed(3)+","+meanClass2Y.toFixed(3)+")"+"
"+"Covariance   "+covarianceClass1.toFixed(3)+"                  "+covarianceClass2.toFixed(3); + document.getElementById("meanresult").innerHTML=answer; + } +} + +function mark(event) +{ + flag2=0; + flag3=-1; + ctx.fillStyle="black"; + markpoints(event); +} +function markp(event) +{ + flag2=0; + flag3=-1; + ctx.fillStyle="red"; + markpoints(event); +} +function resizeAxis() +{ + var x=document.getElementById("s1").value; + var GridSize=50; + var XAxisDistanceGridLines =14; + var YAxisDistanceGridLines = 10; + if (flag===0) + { + if(x==="T1") + { + GridSize=55; + XAxisDistanceGridLines=6; + YAxisDistanceGridLines=5; + } + else if(x==="T3") + { + GridSize=30; + XAxisDistanceGridLines=10; + YAxisDistanceGridLines=10; + } + else if(x==="T4") + { + GridSize=40; + XAxisDistanceGridLines=10; + YAxisDistanceGridLines=7; + } + if(x==="T2") + { + ctx.clearRect(-(GridSize)* YAxisDistanceGridLines,-25*XAxisDistanceGridLines,(GridSize)* (Number(YAxisDistanceGridLines)-1),canvas.height); + ctx.clearRect(-(GridSize)* YAxisDistanceGridLines,25,canvas.width,canvas.height); + } + else + { + ctx.clearRect(-(GridSize)* YAxisDistanceGridLines,-(GridSize)*XAxisDistanceGridLines,(GridSize)* (Number(YAxisDistanceGridLines)-1),canvas.height); + ctx.clearRect(-(GridSize)* YAxisDistanceGridLines,(GridSize),canvas.width,canvas.height); + } + } +} +function bayesian() +{ + var value1=document.getElementById("t1").value; + var value2=document.getElementById("t2").value; + var value3=document.getElementById("t3").value; + var value4=document.getElementById("t4").value; + var value5=document.getElementById("t5").value; + var value6=document.getElementById("t6").value; + var value7=document.getElementById("t7").value; + var value8=document.getElementById("t8").value; + var value9=document.getElementById("t9").value; + var value10=document.getElementById("t10").value; + var value11=document.getElementById("t11").value; + var value12=document.getElementById("t12").value; + var digit= /^\d+$/; + if((value1!=="" && value1.match(digit)) ||(value2!=="" && value2.match(digit)) ||(value3!=="" && value3.match(digit)) ||(value4!=="" && value4.match(digit)) ||(value5!=="" && value5.match(digit)) ||(value6!=="" && value6.match(digit)) ||(value7!=="" && value7.match(digit)) ||(value8!=="" && value8.match(digit)) ||(value9!=="" && value9.match(digit)) ||(value10!=="" && value10.match(digit)) ||(value11!=="" && value11.match(digit)) ||(value12!=="" && value12.match(digit)) ) + { + var area1=0; + var area2=0; + //for class1 + if(value5===value10 && value5>"0") + { + area1=Math.PI*value5*value5; + } + else + { + area1=Math.PI*value5*value10; + } + //for class 2 + if(value7===value12 && value12>"0") + { + area2=Math.PI*value7*value7; + } + else + { + area2=Math.PI*value7*value12; + } + var totalArea=Number(area1)+Number(area2); + var answer="Bayesian Classification Results:-
"+"For Class 1= "+(area1/totalArea)+"
"+"For Class 2= "+(area2/totalArea); + document.getElementById("result").innerHTML=answer; + } +} +document.getElementById("b1").addEventListener("click",load); +document.getElementById("b5").addEventListener("click",generate); +document.getElementById("b3").addEventListener("click",markAllPoints); +document.getElementById("b4").addEventListener("click",clear); +document.getElementById("b2").addEventListener("click",mark); +document.getElementById("b2a").addEventListener("click",markp); +document.getElementById("b6").addEventListener("click",resizeAxis); +document.getElementById("b7").addEventListener("click",bayesian); + diff --git a/SRIP/Codes/README.txt b/SRIP/Codes/README.txt new file mode 100644 index 00000000..69a01651 --- /dev/null +++ b/SRIP/Codes/README.txt @@ -0,0 +1,13 @@ +Repository Details:- +Created ->> 16 May 2019 +Creater ->>Shubham Agarwal +Objective ->> SRIP Projects +Project Number ->>1 +Project Topic ->> Bayesian Classification Simulator + +TO RUN THE EXPERIMENT OF BAYESIAN CLASSIFICATION: +1. Download the SRIP folder +2. Go to Codes folder +3. Run the .html file + +HTML file will open in the browser and all functionalities will run from the HTML file. \ No newline at end of file diff --git a/SRIP/Codes/SRIP PROJECT 1 DOCUMENTATION.pdf b/SRIP/Codes/SRIP PROJECT 1 DOCUMENTATION.pdf new file mode 100644 index 00000000..81dcf43b Binary files /dev/null and b/SRIP/Codes/SRIP PROJECT 1 DOCUMENTATION.pdf differ diff --git a/SRIP/Codes/Script.js b/SRIP/Codes/Script.js new file mode 100644 index 00000000..73c7cef1 --- /dev/null +++ b/SRIP/Codes/Script.js @@ -0,0 +1,683 @@ +// var XAxisStartingPoint = { number: 0.125}; +// var YAxisStartingPoint = { number: 0.125}; + +var canvas = document.getElementById("myChart"); +var ctx = canvas.getContext("2d"); + +// canvas width +var CanvasWidth = canvas.width; + +// canvas height +var CanvasHeight = canvas.height; + +function script(XAxisStartingPoint,YAxisStartingPoint) +{ + var GridSize = 50; + var XAxisDistanceGridLines =10; + var YAxisDistanceGridLines = 2; + ctx.fillStyle="#000000"; + XAxisStartingPoint=Number(XAxisStartingPoint); + YAxisStartingPoint=Number(YAxisStartingPoint); + // no of vertical grid lines +var NumLinesX = Math.floor(CanvasHeight/GridSize); + +// no of horizontal grid lines +var NumLinesY = Math.floor(CanvasWidth/GridSize); +var i=0; +// Draw grid lines along X-axis +for(i=0; i<=NumLinesX; i++) + { + ctx.beginPath(); + ctx.lineWidth = 1; + + // If line represents X-axis draw in different color + if(i === XAxisDistanceGridLines) { + ctx.strokeStyle = "#000000"; + } + else{ + ctx.strokeStyle = "#e9e9e9"; + } + + if(i === NumLinesX) { + ctx.moveTo(0, GridSize*i); + ctx.lineTo(CanvasWidth, GridSize*i); + } + else { + ctx.moveTo(0, GridSize*i+0.5); + ctx.lineTo(CanvasWidth, GridSize*i+0.5); + } + ctx.stroke(); +} +// Draw grid lines along Y-axis +for(i=0; i<=NumLinesY; i++) { + ctx.beginPath(); + ctx.lineWidth = 1; + + // If line represents X-axis draw in different color + if(i === YAxisDistanceGridLines) { + ctx.strokeStyle = "#000000"; + } + else{ + ctx.strokeStyle = "#e9e9e9"; + } + + if(i === NumLinesY) { + ctx.moveTo(GridSize*i, 0); + ctx.lineTo(GridSize*i, CanvasHeight); + } + else { + ctx.moveTo((GridSize*i)+0.5, 0); + ctx.lineTo((GridSize*i)+0.5, CanvasHeight); + } + ctx.stroke(); +} +// Translate to the new origin. Now Y-axis of the canvas is opposite to the Y-axis of the graph. So the y-coordinate of each element will be negative of the actual +ctx.translate(YAxisDistanceGridLines*GridSize, XAxisDistanceGridLines*GridSize); + +// Ticks marks along the positive X-axis +for(i=1; i<(NumLinesY - YAxisDistanceGridLines); i++) { + ctx.beginPath(); + ctx.lineWidth = 1; + ctx.strokeStyle = "#000000"; + + // Draw a tick mark 6px long (-3 to 3) + ctx.moveTo((GridSize*i)+0.5, -3); + ctx.lineTo((GridSize*i)+0.5, 3); + ctx.stroke(); + + // Text value at that point + ctx.font = "9px Arial"; + ctx.textAlign = "center"; + ctx.fillText(XAxisStartingPoint*i, GridSize*i, 15); +} +// Ticks marks along the negative X-axis +for(i=1; i + + + + + +Pattern Recognition:Bayesian Classification + + + + + + + + +
+
+ + +
+ +
+ + + +
+
+
+ + + +
+
+ +Mark Points
+
+
+ +

+ +

Class 1				 Class 2 
+ +

+
+ + + + +
+
+ +Generate Random Values
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Class 1Class 2
Mean
Co-Variance
+ +
+
+
+
+
+ + \ No newline at end of file diff --git a/SRIP/Quiz/Quiz.css b/SRIP/Quiz/Quiz.css new file mode 100644 index 00000000..caafb485 --- /dev/null +++ b/SRIP/Quiz/Quiz.css @@ -0,0 +1,174 @@ +{ + +border: 1px dotted black; + +} + +p.question { + +font-family: Arial, sans-serif; + +font-size:20px; + +color: #2E2E2E; + +margin-bottom:0px; + +} + + +h1.Header { + +font-family: Arial, sans-serif; + +font-weight:normal; + +font-size:25px; + +line-height: 27px; + +margin: 24px 0 12px 0; + +padding: 0 0 4px 0; + +border-bottom: 1px solid #a2a2a2; + +} + + +h2.quizScore{ + +font-family: Arial, sans-serif; + +font-size:25px; + +} + + +div.quizAnswers{ + +font-family: Arial, sans-serif; + +font-size:16px; + +color: #424242; + +padding: 4px 0 4px 0; + +} + + +label { + +font-family: Arial, sans-serif; + +font-size:14px; + +color: #424242; + +vertical-align:top; + +} + + +input.answer[type="radio"] { + +margin-bottom: 10px; + +} + +input.quizSubmit[type="submit"] { + +-webkit-background-clip: border-box; + +-webkit-background-origin: padding-box; + +-webkit-background-size: auto; + +-webkit-transition-delay: 0s, 0s; + +-webkit-transition-duration: 0.2s, 0.2s; + +-webkit-transition-property: color, background-color; + +-webkit-transition-timing-function: ease, ease; + +box-shadow: rgba(0, 0, 0, 0.498039) 0px 0px 5px 0px; + +color: #ffffff; + +background-color: #c30b0a; + +margin: 0; + +border: 0; + +outline: 0; + +text-transform:uppercase; + +height:35px; + +width:85px; + +border: 1px solid #5E5E5E; + +border-radius:5px; + +} + + +input.quizSubmit[type="submit"]:hover { + +color: #ffffff; + +background: #680f11; + +text-decoration: none; + +} + + +table { + +background-color: #F2F2F2; + +border:1px solid #BDBDBD; + +border-radius:5px; + +padding:10px; + +padding-left:25px; + +box-shadow: rgba(0, 0, 0, 0.498039) 0px 0px 1px 0px; + +} + + +th { + +} + + +tr { + +} + + +td { + +} + +.submitter { + +width:85px; + +} + + +.hide { + +display:none; + +} \ No newline at end of file diff --git a/SRIP/Quiz/Quiz.htm b/SRIP/Quiz/Quiz.htm new file mode 100644 index 00000000..14c56e1d --- /dev/null +++ b/SRIP/Quiz/Quiz.htm @@ -0,0 +1,542 @@ + + +Quiz on Experiment- Bayesian Classification + + + + + + +

Lets Quiz!

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

1.Bayesian classifiers is:-

+
    + + +
    + + +
    + + +
    + + +
+
+
+
+

2. What does the bayesian network provides?

+
    + + +
    + + +
    + + +
    + + +
+
+
+
+

3. How the bayesian network can be used to answer any query?

+ +
    + + +
    + + +
    + + +
    + + +
+
+
+
+

4.What is the consequence between a node and its predecessors while creating bayesian network?

+
    + + +
    + + +
    + + +
    + + +
+
+
+
+

5.How many terms are required for building a bayes model?

+
    + + +
    + + +
    + + +
    + + +
+
+
+
+

6.What is needed to make probabilistic systems feasible in the world?

+
    + + +
    + + +
    + + +
    + + +
+
+
+
+

7.Where does the bayes rule can be used?

+
    + + +
    + + +
    + + +
    + + +
+
+
+
+

8. How the entries in the full joint probability distribution can be calculated?

+
    + + +
    + + +
    + + +
    + + +
+
+
+
+

9. How the compactness of the bayesian network can be described?

+
    + + +
    + + +
    + + +
    + + +
+
+
+
+

10.To which does the local structure is associated?

+
    + + +
    + + +
    + + +
    + + +
+
+
+
+

11.With Bayes classifier, missing data items are:-

+
    + + +
    + + +
    + + +
    + + +
+
+
+
+

12. Naive prediction is:-

+
    + + +
    + + +
    + + +
    + + +
+
+
+
+

13.With the application of Bayesian methods, the most probable repeat length and evolutionary time since the repeat was formed may be derived.

+
    + + +
    + + +
+
+
+
+

14.If the purpose is to calculate the probability of one event and a second event, the odds scores for the events are

+
    + + +
    + + +
    + + +
    + + +
+
+
+
+

15. In Bayesian methods, difficulty with making estimations is that the estimate depends on the +Assumption– The mutation rate in sequences has been constant with time and that the rate of mutation of all nucleotides is the same:-

+
    + + +
    + + +
+
+
+
+

16. Which of the following feature of Bayesian methods is the disadvantage of it?

+
    + + +
    + + +
    + + +
    + + +
+
+
+
+

17.Which of the following statements about Naive Bayes is incorrect?

+
    + + +
    + + +
    + + +
    + + +
+
+
+
+

18. Previous probabilities in Bayes Theorem that are changed with help of new available information are classified as

+
    + + +
    + + +
    + + +
    + + +
+
+
+
+

19.Three companies A, B and C supply 25%, 35% and 40% of the notebooks to a school. Past experience shows that 5%, 4% and 2% of the notebooks produced by these companies are defective. If a notebook was found to be defective, what is the probability that the notebook was supplied by A?

+
    + + +
    + + +
    + + +
    + + +
+
+
+
+

20. Two boxes containing candies are placed on a table. The boxes are labelled B1 and B2. Box B1 contains 7 cinnamon candies and 4 ginger candies. Box B2 contains 3 cinnamon candies and 10 pepper candies. The boxes are arranged so that the probability of selecting box B1 is 1⁄3 and the probability of selecting box B2 is 2⁄3. Suresh is blindfolded and asked to select a candy. He will win a colour TV if he selects a cinnamon candy. What is the probability that Suresh will win the TV (that is, she will select a cinnamon candy)?

+
    + + +
    + + +
    + + +
    + + +
+
+
+
+

21. Suppose box A contains 4 red and 5 blue coins and box B contains 6 red and 3 blue coins. A coin is chosen at random from the box A and placed in box B. Finally, a coin is chosen at random from among those now in box B. What is the probability a blue coin was transferred from box A to box B given that the coin chosen from box B is red?

+
    + + +
    + + +
    + + +
    + + +
+
+
+
+

22. An urn B1 contains 2 white and 3 black chips and another urn B2 contains 3 white and 4 black chips. One urn is selected at random and a chip is drawn from it. If the chip drawn is found black, find the probability that the urn chosen was B1.

+
    + + +
    + + +
    + + +
    + + +
+
+
+
+

23.At a certain university, 4% of men are over 6 feet tall and 1% of women are over 6 feet tall. The total student population is divided in the ratio 3:2 in favour of women. If a student is selected at random from among all those over six feet tall, what is the probability that the student is a woman?

+
    + + +
    + + +
    + + +
    + + +
+
+
+
+

24. Two boxes containing candies are placed on a table. The boxes are labelled B1 and B2. Box B1 contains 7 cinnamon candies and 4 ginger candies. Box B2 contains 3 cinnamon candies and 10 pepper candies. The boxes are arranged so that the probability of selecting box B1 is 1⁄3 and the probability of selecting box B2 is 2⁄3. Suresh is blindfolded and asked to select a candy. He will win a colour TV if he selects a cinnamon candy. If he wins a colour TV, what is the probability that the marble was from the first box?

+
    + + +
    + + +
    + + +
    + + +
+
+
+
+

25.At a certain university, 4% of men are over 6 feet tall and 1% of women are over 6 feet tall. The total student population is divided in the ratio 3:2 in favour of women. If a student is selected at random from among all those over six feet tall, what is the probability that the student is a woman?

+
    + + +
    + + +
    + + +
    + + +
+
+
+ +
+ +
+ + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + +
+

+
+ + + + \ No newline at end of file diff --git a/SRIP/Quiz/Quiz.js b/SRIP/Quiz/Quiz.js new file mode 100644 index 00000000..89ca6e37 --- /dev/null +++ b/SRIP/Quiz/Quiz.js @@ -0,0 +1,122 @@ +function submitQuiz() +{ + // get each answer + function answerScore (qName) { + var radioNumber = document.getElementsByName(qName); + + for (var i = 0, length = radioNumber.length; i < length; i++) { + if (radioNumber[i].checked) + { + var answerValue = Number(radioNumber[i].value); + } + } + if (isNaN(answerValue)) + { + answerValue = 0; + } + return answerValue; + } + + // calcualte score with answerScore function + var calculateScore = (answerScore('q1') + answerScore('q2') + answerScore('q3') + answerScore('q4')+ answerScore('q5')+ answerScore('q6')+ answerScore('q7')+ answerScore('q8')+ answerScore('q9')+ answerScore('q10')+ answerScore('q11')+ answerScore('q12')+ answerScore('q13')+ answerScore('q14')+ answerScore('q15')+ answerScore('q16')+ answerScore('q17')+ answerScore('q18')+ answerScore('q19')+ answerScore('q20')+ answerScore('q21')+ answerScore('q22')+ answerScore('q23')+ answerScore('q24')+ answerScore('q25')); + + // function to return correct answer string + function correctAnswer (correctStringNo, qNumber) { + return ("The correct answer for question " + qNumber+":-" + "" + (document.getElementById(correctStringNo).htmlFor) + ""); + } + + // print correct answers only if wrong (calls correctAnswer function) + if (answerScore('q1') === 0) { + document.getElementById('correctAnswer1').innerHTML = correctAnswer('correctString1', 1); + } + if (answerScore('q2') === 0) { + document.getElementById('correctAnswer2').innerHTML = correctAnswer('correctString2', 2); + } + if (answerScore('q3') === 0) { + document.getElementById('correctAnswer3').innerHTML = correctAnswer('correctString3', 3); + } + if (answerScore('q4') === 0) { + document.getElementById('correctAnswer4').innerHTML = correctAnswer('correctString4', 4); + } + if (answerScore('q5') === 0) { + document.getElementById('correctAnswer5').innerHTML = correctAnswer('correctString5', 5); + } + if (answerScore('q6') === 0) { + document.getElementById('correctAnswer6').innerHTML = correctAnswer('correctString6', 6); + } + if (answerScore('q7') === 0) { + document.getElementById('correctAnswer7').innerHTML = correctAnswer('correctString7', 7); + } + if (answerScore('q8') === 0) { + document.getElementById('correctAnswer8').innerHTML = correctAnswer('correctString8', 8); + } + if (answerScore('q9') === 0) { + document.getElementById('correctAnswer9').innerHTML = correctAnswer('correctString9', 9); + } + if (answerScore('q10') === 0) { + document.getElementById('correctAnswer10').innerHTML = correctAnswer('correctString10', 10); + } + if (answerScore('q11') === 0) { + document.getElementById('correctAnswer11').innerHTML = correctAnswer('correctString11', 11); + } + if (answerScore('q12') === 0) { + document.getElementById('correctAnswer12').innerHTML = correctAnswer('correctString12', 12); + } + if (answerScore('q13') === 0) { + document.getElementById('correctAnswer13').innerHTML = correctAnswer('correctString13', 13); + } + if (answerScore('q14') === 0) { + document.getElementById('correctAnswer14').innerHTML = correctAnswer('correctString14', 14); + } + if (answerScore('q15') === 0) { + document.getElementById('correctAnswer15').innerHTML = correctAnswer('correctString15', 15); + } + if (answerScore('q16') === 0) { + document.getElementById('correctAnswer16').innerHTML = correctAnswer('correctString16', 16); + } + if (answerScore('q17') === 0) { + document.getElementById('correctAnswer17').innerHTML = correctAnswer('correctString17', 17); + } + if (answerScore('q18') === 0) { + document.getElementById('correctAnswer18').innerHTML = correctAnswer('correctString18', 18); + } + if (answerScore('q19') === 0) { + document.getElementById('correctAnswer19').innerHTML = correctAnswer('correctString19', 19); + } + if (answerScore('q20') === 0) { + document.getElementById('correctAnswer20').innerHTML = correctAnswer('correctString20', 20); + } + if (answerScore('q21') === 0) { + document.getElementById('correctAnswer21').innerHTML = correctAnswer('correctString21', 21); + } + if (answerScore('q22') === 0) { + document.getElementById('correctAnswer22').innerHTML = correctAnswer('correctString22', 22); + } + if (answerScore('q23') === 0) { + document.getElementById('correctAnswer23').innerHTML = correctAnswer('correctString23', 23); + } + if (answerScore('q24') === 0) { + document.getElementById('correctAnswer24').innerHTML = correctAnswer('correctString24', 24); + } + if (answerScore('q25') === 0) { + document.getElementById('correctAnswer25').innerHTML = correctAnswer('correctString25', 25); + } + + + // calculate "possible score" integer + var questionCountArray = document.getElementsByClassName('question'); + + var questionCounter = 0; + for (var i = 0, length = questionCountArray.length; i < length; i++) { + questionCounter++; + } + + // show score as "score/possible score" + var showScore = "Your Score: " + calculateScore +"/" + questionCounter; + // for perfect score + if (calculateScore === questionCounter) { + showScore = showScore + "  Perfect Score!"; + } + document.getElementById('userScore').innerHTML = showScore; + } + diff --git a/SRIP/README.txt b/SRIP/README.txt new file mode 100644 index 00000000..69a01651 --- /dev/null +++ b/SRIP/README.txt @@ -0,0 +1,13 @@ +Repository Details:- +Created ->> 16 May 2019 +Creater ->>Shubham Agarwal +Objective ->> SRIP Projects +Project Number ->>1 +Project Topic ->> Bayesian Classification Simulator + +TO RUN THE EXPERIMENT OF BAYESIAN CLASSIFICATION: +1. Download the SRIP folder +2. Go to Codes folder +3. Run the .html file + +HTML file will open in the browser and all functionalities will run from the HTML file. \ No newline at end of file diff --git a/SRIP/SRIP PROJECT 1 DOCUMENTATION.pdf b/SRIP/SRIP PROJECT 1 DOCUMENTATION.pdf new file mode 100644 index 00000000..81dcf43b Binary files /dev/null and b/SRIP/SRIP PROJECT 1 DOCUMENTATION.pdf differ diff --git a/src/lab/Experiments.html b/src/lab/Experiments.html index 74054df5..1f872db4 100644 --- a/src/lab/Experiments.html +++ b/src/lab/Experiments.html @@ -40,7 +40,7 @@ - + @@ -56,16 +56,16 @@ --> @@ -88,12 +88,12 @@
-

Computer Science & Engineering

+

Computer Science & Engineering

+

Introduction

Experiments

Prerequisites

Related Courses

Software Needed

Feedback

@@ -174,7 +174,7 @@

U --> - Community + Community Sakshat Portal Outreach Portal @@ -186,8 +186,8 @@

U -->

Contact us

- Feedback - support@vlabs.ac.in + support@vlabs.ac.in