WEB7(OJ7) Machine Learning (ML)
What is Machine Learning?
Machine Learning is the most popular technique of predicting the future or
classifying information to help people in making necessary decisions.
Machine Learning algorithms are trained over instances or examples through
which they learn from past experiences and also analyze the historical data.
Therefore, as it trains over the examples, again and again, it is able to identify
patterns in order to make predictions about the future.
What is meant by machinelearning ?
Machine learning is an application of artificial intelligence (AI) that provides systems
the ability to automatically learn and improve from experience without being explicitly programmed.
Machine learning focuses on the development of computer programs that can access data and use it learn for themselves.
What is Machine Learning with an example?
For example, medical diagnosis, image processing, prediction, classification, learning association, regression etc.
The intelligent systems built on machine learning algorithms have the capability to learn from past experience or historical data.
Why Machine Learning?
The world today is evolving and so are the needs and requirements of people.
Furthermore, we are witnessing a fourth industrial revolution of data.
In order to derive meaningful insights from this data and learn from the way
in which people and the system interface with the data, we need computational algorithms
that can churn the data and provide us with results that would benefit us in various ways.
Machine Learning has revolutionized industries like medicine, healthcare, manufacturing,
banking, and several other industries. Therefore, Machine Learning has become an essential part of modern industry.
FAQS
Why i don't focus Machinelearning /Automation at console application?
Since that is useless and not advanced. That has no security. But that is used only for testing with WEB7(OJ7) shell prompt.
About WEB7(OJ7) Machine learning
WEB7(OJ7) MachineLearning with Webapplication is a new concept wilmix jemin j
has designed.In machine learning with console , where one can optimize the source code as 2 lines.
But in case of Web application with MachineLearning can fail.
That why WEB7(OJ7) Machine Learning with Webapplication code can be kept as medium..
This new concept is introduced by wilmix jemin j at year 2016.
That's why i maintained the rules for WEB7(OJ7) Developers...
Rules For WEB7(OJ7) Developers for WEB7(OJ7) MachineLearning/WebApplication is
A) A WEB7(OJ7) code may be medium since it is focused for web application
b) Mostly follow Corejavac7 <filename.web> to write a short code..
c) Involve in writing your own logic for for loop or any WEB7(OJ7) - loop..
d) Test the WEB7(OJ7) program using WEB7(OJ7)Shell prompt.
e)Mostly Use WEB7(OJ7) libraries...
f) Try to write a WEB7(OJ7)-java7 logic and convert to .dll package
and use it in corejavac7 <filename.web> program. so that your code will be minimised as 10 or 2 lines..
g) Also construct your user defined libraries (.dll) and use it in WEB7(OJ7)(filename.web).
===============================================================================
Sample A : WEB7(OJ7) Introduction with machine learning syntax with
user friendly framework OJ7UA (WEB7(OJ7) userfriendly Application).
================================================================================
Syntax for WEB7(OJ7) Machine Learning program
<filename>.oj7ua
<OJ7ML> // Beginning of WEB7(OJ7) ML Program
<DESIGN
// Design is the HTML GUI or variable declarations or method declarations
// SRC include methods declarations
SRC='
// Method declarations
public static void Methods1()
{
j7out.println("");
}
'>
//Close Design for GUI
</DESIGN>
//Mention name of Package value in Package always mention wnosql as a default value for the Database.
// Mention WEB7(OJ7) library files for machine Learning in J7Lib eg) Java7ML
// Mention Package as ML , Names as sampleml1 for namespace name and class name as misctype1
// Mention Type as .exe or .dll
<OakJava7 Package='ML' Database='wnosql' J7Lib='{Java7ML}' Names='sampleml1,misctype1' Type='exe'
//Mention MAIN section for WEB7(OJ7) main program ie) public void main() can be written as MAIN
// Mention what are the Business logic methods inside the main program eg) Methods1(),Methods2() in the MAIN section
MAIN='
// Methods call
Methods1();
Methods2();
// This ( ?> ) is equivalent to }}.Close the Main Section
?> '
//LOGIC sections represent Business Logic for WEB7(OJ7)
LOGIC='
//Business logic methods
public static void Method2()
{
<!----- write Business Logic and use WEB7(OJ7) Servlet ----!>
}
// Close the Logic section
'>
// Close the WEB7(OJ7) program
</OakJava7>
// End of WEB7(OJ7)Program
</OJ7ML>
Explanation
Here when you code the Machine Learning program using this syntax and compile it using corejavac7 <filename.oj7ua> ,
it will automatically convert to WEB7(OJ7)program ie(.web) . And you will get a optimized WEB7(OJ7) (.web) code and .exe and .ojava7 files.
You can also test the WEB7(OJ7) Machine Learning program using generated (.web) code...So when we notice that here <OJ7ML> act like a
WEB7(OJ7) user friendly framework. It act like a XML syntax with data present inside it.
This WEB7(OJ7) Machine Learning program (<OJ7ML) will automatically generate (.web). This (<OJ7ML>) program has attractive syntax.So it is considered as a WEB7(OJ7) advanced framework or
WEB7(OJ7) Machine learning framework. It reduces the pain of writing program for (.web).
And It saves time and cost.The Full form of <OJ7ML> syntax is "WEB7(OJ7) MACHINELEARNING".
It is used for Dynamic Webpages construction ie) DB with GUI + Business Logic and WEB7(OJ7) Servlet.
We can also generate .dll using this syntax by using .dll value as a Type.
So when you include .exe value as a Type means when you compile the WEB7(OJ7)
it will generate the .exe files and .ojava7 files.
Now let us see a example about creating dummy logic which is dummy.oj7ua
....
================================================================================
Q) Write a dummmy oakjava7 Program using OJ7UA framework.
and Explain how it works when compared to .web oakjava7 program.
dummy.oj7ua
<OJ7ML>
<DESIGN
SRC='
'>
</DESIGN>
<OakJava7 Package='ML' Database='wnosql' J7Lib='{Java7MLGraphics}' Names='graphicsa,Bernoulli5' Type='exe' MAIN=' Bernoulli.Draw(32, 1000, 0, 0.2); ?> '
LOGIC='
'>
</OakJava7>
</OJ7ML>
Explanation
In this dummy.oj7ua program we make DESIGN part as empty and LOGIC part as empty.
And we have written only one statement in the Main ie) Bernoulli.Draw(32, 1000, 0, 0.2);
So According to WEB7(OJ7) machine learning the statements given below is configuration
statements in Oj7ua framework.
<OJ7ML> , <DESIGN SRC=' '> </DESIGN>
and we see LOGIC=' '>, </OakJava7> </OJ7ML>
so only the WEB7(OJ7) Beautiful statements given below is considered as only 1 line.
<OakJava7 Package='ML' Database='wnosql' J7Lib='{Java7MLGraphics}' Names='graphicsa,Bernoulli5' Type='exe' MAIN=' Bernoulli.Draw(32, 1000, 0, 0.2); ?> '
(Note: when we use in notepad or any editor this statement will fit in one line....)
When you define LOGIC with methods and in SRC is considered as statements.
So we write a optimized code for Bernouli5.oj7ua with 1 line using Oj7ua framework
when compared to 13 lines in Sample-2 (Bernoulli.web) Bernouli Distribution. So Oj7ua framework
will not throw any error when you define Dummy logic without html , and Logic methods.
kindly read Sample -1 .... describes how to write optimize code using .Oj7ua
That's about WEB7(OJ7) Machine learning concepts..
How WEB7(OJ7) Program Works with UserFriendly Framework(OJ7UA) ? Explain with
an example ?
WEB7(OJ7) Program (.Web) is automatically generated by User Friendly Framework(OJ7UA).
For eg)
linegraph5.oj7ua
<OJ7ML>
<DESIGN SRC=' '> </DESIGN>
<OakJava7 Package='DataScience' Database='wnosql' J7Lib='{}' Names='ConsoleApp28,linegraph1' Type='exe' MAIN=' display();?> '
LOGIC=' public static void display() { HTML.displayhtml("linegraph.html"); } '>
</OakJava7>
</OJ7ML>
Explanation
Here LOGIC is the functionality ,and J7Lib is the package like CUTIL,etc used
to be mentioned in J7Lib.We can also choose Type =.dll and
MAIN indicates main part of the OJ7UA framework.So Names cantains two
values which are ConsoleApp28,and linegraph1.This ConsoleApp28 indicates
Namespace or package name of WEB7(OJ7) Program and linegraph1 indicates
WEB7(OJ7) Class name. So when you compile using corejavac7 linegraph5.oj7ua
will automatically generate the linegraph5.web file.You can use linegrap5.web file
for testing the WEB7(OJ7) program.We should mention <OJ7ML> , </OJ7ML>,
<DESIGN SRC=' '> , </DESIGN>,<OakJava7 Package='xx1' Database='wnosql'
J7Lib='{}' Names='YYYY,xxxx' Type='exe' MAIN=' ?> ',</OakJava7>,LOGIC=''>. If it is a very simple
program without business logic or it is dummy program,otherwise it will generate the
error.It will not generate the .exe or .dll file in this case.
Step 1:-Create a OJ7UA user friendly program (OJ7UA)
Step 2: Follow the rules of WEB7(OJ7) OJ7UA user friendly program (OJ7UA)
Step 3: Compile it using WEB7(OJ7) Shell or Using Visual Studio code. ie) Use corejavac7 <filename.oj7ua>
eg) Here we compile using corejavac7 linegraph5.oj7ua in Visual Studio code two times or compile it in
WEB7(OJ7) Shell for only one time.You can see the compilation of WEB7(OJ7) files in Visual Studio code.
Step 4: When the linegraph5.web code is generated ,use
it for testing purpose.For testing compile using javac7 <filename.web>
eg) here we compile using corejavac7 linegraph5.web.So you can
find the error as quick as possible. Always see the errors at Console.
Step 5: At step5 you will see the two kinds files are
generated which are linegraph5.exe,linegraph5.ojava7.
So using the ls linegraph* command in Visual Studio code
PS C:\wilmix> ls linegraph5* , you can see the created
two files(.ojava7,.exe), and .web file .
Step -6: At the Visual Studio you can run the program using ./linegraph5.exe
for running .exe file and run linegraph5.ojava7 at command prompt for .oakjava7 file.Or
Run the WEB7(OJ7) program using RunJava7 <filename> ie)
RunJava7 linegraph5 in WEB7 (OJ7) Shell.Or else copy
the two files(.exe ,.ojava7) and used that files in Scroll Server for web application.
================================================================================
Sample-1: Write a WEB7(OJ7) .web program to calculate ChiSquare value,
MeanMedian(Median,Sum,Avg,list MaximumRepeatingElement),Variance and Standard Deviation,Percentile for Students,Scale using Oakjava7 Machine Learning Syntax program
================================================================================
Q) Write the Chisquare, MeanMedianMode, varianceandSTD ,percentile, Scale methods using
Oakjava7 MachineLearning Syntax program and print all this details in
Google Webbrowser using Scroll server.
sample1.oj7ua
<OJ7ML>
<DESIGN
SRC='
'>
</DESIGN>
<!-- Here Java7ML is the .dll library for WEB7(OJ7) used for machine learning (ML) -->
<OakJava7 Package='ML' Database='wnosql' J7Lib='{Java7ML}' Names='sampleml1,misctype1' Type='exe'
MAIN=' ChiSquaretest(); MeanMedianMode();varianceandSTD();percentile();Scale(); ?> '
LOGIC='
public static void ChiSquaretest(){
PRINTLN("g$BR>");g$OJ7UTIL>.ArrayList observedvalue = new g$OJ7UTIL>.ArrayList();
g$OJ7UTIL>.ArrayList expectedvalue = new g$OJ7UTIL>.ArrayList();
observedvalue.add(85);observedvalue.add(15); expectedvalue.add(75); expectedvalue.add(25);
double chi = Java7ML.ChiSquare.chisquaretest(observedvalue, expectedvalue);PRINTLN("g$BR>");
PRINTLN("Observed value=" + Java7ML.ChiSquare.osum);PRINTLN("g$BR>");
PRINTLN("Expected value=" + Java7ML.ChiSquare.esum);PRINTLN("g$BR>");
PRINTLN("Chi-Square value=" + chi);PRINTLN("g$BR>"); }
public static void MeanMedianMode(){
PRINTLN("g$BR>");int n = 5;
int[] a = { 2, 6, 7, 4, 9 };PRINTLN("g$BR>");
PRINTLN("Mean ::" + Java7ML.MeanMedianMode.Mean(a, n));
int[] values = { 2, 3, 6, 12, 15, 34, 65, 78, 99 };
double median1 = Java7ML.MeanMedianMode.median(values);PRINTLN("g$BR>"); PRINTLN("Median is : " + median1);
int[] arrA = { 4, 1, 3, 2, 1, 5, 9, 8, 6, 5, 3, 2, 4, 7,7,7,7,7, 10, 10, 10, 10, 10, 10 };PRINTLN("g$BR>");
PRINTLN(Java7ML.MeanMedianMode.MaxRepeatingElement(arrA));
double[] a1 = { 90.5, 90.5, 90.5, 90.5, 99.25,78.34 };
double sum1 = Java7ML.MeanMedianMode.SUM(a1);PRINTLN("g$BR>"); PRINTLN("SUM=" + sum1);
double avg1 = Java7ML.MeanMedianMode.AVG(sum1, a1.Length);PRINTLN("g$BR>");
PRINTLN("AVG=" + avg1);PRINTLN("g$BR>");PRINTLN("g$BR>"); }
public static void varianceandSTD() {
PRINTLN("g$BR>"); double [] arr = { 32, 111, 138, 28, 59, 77, 97 };
int n1 = arr.Length;PRINTLN("g$BR>");
PRINTLN("Variance: " + Java7ML.stdvariance.variance(arr, n1));PRINTLN("g$BR>");
PRINTLN("Standard Deviation: " +Java7ML.stdvariance.standardDeviation(arr, n1));
PRINTLN("g$BR>"); PRINTLN("g$BR>"); }
public static void percentile(){
PRINTLN("g$BR>");int[] StudentMarks = { 5, 31, 43, 48, 50, 41, 7, 11, 15, 39, 80, 82, 32, 2, 8, 6, 25, 36, 27, 61, 31 };
int n2 = StudentMarks.Length; int percent = 190;PRINTLN("g$BR>");
PRINTLN("Percentile=" + Java7ML.Percentile.Studentpercentile(StudentMarks, n2, percent));PRINTLN("g$BR>"); }
public static void Scale() {
PRINTLN("g$BR>");double[] ar = { 32, 111, 138, 28, 59, 77, 97 };
double mean1 = Java7ML.Scale.median(ar);PRINTLN("g$BR>");PRINTLN("Mean=" + mean1);
int n3 = ar.Length; double std1 = Java7ML.stdvariance.variance(ar, n3);PRINTLN("g$BR>");
PRINTLN("STD=" + std1); double[] cr = new double[ar.Length];
cr = Java7ML.Scale.calculate(ar, mean1, std1);PRINTLN("g$BR>");
for (int i = 0; i g$ cr.Length; i++)
PRINTLN(" " + cr[i]);
PRINTLN("g$BR>"); } '>
</OakJava7>
</OJ7ML>
Note: This <!-- --> is called as Comments in WEB7(OJ7) Userfriendly framework(Oj7UA).
Explanation
This g$ is the Special character used in WEB7(OJ7) Machine learning.
This g$ means special character '<' . eg) When we use PRINTLN means
it is equivalent to <PRINTLN> in WEB7(OJ7) (.web).So this
statement PRINTLN("g$BR>"); is equivalent to <PRINTLN>("<BR>");
so g$ is equivalent to '<' ie) Lesser than symbol '<'.
Explanation:
The api Java7ML.ChiSquare.chisquaretest(observedvalue, expectedvalue)
will calculate chisquare value ,Observed value ,Expected Value.
When Observed Arraylist value and expected Arraylist value
is passed as a parameters to api chisquaretest(observedvalue, expectedvalue).
The api Java7ML.MeanMedianMode.Mean(a, n) will calculate mean for the given array of numbers.
The api Java7ML.MeanMedianMode.median(values) will calculate median for the given array of numbers.
The api Java7ML.MeanMedianMode.MaxRepeatingElement(arrA)
will print which number is repeated more times than other.
and it will print the occurence of the number repeatation.
and will calculate this for the given array values.
This api Java7ML.MeanMedianMode.SUM(a1) will calculate the sum of values for a given array.
This api Java7ML.MeanMedianMode.AVG(sum1, a1.Length) will calculate the Avg of Sum of given array.
This api Java7ML.stdvariance.variance(arr, n1)) will calculate the variance of a given array.
This api Java7ML.stdvariance.standardDeviation(arr, n1)) will calculate the StandardDeviation of a given array.
This api Java7ML.Percentile.Studentpercentile(StudentMarks, n2, percent) will calculate Student Percentile based on given array Student Marks and with given percentage...
This api Java7ML.Scale.median(ar) will calculate median for a given array.
This api Java7ML.stdvariance.variance(ar, n3) will calculate variance for a given array.
This api Java7ML.Scale.calculate(ar, mean1, std1) will calculate Scale for the mean and Standard Deviation Values.
Note: You had to include Java7ML.dll in the Java7.0 properties file for this program
to be executed.
OUTPUT
Observed value=100
Expected value=100
Chi-Square value=5.33333333333333
Mean ,5.6
Median is : 15
{10=6}
SUM=539.59
AVG=89.9316666666667
Variance: 1432.24489795918
Standard Deviation: 37.8450115333472
Percentile=85
Mean=77
STD=1432.24489795918
-0.0342120262182958 -0.0314192077514961 -0.0125676831005985 0 0.0139640923339983 0.0237389569677971 0.0425904816186948
================================================================================
SAMPLE-2 : Bernouli Distribution
================================================================================
What is Bernoulli Distribution?
Bernoulli Distribution is a special kind of distribution that is used to model
real-life examples and can be used in many different types of applications.
A random experiment that can only have an outcome of either 1 or 0 is known
as a Bernoulli trial. Such an experiment is used in a Bernoulli distribution.
Bernoulli Distribution Definition
A discrete probability distribution wherein the random variable can only have 2
possible outcomes is known as a Bernoulli Distribution. If in a Bernoulli trial
the random variable takes on the value of 1, it means that this is a success.
The probability of success is given by p. Similarly, if the value of the random variable is 0,
it indicates failure. The probability of failure is q or 1 - p.
Bernoulli Distribution Example
Suppose there is an experiment where you flip a coin that is fair. If the outcome of the flip
is heads then you will win. This means that the probability of getting heads is p = 1/2.
If X is the random variable following a Bernoulli Distribution, we get P(X = 1) = p = 1/2.
Bernoulli Distribution Formula
A binomial random variable, X, is also known as an indicator variable.
This is because if an event results in success then X = 1 and if the
outcome is a failure then X = 0. X can be written as X
Bernoulli (p), where p is the parameter. The formulas for
Bernoulli distribution are given by the probability mass function
(pmf) and the cumulative distribution function (CDF).
Formulae for Probability Mass Function for Bernoulli Distribution
f(x, p) = p pow(x)* (1 - p) pow(1 - x); x ϵ {0, 1}
Let us consider a few Bernoulli distribution examples to understand the concept:
Example #1
In a medical examination, the chances of error are 15%. Now, find the Bernoulli distribution if one patient is randomly selected out of 60 patients.
Solution:
Number of error reports when 60 patients are examined = 15% of 60 = 9 patients
Thus, the number of patients getting the correct reports = 60 – 9 = 51
p = 51/60 = 17/20
P (X = x) = p x (1-p) (1-x)
Thus, P (X = x) = (17/20) x (1 – 17/20) (1-x)
Computing for x = 0, 1
If, x = 1
Then P (X = 1) = 17/20 = 0.85
If, x = 0
Then P (X = 0) = q = 1 – p = 1 – 17/20 = 3/20 = 0.15
Thus, the probability of getting a successful result in the medical test is 0.85, whereas the probability of error (failure) is 0.15.
Let us plot the above example on a graph:
Given that p = 0.85 and q or 1-p = 0.15.
Now let us see the given below WEB7(OJ7) OJ7UA framework program for this example given above.
Write a WEB7(OJ7) Program for Bernouli Distribution for the given above example using Oj7ua framework:-
BernoulliDistribution.oj7ua
<OJ7ML>
<DESIGN SRC=' '> </DESIGN>
<OakJava7 Package='ML' Database='wnosql' J7Lib='{J7Distribution}' Names='Distribution,BernoulliJ7' Type='exe' MAIN=' display();?> '
LOGIC=' public static void display() {
double p=(17.0/20.0);
double p2=0.0D;
p2= double.Parse(String.Format("{0:0.####}", ""+p));
int x=0;
g$J7ARRAYLIST> ar = new g$J7ARRAYLIST> ();
/* x is intialized to 0 */
x=0;
ar.add(0,double.Parse(J7PlotGraph.BernoulliDistProcess(p2,x).get(0).ToString()));
/* x is intialized to 1 */
x=1;
ar.add(1,double.Parse(J7PlotGraph.BernoulliDistProcess(p2,x).get(0).ToString()));
HTML.displayhtml("colchart1.html");
PRINTLN("data: "+ar);
HTML.displayhtml("colchart2.html");
}
'>
</OakJava7>
</OJ7ML>
Explanation
The statement double.Parse(String.Format("{0:0.####}", ""+p));
is used to change the format to double data type and it's value is stored in double variable p2.
This statement g$J7ARRAYLIST> ar = double.Parse(J7PlotGraph.BernoulliDistProcess(p2,x).get(0).ToString())
means that the double.Parse (J7PlotGraph.BernoulliDistProcess is used
to store the converted double value in <J7ARRAYLIST> ar and it
is easy to store in J7ArrayList ar using ar.add( statement.
Here we should specify the location starts with 0 ,1,2,3....
eg) ar.add(0,double.Parse(J7PlotGraph.BernoulliDistProcess(p2,x).get(0).ToString()))
Here J7Distribution in J7Lib is the package and J7PlotGraph is the name of the class
to plot the graph using method BernoulliDistProcess.
BernoulliDistProcess(p2,x).get(0).ToString() is the method present in J7PlotGraph class.
Here x=0 then x value is passed to the method double.Parse(BernoulliDistProcess(p2,x).get(0).ToString())
and converted to double datatype using double.Parse.
simillarly x=1 value is passed to the method double.Parse(BernoulliDistProcess(p2,x).get(0).ToString())
and converted to double datatype using double.Parse.
The Statements ...
HTML.displayhtml("colchart1.html");
PRINTLN("data: "+ar);
HTML.displayhtml("colchart2.html");
This colchart1.html , colchart2.html library files are used to plot the BernoulliDistrbution graph using the ar ArrayList values.
Note: Here in this case you must use WEBJ7Distribution.web.dll
in the WEB7(OJ7) Properties file.
OUTPUT
The Output for BernoulliDistrbution graph is given below....
===============================================================================
================================================================================
SAMPLE-3 : Binomial Distribution
================================================================================
Binomial Distribution
In probability theory and statistics, the binomial distribution is the discrete probability
distribution that gives only two possible results in an experiment, either Success or Failure.
For example, if we toss a coin, there could be only two possible outcomes: heads or tails,
and if any test is taken, then there could be only two results: pass or fail.
This distribution is also called a binomial probability distribution.
Binomial Distribution Examples
As we already know, binomial distribution gives the possibility of a different set of outcomes. In real life, the concept is used for:
Finding the quantity of raw and used materials while making a product.
Taking a survey of positive and negative reviews from the public for any specific product or place.
By using the YES/ NO survey, we can check whether the number of persons views the particular channel.
To find the number of male and female employees in an organisation.
The number of votes collected by a candidate in an election is counted based on 0 or 1 probability.
Binomial Distribution Formula
The binomial distribution formula is for any random variable X, given by;
P(x:n,p) = nCx px (1-p)n-x
Or
P(x:n,p) = nCx px (q)n-x
Where,
n = the number of experiments
x = 0, 1, 2, 3, 4, …
p = Probability of Success in a single experiment
q = Probability of Failure in a single experiment = 1 – p
The binomial distribution formula can also be written in the form of n-Bernoulli trials, where nCx = n!/x!(n-x)!. Hence,
P(x:n,p) = n!/[x!(n-x)!].px.(q)n-x
Example and Solutions for Binomial Distribution
Example 1: If a coin is tossed 5 times, find the probability of:
(a) Exactly 2 heads
(b) At least 4 heads.
Solution:
(a) The repeated tossing of the coin is an example of a Bernoulli trial. According to the problem:
Number of trials: n=5
Probability of head: p= 1/2 and hence the probability of tail, q =1/2
For exactly two heads:
x=2
P(x=2) = 5C2 p2 q5-2 = 5! / 2! 3! × (½)2× (½)3
P(x=2) = 5/16
(b) For at least four heads,
x ≥ 4, P(x ≥ 4) = P(x = 4) + P(x=5)
Hence,
P(x = 4) = 5C4 p4 q5-4 = 5!/4! 1! × (½)4× (½)1 = 5/32
P(x = 5) = 5C5 p5 q5-5 = (½)5 = 1/32
Therefore,
P(x ≥ 4) = 5/32 + 1/32 = 6/32 = 3/16
Example 2:
A fair coin is tossed 10 times, what are the probability of getting exactly 6 heads.
Solution:
Let x denote the number of heads in an experiment.
Here, the number of times the coin tossed is 10. Hence, n=10.
The probability of getting head, p ½
The probability of getting a tail, q = 1-p = 1-(½) = ½.
The binomial distribution is given by the formula:
P(X= x) = nCxpxqn-x, where = 0, 1, 2, 3, …
Therefore, P(X = x) = 10Cx(½)x(½)10-x
(i) The probability of getting exactly 6 heads is:
P(X=6) = 10C6(½)6(½)10-6
P(X= 6) = 10C6(½)10
P(X = 6) = 105/512.
Hence, the probability of getting exactly 6 heads is 105/512.
=============================================================
Write a BinomialDistribution program using WEB7(OJ7)
and OJ7UA framework. Plot the column chart for this.
BinomialDistribution.oj7ua
<OJ7ML>
<DESIGN SRC=' '> </DESIGN>
<OakJava7 Package='ML' Database='wnosql' J7Lib='{J7Distribution}' Names='Distribution,BinomialJ7' Type='exe' MAIN=' display();?> '
LOGIC=' public static void display() {
/* Binomial Distribution */
double ncr= J7PlotGraph.NCR(5,0,1.0/2.0 ,1.0/2.0);
g$J7ARRAYLIST> ar1 = new g$J7ARRAYLIST> ();
ncr= J7PlotGraph.NCR(5,4,1.0/2.0 ,1.0/2.0);
ar1.add(0,ncr);
ncr= J7PlotGraph.NCR(5,5,1.0/2.0 ,1.0/2.0);
ar1.add(1,ncr);
ncr= J7PlotGraph.NCR(5,2,1.0/2.0 ,1.0/2.0);
ar1.add(2,ncr);
ncr= J7PlotGraph.NCR(10,6,1.0/2.0 ,1.0/2.0);
ar1.add(3,ncr);
HTML.displayhtml("colchartA1.html");
PRINTLN("data: "+ar1);
HTML.displayhtml("colchartA2.html");
}
'>
</OakJava7>
</OJ7ML>
Explanation
if n=5, and X=0
you will get the value 0.03125 for
Binomial Distribution graph.
if n=5, and X=1
you will get the value 0.15625 for
Binomial Distribution graph.
if n=5, and X=2
you will get the value 0.3125 for
Binomial Distribution graph.
if n=5, and X=3
you will get the value 0.205078 for
Binomial Distribution graph.
How you get the points/value for the graph?
That can be done using J7PlotGraph.NCR(n,X,p ,q);
where p=1/2 and q=1/2.
Next step is using colchartA1.html, colchart2.html,
and printing the arraylist ar1 contents which
are given below...
HTML.displayhtml("colchartA1.html");
PRINTLN("data: "+ar1);
HTML.displayhtml("colchartA2.html");
You will get the Output as shown below...
OUTPUT
================================================================================
SAMPLE -4 : Poisson Distribution
================================================================================
Poisson Distribution Definition
The Poisson distribution is a discrete probability function that means the variable
can only take specific values in a given list of numbers, probably infinite.
A Poisson distribution measures how many times an event is likely to occur within “x” period of time.
In other words, we can define it as the probability distribution that results from the Poisson experiment.
A Poisson experiment is a statistical experiment that classifies the experiment into two categories,
such as success or failure. Poisson distribution is a limiting process of the binomial distribution.
A Poisson random variable “x” defines the number of successes in the experiment.
This distribution occurs when there are events that do not occur as the outcomes
of a definite number of outcomes. Poisson distribution is used under certain conditions.
They are:
The number of trials “n” tends to infinity
Probability of success “p” tends to zero
np = 1 is finite
Poisson Distribution Formula
The formula for the Poisson distribution function is given by:
f(x) =(e ^ – λ * λ ^ x)/x!
Where,
e is the base of the logarithm
x is a Poisson random variable
λ is an average rate of value
=================================
Poisson Distribution Solved Examples
Example 1:If 4% of the total items made by a factory are defective.
Find the probability that less than 2 items are defective in the sample of 50 items.
Solution:
Here we have, n = 50, p = (4/100) = 0.04, q = (1-p) = 0.96, λ = 2
Using Poisson's Distribution,
P(X = 0) = 20e−20!0!20e−2 = 1/e2 = 0.13534
P(X = 1) = 21e−21!1!21e−2 = 2/e2 = 0.27068
Hence the probability that less than 2 items are defective in sample of 50 items is given by:
P( X > 2 ) = P( X = 0 ) + P( X = 1 ) = 0.13534 + 0.27068 = 0.40602
Next is .....
Write the WEBJ7(OJ7) Program to find the solutions , If 4% of the total items made by a factory are defective. Find the probability that less than 2 items are defective in the sample of 50 items. Here use Google chart only.
probfactory.oj7ua
<OJ7ML>
<DESIGN SRC=' '> </DESIGN>
<OakJava7 Package='ML' Database='wnosql' J7Lib='{J7Distribution}' Names='Distribution,PoissionDistJ7' Type='exe' MAIN=' display();?> '
LOGIC=' public static void display() {
/* Poission Distribution */
g$J7ARRAYLIST> poissiondist = new g$J7ARRAYLIST>();
poissiondist.add(0,"[l$Icapacityl$,l$Profitl$]");
double sum= double.Parse(J7PlotGraph.PoissonDistProcess(0,2.0 ).get(1).ToString().Replace("l$",""))+ double.Parse(J7PlotGraph.PoissonDistProcess(1,2.0 ).get(1).ToString().Replace("l$","")) ;
for (int i=1;i g$ 15;i++)
{
poissiondist.add(i, J7PlotGraph.PoissonDistProcess(i-1,2.0 ));
}
HTML.displayhtml("columnchart1.html");
PRINTLN(poissiondist);
HTML.displayhtml("columnchart2.html");
PRINTLN("g$BR> ");
PRINTLN("Here we have, n = 50, p = (4/100) = 0.04, q = (1-p) = 0.96, Lambda = 2");
PRINTLN(" ");
PRINTLN("g$BR> ");
PRINTLN("g$BR> ");
PRINTLN(" ");
PRINTLN("P(X=0) = "+double.Parse(J7PlotGraph.PoissonDistProcess(0,2.0 ).get(1).ToString().Replace("l$","")));
PRINTLN("g$BR> ");
PRINTLN("g$BR> ");PRINTLN(" ");
PRINTLN("P(X=1) = "+double.Parse(J7PlotGraph.PoissonDistProcess(1,2.0 ).get(1).ToString().Replace("l$","")));
PRINTLN("g$BR> ");
PRINTLN("g$BR> ");PRINTLN(" ");
PRINTLN(" P( X > 2 ) = P( X = 0 ) + P( X = 1 ) = "+sum);
PRINTLN("g$BR> ");
PRINTLN(" g$BR>");
PRINTLN(" ");
PRINTLN("g$BR> ");
}
'>
</OakJava7>
</OJ7ML>
Explanation
Here pass the value where X=0, and Lambda =2.0
to the method which is given below...
J7PlotGraph.PoissonDistProcess(X, Lambda ).get(1).ToString().Replace("l$","")
simillarly pass the value where X=1, and Lambda =2.0
to the method which is given below...
J7PlotGraph.PoissonDistProcess(X, Lambda ).get(1).ToString().Replace("l$","")
Here L$ represented in OJ7UA framework represent special symbol '
which is replaced by empty string.
You will get two values which are given below....
P(X=0) = 0.135335283236613
P(X=1) = 0.270670566473225
For the probability that less than 2 items are defective in sample of 50 items is given by:
P( X > 2 ) = P( X = 0 ) + P( X = 1 ) = 0.135335283236613 + 0.270670566473225 = 0.406005849709838
OUTPUT
The Poisson Distribution Chart is given below...
===============================================================================
Sample -5: Normal Distribution using Web7(OJ7)
===============================================================================
About Normal Distribution
Normal Distribution is the most common or normal form of distribution of Random Variables,
hence the name "normal distribution." It is also called Gaussian Distribution in Statistics
or Probability. We use this distribution to represent a large number of random variables.
It serves as a foundation for statistics and probability theory.
Normal Distribution Definition
The Normal Distribution is defined by the probability density function for a continuous random variable
in a system. Let us say, f(x) is the probability density function and X is the random variable.
Hence, it defines a function which is integrated between the range or interval (x to x + dx),
giving the probability of random variable X, by considering the values between x and x+dx.
f(x) ≥ 0 ∀ x ϵ (−∞,+∞)
And -∞∫+∞ f(x) = 1
Normal Distribution Formula
The probability density function of normal or gaussian distribution is given by;
f(x,U,std) = (1/(std * sqrt(2 * PI)) * e ^ (-(x-U)^2)/ (2 * std ^2))
Normal Distribution Formula
Where,
x is the variable
μ is the mean
σ is the standard deviation
Normal Distribution Curve
The random variables following the normal distribution are those whose values can find
any unknown value in a given range. For example, finding the height of the students in
the school. Here, the distribution can consider any value, but it will be bounded in
the range say, 0 to 6ft. This limitation is forced physically in our query.
Example 1: If the value of the random variable is 4, the mean is 4 and the standard deviation is 3,
then find the probability density function of the Gaussian distribution.
Solution:
Given,
Variable (x) = 4
Mean = 4
Standard Deviation = 3
Using formula of probability density of normal distribution we obtain the result
which is given below..
Simplifying,
f(4, 4, 3) = 1/(3√2π)e0
f(4, 4, 3) = 0.13301
Write the WEB7(OJ7) .oj7ua Framework program for the same Example 1 as explained above Apply Google chart for this..
NormalDistribution.oj7ua
<OJ7ML>
<DESIGN SRC=' '> </DESIGN>
<OakJava7 Package='ML' Database='wnosql' J7Lib='{J7Distribution}' Names='Distribution,NormalDistJ7' Type='exe' MAIN=' display();?> '
LOGIC=' public static void display() {
/* Normal Distribution */
g$J7ARRAYLIST> normaldistn = new g$J7ARRAYLIST> ();
normaldistn.add(0,"[l$Salesl$,l$Expensesl$]");
for(int i=1;i g$ 10;i++)
{
normaldistn.add(i, J7PlotGraph.NormalDistType2(i ,4.0,3.0,0.0));
}
// load Google chart for normal distribution
HTML.displayhtml("normaldisttyA.html");
PRINTLN(normaldistn);
// load Google chart for normal distribution
HTML.displayhtml("normaldisttyB.html");
}
'>
</OakJava7>
</OJ7ML>
Explanation
J7Distribution package is used for Normal Distribution.That's why
we mention J7Distribution in J7Lib.
Here in this example method
J7PlotGraph.NormalDistType2(X ,U,std,0.0)
is used for constructing Normal Distribution Curve
and Normal Distribution chart.
where std stands for standard Deviation...
now we must find all the hidden values
in the curve. ie) we should find for
X values ranging from 1 to 10.
After that we add all the results to the
ArrayList normaldistn. Which is given below..
normaldistn.add(i, J7PlotGraph.NormalDistType2(i ,4.0,3.0,0.0));
Note: You must use WEBJ7Distribution.web.dll
in the properties.txt file.
OUTPUTS
2 Outputs for the Normal Distribution is given below...
===============================================================================
Sample -6: Uniform Distribution using Web7(OJ7)
===============================================================================
What is Uniform Distribution?
A Uniform Distribution is a type of probability distribution in which every outcome in a given range
is equally likely to occur. That means there is no bias—no outcome is more likely than another within the specified set.
It is also known as rectangular distribution (continuous uniform distribution).
It has two parameters a and b: a = minimum and b = maximum. The distribution is written as U (a, b).
Random Number Generation (Continuous Uniform Distribution)
Suppose a random number generator is programmed to produce a real number between 0 and 1,
with each number in this range being equally likely.
This is an example of a continuous uniform distribution.
The graph will show the range [0, 1] on the x-axis,
with a constant probability density of 1 across this interval.
Uniform Distribution Formula
A random variable X is said to be uniformly distributed over the interval
-∞ < a < b < ∞.
Formulae for uniform distribution:
Probability density function(pdf) => f(x) = 1/( b - a), a ≤ x ≤ b
Mean(μ) = (a+b)/2
For the conditional probability = P( c < x < d )
= (d - c ) × f(x)
= (d - c)/(b - a)
Cumulative Distribution function (CDF) = (x - a)/(b - a) for x ∈ [a , b]
Variance (σ2 ) = ((b-a) ^2) /12
Standard Deviation (σ) = sqrt(((b-a) ^2) /12)
Median = (a + b)/2
===========================================
Question 1: Using the Uniform distribution probability density function for random variable X. in (0, 20), find P(3< X < 16).
Solution:
Here, a = 0, b =20
f(x) = 1/(20 - 0) = 1/20
P(3< X < 16) = (16 - 3) × (1/20) = 13/20
Question 2: Find the Probability density function(pdf) where
a random number generator is programmed to produce a
real number between 0 and 1, with each number in this
range being equally likely.
pdfX=1/(b-a);
where b=1 , a=0
pdfx= 1/(1-0)= 1
Write a WEB7(OJ7) Program to
i) Use the uniform distribution probability density function for random variable X. in (0, 20), find P(3< X < 16).
ii) Find the Probability density function(pdf) where a random number generator is programmed to produce a real number between 0 and 1, with each number in this range being equally likely.
Uniformdistribution.oj7ua
<OJ7ML>
<DESIGN SRC=' '> </DESIGN>
<OakJava7 Package='ML' Database='wnosql' J7Lib='{J7Distribution}' Names='Distribution,UniformDistJ7' Type='exe' MAIN=' display();?> '
LOGIC=' public static void display() {
/* Uniform Distribution */
g$J7ARRAYLIST> uniformdistn = new g$J7ARRAYLIST> ();
uniformdistn.add(0,"[l$Salesl$,l$Expensesl$]");
g$J7ARRAYLIST> uniformdistn1 = new g$J7ARRAYLIST> ();
uniformdistn1.add(0,"[l$Salesl$,l$Expensesl$]");
int s=0; int j=1;
for(int i=1;i g$ 11;i+=1)
{
uniformdistn1.add(i, J7PlotGraph.UniformDistProcess(0,20,i-1,3,16 ,7));
}
for(double i=0.0;i g$ 1;i+=0.1)
{
uniformdistn.add(j, J7PlotGraph.UniformDistProcess(0,1,i,0,0,1));
j++;
}
HTML.displayhtml("normaldisttyA.html");
PRINTLN(uniformdistn);
HTML.displayhtml("normaldisttyB.html");
HTML.displayhtml("normaldisttyA.html");
PRINTLN(uniformdistn1);
HTML.displayhtml("normaldisttyB1.html");
}
'>
</OakJava7>
</OJ7ML>
Explanation
Here Uniform Distribution has two types.
One is to find the Probability density function(pdf)
where a random number generator is programmed to produce a
real number between 0 and 1. Here we use the common Uniform
distribution method which is ...
uniformdistn.add(j, J7PlotGraph.UniformDistProcess(a,b,X,c,d,ch));
we will iterate using the for loop to get Uniform Distribution graph
Type -1. Here we use the formulae 1/(b-a) so choice 1 is selected.
that's why we pass the value 1 as a parameter..
J7PlotGraph.UniformDistProcess(0,1,i,0,0,1);
Simillarly we hav to find uniform distribution probability density function
for random variable X. in (0, 20), find P(3< X < 16).
for this we use the choice 7 at method ...
J7PlotGraph.UniformDistProcess(0,20,i-1,3,16 ,7);
so a=0, b=20, x=i-1,c=3,d=16, choice=7
where choice 7 formulae is given below...
double condPx=(d-c)/(b-a);
by using this J7PlotGraph.UniformDistProcess(0,20,i-1,3,16 ,7) method
we will find uniform distribution probability density function .
HTML.displayhtml will display the contents of html
templates at the webpage.
Here we will use the same template that we used
with normal distribution...
HTML.displayhtml("normaldisttyA.html");
HTML.displayhtml("normaldisttyB.html");
HTML.displayhtml("normaldisttyB1.html");
This indicates that we can draw multiple graphs
at the webpage.
For J7PlotGraph.UniformDistProcess(0,20,i-1,3,16 ,7) method output
please refer screenshot UniformDistScreenshot1.png
For J7PlotGraph.UniformDistProcess(0,1,i,0,0,1) method output
please refer screenshot UniformDistScreenshot2.png
2 Outputs for this uniform distribution is given below...
OUTPUTS
============================================================================
SAMPLE-7 :COS WAVE and SIN WAVE
================================================================================
About Sine and Cosine Waves
========================
Sine waves and cosine waves are periodic, oscillating functions that are closely related.
A cosine wave can be thought of as a sine wave that has been shifted by a quarter of a period,
or 90 degrees. Both waves are essential for understanding various phenomena, including sound,
light, and electricity.
WAVES.oj7ua
<OJ7ML>
<DESIGN SRC=' '> </DESIGN>
<OakJava7 Package='ML' Database='wnosql' J7Lib='{}' Names='CoswaveandSinwave,Waves' Type='exe' MAIN=' display();?> '
LOGIC=' public static void display() {
g$TRY>
{
PRINTLN();PRINTLN();PRINTLN();PRINTLN();
PRINTLN("g$B>COSWAVEg$/B>");
PRINTLN();
HTML.displayhtml("CosWave.html");
PRINTLN();
PRINTLN("g$B>SINWAVEg$/B>");
PRINTLN();
HTML.displayhtml("SinWave.html");
PRINTLN();
}
g$CATCH>(g$EXE> e)
{
PRINTLN("g$RUNTIMEERROR>");
PRINTLN(e);
}
}
'>
</OakJava7>
</OJ7ML>
Explanation:
If you want to find Cos Wave and Sin Wave
then we have to include Google Template (SinWave.html,CosWave.html)
for Cos and Sine Wave. Here Cos and
Sine Waves values are final. ie)
Values is constant for COS and Sin Wave.
OutPut For Cos Wave and Sine Wave is given below...
Output:
================================================================================
Sample -8: MultiNomial Distribution using Web7(OJ7) with Web7(Oj7)
Advanced Structures for MachineLearning
================================================================================
About MultiNomial Distribution
The multinomial distribution is a multivariate generalization of the binomial distribution.
Consider a trial that results in exactly one of some fixed finite number k of possible outcomes,
with probabilities p1, p2, … , pk (so that pi ≥ 0 for i = 1, … , k and ∑i=1kpi=1), and there are
n independent trials. Then let the random variables Xi indicate the number of times outcome number
i was observed over the n trials. Then X = (X1, X2, … , Xk) follows a multinomial distribution with parameters n and p,
where p =(p1, p2, … , pk). An example where a multinomial random variable could occur is during the throw of a dice.
Let Xi, i = 1, 2, … , 6, denote the number of times i is observed in n throws of a dice. Then X = (X1, X2, … , X6)
has a multinomial distribution. If the dice is fair, then pi=16 for all i.
The PMF of the multinomial distribution is given by
PX1=x1,X2=x2,…,Xk=xk=(n!/(x1!x2!…xk!)) * (p1^ x1* p2^x2 ⋯pk^xk)
where ∑i=1kxi=n. If k = 2, the multinomial distribution becomes a binomial distribution with n trials and success probability p1.
When X = (X1, X2, …, Xk) follows a multinomial distribution with the PMF given above, Xi follows a binomial distribution with n
trials and success probability pi. Hence, the mean and variance of Xi are npi and npi(1 − pi), respectively. The covariance
between Xi and Xj is −npipj.The maximum likelihood estimate of pi for a multinomial distribution is the ratio of the sample mean of xi's and n.
Three card players play a series of matches. The probability that player A will win any game is 20%,
the probability that player B will win is 30%, and the probability player C will win is 50%. If they play 6 games,
what is the probability that player A will win 1 game, player B will win 2 games, and player C will win 3?
Use the following formula to calculate the odds :
multinomial formulae..
PX1=x1,X2=x2,…,Xk=xk=(n!/(x1!x2!…xk!)) * (p1^ x1* p2^x2 ⋯pk^xk)
where:
n = number of events
x1 = number of outcomes, event 1
x2 = number of outcomes, event 2
x3 = number of outcomes, event x
p1 = probability event 1 happens
p2 = probability event 2 happens
px = probability event x happens
Using the data from the question, we get:
n = 12 (6 games total).
x1 = 1 (Player A wins).
x2 = 2 (Player B wins).
x3 = 3 (Player C wins).
p1 = 0.20 (probability that Player A wins).
p2 = 0.30 (probability that Player B wins).
p3 = 0.50 (probability that Player C wins).
Putting this into the formula, we get: multinomial distribution
P(x1=1,x2=2,x3=3) = (6!/(1! * 2! * 3!)) * ((0.2 ^ 1) * (0.3 ^ 2) * (0.5 ^ 3)) = 0.135
The Web(OJ7) program for the Multinomial Distribution is given below....
Web(OJ7) Program
multinomialdistsample.web
<WEB>
<WNOSQL>
<USE> J7Distribution;
<PACK> Distribution {
<CLASS> multinomialdist {
public static void display() {
<J7ARRAYLIST> xn= new <J7ARRAYLIST>();
xn.add(0,1); xn.add(1,2); xn.add(2,3);
<J7ARRAYLIST> pn= new <J7ARRAYLIST>();
pn.add(0,0.2); pn.add(1,0.3); pn.add(2,0.5);
double x=J7Distribution.J7PlotGraph.MULTINOMIALResult(pn,xn,6);
<J7ARRAYLIST> result= new <J7ARRAYLIST>();
<STRUCTURE> list = new <STRUCTURE> ("sample");
list.add(1);list.add(x);
list.add(2); list.add(x);
list.add(3); list.add(x);
//result ArrayList
result.add(0,"'A'");
result.add(1,"'B'");
HTML.displayhtml("MBarcharts1.html");
<PRINTLN>("[");
<PRINTLN>(result);
<PRINTLN>(",");
for (int i=2;i<list.size();i+=2)
{
<PRINTLN>("[");
<PRINTLN>(i-1);
<PRINTLN>(",");
<PRINTLN>(list.ret(i));
if (i < list.size())
<PRINTLN>("],");
else if (i ==list.size())
<PRINTLN>("]");
}
<PRINTLN>("]");
HTML.displayhtml("MBarcharts2.html");
}
public void main()
{ display(); } }
}
Explanation
We are adding 1,2,3 in the J7ArrayList xn.
where xn represent Xn values...
<J7ARRAYLIST> xn= new <J7ARRAYLIST>();
xn.add(0,1); xn.add(1,2); xn.add(2,3);
We are adding 0.2,0.3,0.5 in the J7ArrayList pn
where pn represent Probability values...
<J7ARRAYLIST> pn= new <J7ARRAYLIST>();
pn.add(0,0.2); pn.add(1,0.3); pn.add(2,0.5);
Now here
double x=J7Distribution.J7PlotGraph.MULTINOMIALResult(pn,xn,6);
This means J7Distribution represent the Distribution package
and J7PlotGraph is the common class for distribution.
For Multinomial Dsistribution you must use the method...
MULTINOMIALResult(pn,xn,6);
where pn represent the probability
where xn represent Xn values
And N represent N trials.
Now <J7ARRAYLIST> result= new <J7ARRAYLIST>();
we are adding two values which is (A,B) in to J7ArrayList result.
Limitations of C Structures
->The C structure does not allow the struct data type to be treated like built-in data types.
-> We cannot use operators like +,- etc. on Structure variables.
-> No Data Hiding: C Structures do not permit data hiding. Structure members can be accessed by any function, anywhere in the scope of the Structure.
->Functions inside Structure: C structures do not permit functions inside the Structure
-> Static Members: C Structures cannot have static members inside their body
->Access Modifiers: C Programming language does not support access modifiers. So they cannot be used in C Structures.
->Construction creation in Structure: Structures in C cannot have a constructor inside Structures.
When we compare ( C/C++ or Other Programming languages ) with WEB7(OJ7) Programming language
All failed.
Why ?
Because even C# follow C type Data Structure STRUCTURE,
Storing many data in C type Structure makes C Type
allocation memory goes down.
So when are dealing with more datas like
["SNO","NAME","Country","ADDRESS","JOB","SALARY"]
Here JSON fails,Any type of webservice fails
and it will bring more complex to implement using Java or Python
and store the datas. It requires more lines of code to implement.
But WEB7(OJ7) STRUCTURE is not like that When this type of 6 or 100 or 1000,etc any column datas are focused we can store the data and easily we can seperate using J7 for loop. This is the END of C/C++.
eg) ["SNO","NAME","Country","ADDRESS","JOB","SALARY","A","B","C" ,"D".... so on ]
values are [[1,2,3,4,5,6,7,8,9,10],[1,23,24,25,26,28,2,20,10,9], etc]
Now we can see J7Structure is very simple and easy to learn or use....
And we can simplify any complex data with any rows and columns. So i ask all professionals
to focus it.This J7STRUCTURE is implemented in year Nov 2018 by Wilmix jemin j.
J7Structure removes all the limitations where C/C++
have.And we see that J7Structure is the Advanced Data Structures
defeating C/C++.So J7Structure is userfriendly datastructure.
And it is easy to focus...
Now we are adjusting our datastructure when we
use J7Structure....
<PRINTLN>("[");
<PRINTLN>(result); // Here we are printing the result arraylist
<PRINTLN>(",");
for (int i=2;i<list.size();i+=2) // I value is incremented by 2 due to two columns present according to the requirements.
{
<PRINTLN>("[");
<PRINTLN>(i-1); // i-1 is to use X value as 1,2,3 ---etc.
<PRINTLN>(",");
<PRINTLN>(list.ret(i));// J7Structure values can be retrieved using list.ret(i)
if (i < list.size()) // we are checking the size, if i < size then print "]," otherwise print "]" only.
<PRINTLN>("],");
else if (i ==list.size())
<PRINTLN>("]");
}
<PRINTLN>("]");//close the final special character "]" .
Like this we can optimize our code using WEB7(OJ7) Machine Learning
technique -> J7Structures.
So other type WEB7(OJ7) datastructures like Heap,
EXTEND, LARRAY, etc are also advanced like J7Structure.
So this type of Advanced dataStructures like J7Structures, EXTEND,LARRAY,etc
are invented by Wilmix Jemin in WEB7(OJ7) Programming Language itself.
So this WEB7(OJ7) datastructures is a versalite datastructures....
So WEB7(OJ7) is a Versalite and Advanced High level programming Language..
The Output Graph for the MultiNomial Distribution are given below...
Note: like wise many WEB7(OJ7) DataStructures are found at WEB(OJ7) Enterprise Edition.
Output
============================================================================
Note: Distributions we see is important one. We will see the remaining distribution
at WEB7(OJ7) Enterprise Edition.
================================================================================
SAMPLE-9: Geographical charts with fusion charts using Webj7(OJ7)
================================================================================
Q) Write a Web7(OJ7) Program for Fusionchart using Oj7ua framework and Scroll server
to display the chart in google browser.
fusionchart.oj7ua
<OJ7ML>
<DESIGN SRC=' '>
</DESIGN>
<OakJava7 Package='wil' Database='' J7Lib='{format,java7displayurl}' Names='fusions,chartss' Type='exe' MAIN=' display(); ?> '
LOGIC=' public static void display() {
String s="";
s=java7UrlConnectionReader.getUrlContents("http://localhost:8082/json1.WS").Replace("g$HTML>","").Replace("g$/html>","");
J7HTML.displayhtml("fusion.html");
PRINTLN(""+s);
J7HTML.displayhtml("fusion1.html");
} '>
</OakJava7>
</OJ7ML>
Note: This java7displayurl , format are Web7(Oj7) library packages.
file.json
[
{
id: "021",
value: "11",
tooltext: "No data available"
},
{
id: "002",
value: "11",
tooltext: "No data available"
},
{
id: "025",
value: 11,
tooltext: "No data available"
},
{
id: "034",
value: "11",
tooltext: "No data available"
},
{
id: "027",
value: "11",
tooltext: "No data available"
},
{
id: "043",
value: "11",
tooltext: "No data available"
},
{
id: "028",
value: "11",
tooltext: "No data available"
},
{
id: "044",
value: "11",
tooltext: "No data available"
},
{
id: "026",
value: "11"
},
{
id: "023",
value: "11",
tooltext: "No data available"
},
{
id: "010",
value: "6.4"
},
{
id: "017",
value: "4.5"
},
{
id: "042",
value: "5.7"
},
{
id: "018",
value: "6.4"
},
{
id: "030",
value: "4.9"
},
{
id: "039",
value: "2.9"
},
{
id: "029",
value: "6.4"
},
{
id: "005",
value: "7"
},
{
id: "013",
value: "5.1"
},
{
id: "038",
value: "7.1"
},
{
id: "032",
value: "5.4"
},
{
id: "040",
value: "6.7"
},
{
id: "003",
value: "6.5"
},
{
id: "037",
value: "6.1"
},
{
id: "008",
value: "6.4"
},
{
id: "006",
value: "11",
tooltext: "No data available"
},
{
id: "001",
value: "11",
tooltext: "No data available"
},
{
id: "015",
value: "9.9"
},
{
id: "045",
value: "11",
tooltext: "No data available"
},
{
id: "007",
value: "7.6"
},
{
id: "024",
value: "11",
tooltext: "No data available"
},
{
id: "033",
value: "6"
},
{
id: "016",
value: "7"
},
{
id: "036",
value: "7.8"
},
{
id: "009",
value: "6.2"
},
{
id: "014",
value: "6.1"
},
{
id: "031",
value: "6.5"
},
{
id: "041",
value: "11",
tooltext: "No data available"
},
{
id: "004",
value: "5.4"
},
{
id: "022",
value: "5.3"
},
{
id: "020",
value: "3.5"
},
{
id: "011",
value: "4.8"
},
{
id: "012",
value: "4"
},
{
id: "046",
value: "8.3"
},
{
id: "019",
value: "5.6"
},
{
id: "035",
value: "11",
tooltext: "No data available"
},
{
id: "047",
value: "11",
tooltext: "No data available"
}
]
Write a Web1.0 webservice program for the file file.json
json1.Web
<WEB>
<WPACK>
<%
public class json1
{
public void WEB-Main( ) throws <EXE>
{
HTML.displayhtml("file.json");
}
}
%>
</WEB>
fusion.html
<html>
<head>
<title>My first chart using FusionCharts Suite XT</title>
<!-- Include fusioncharts core library -->
<script type="text/javascript" src="https://cdn.fusioncharts.com/fusioncharts/latest/fusioncharts.js"></script>
<!-- Include fusion theme -->
<script type="text/javascript" src="https://cdn.fusioncharts.com/fusioncharts/latest/themes/fusioncharts.theme.fusion.js"></script>
<script type="text/javascript">
const dataSource = {
chart: {
caption: "Sales of Cigarettes in Europe",
subcaption: "(per adult per day)",
legendposition: "BOTTOM",
entitytooltext: "$lname: <b>$datavalue </b>cigarettes",
legendcaption: "Number of cigarettes smoked per adult per day",
entityfillhovercolor: "#FFCDD2",
theme: "fusion"
},
colorrange: {
gradient: "0",
color: [
{
maxvalue: "4",
displayvalue: "2-4",
code: "#EF9A9A"
},
{
maxvalue: "6",
displayvalue: "4-6",
code: "#EF5350"
},
{
maxvalue: "8",
displayvalue: "6-8",
code: "#E53935"
},
{
maxvalue: "10",
displayvalue: "8-10",
code: "#C62828"
},
{
maxvalue: "11",
displayvalue: "No data available",
code: "#FFEBEE"
}
]
},
data: [
{
data:
fusion1.html
}
]
};
FusionCharts.ready(function() {
var myChart = new FusionCharts({
type: "europe",
renderAt: "chart-container",
width: "100%",
height: "100%",
dataFormat: "json",
dataSource
}).render();
});
</script>
</head>
<body>
<div id="chart-container">FusionCharts XT will load here!</div>
</body>
</html>
fusionchart.web
<JAVA>
<USE> java7displayurl;
<USE> format;
<PACK> Program121
{
<CLASS> Prog
{
public void main()
{
String s="";
// it will get the json from web1.0 webservice url
s= java7UrlConnectionReader.getUrlContents("http://localhost:8082/json1.WS").Replace("<HTML>","").Replace("</html>","");
// this statement will print additional line spaces with the fusion.html file contents in web
J7HTML.displayhtml("fusion.html");
<PRINTLN>(""+s);
J7HTML.displayhtml("fusion1.html");
}
}
}
Note:
You had to include java7UrlConnectionReader.dll, J7Html.dll in Web7(OJ7) properties file..
Fusion chart is used for geographical chart display.
Start Web1.0Part2 webservice server to run json1.WS -json webservice.
Here we are using json web1.0 webservice..
OUTPUT
FAQS
Why nine demos are published for professional edition for Machine Learning?
Competitors are competive with WEB7(Oj7) programming language
in Machine Learning without any reason.Copying the features
and implementing in their technology is a frauds and fools.
Mostly Python professionals are doing this evil things.
According to 10 commandments of bibble it says
Don't steal other things.That's why professionals
can see only the 9 samples. This is a professional
Website not an Enterprise website.Only 20%
of samples are publish due to this competitors.
======END of Professional Edition Version 1 for MachineLearning==========================