JAVA7.0-MachineLearning-Part1

JAVA7.0 Machine Learning Part-1

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  machinelearning  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 Java7 shell prompt.

About Java7.0 Machinelearning

===========================

 Java7.0 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 WEBapplication with MachineLearning can fail.

 That why Java7.0 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 Java7.0 Developers...

Rules For Java7.0 Developers for Java7.0 MachineLearning/WebApplication  is

===============================================================

A) A Java7.0 code may be medium since it is focused for webapplication 

b) Mostly follow javac7 <filename.web> to write a short code..

c) Involve in writing your own logic for for loop or any Java7.0 - loop..

d) Test the Java7.0 program using Java7Shell prompt.

e)Mostly Use Java7.0 libraries...

f) Try to write a   OakJava7(JAVA7.0)-java7  logic and convert to .dll package and use it in javac7 <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 OakJava7(filename.web)

=========================================================================================

Sample A : Oakjava7 Introduction with machine learning syntax with user friendly

framework  OJ7UA (Oakjava7 userfriendly Application).

==========================================================================================

Syntax for OakJava7 Machine Learning program



<filename>.oj7ua

 <OJ7ML> // Beginning of OakJava7 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 OakJava7 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 OakJava7 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 OakJava7

LOGIC=' 


  

//Business logic methods

public static void Method2()


{


<!----- write Business Logic and  use OakJava7 Servlet ----!>


}






// Close the Logic section

'>


// Close  the OakJava7 program 

</OakJava7>


// End of  Oakjava7 Program

</OJ7ML>




Explanation 

Here when you code the Machine Learning program  using this syntax and compile it using javac7 <filename.oj7ua> , 

it will automatically convert to  Oakjava7 program ie(.web) . And you will get a optimized oakjava7 (.web) code and .exe   and .ojava7 files.

You can also test the  OakJava7 Machine Learning program using generated (.web) code...So when we notice that here <OJ7ML>  act like a OakJava7 user friendly framework. It act like a XML syntax with data present inside it.

This  OakJava7  Machine Learning program (<OJ7ML) will automatically generate (.web). This (<OJ7ML>) 

program has attractive syntax.So it is considered as a OakJava7 advanced framework or 

OakJava7 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 "OAKJAVA7MACHINELEARNING"

It is used for Dynamic Webpages construction ie) DB with GUI + Business Logic and OakJava7 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 oakjava7

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 OakJava7 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 Oakjava7 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  OakJava7 Machine learning concepts..


How Oakjava7 Program Works with UserFriendly Framework(OJ7UA) ? Explain with

an example ? 


OakJava7 Program (.Web) is automatically generated by  UserFriendly 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 Oakjava7 Program and linegraph1 indicates 

OakJava7 Class name. So when you compile using javac7 linegraph5.oj7ua

will automatically generate the linegraph5.web file.You can use linegrap5.web file

for testing the Oakjava7 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 userfriendly program (OJ7UA) 


Step 2: Follow the rules of OakJava7 OJ7UA userfriendly program (OJ7UA) 


Step 3: Compile it using JAVA7.0 Shell or Using Visual Studio code. ie) Use javac7 <filename.oj7ua>


eg) Here we compile using javac7 linegraph5.oj7ua in Visual Studio code two times  or compile it in


 JAVA7.0 Shell for only one time.You can see the compilation of Oakjava7 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 javac7 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 Oakjava7 program using RunJava7 <filename> ie)

RunJava7 linegraph5 in JAVA7.0 Shell.Or else copy

the two files(.exe ,.ojava7) and used that files in Scroll Server for webapplication. 

You can see  the  screenshot  in  OakJava7  EBook.

==============================================================================================

Sample-1:   Write  a   Java7.0-oakjava7.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 OakJava7 used for machine learning  -->

<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 Oakjava7 Userfriendly framework(Oj7UA).


Explanation

This g$ is the  Special character used  in OakJava7 Machine learning.

This g$ means special character '<' . eg) When we use PRINTLN means 

it is  equivalent to <PRINTLN> in OakJava7 (.web).So this

statement PRINTLN("g$BR>"); is equivalent  to  <PRINTLN>("<BR>");

so g$ is equivalent to '<' ie) Lesser than symbol '<'.


Output in Scroll Webpage format  is

It will show beautiful Template with the beautiful clock with

values print on the oakjava7 webpage.



Sample-1: Write  a   Java7.0-oakjava7.web  program  to  calculate   ChiSquare value,MeanMedian(Median,Sum,Avg,list MaximumRepeatingElement),Variance  and Standard Deviation,Percentile for  Students,Scale.

Java7.0-oakjava7.web

====================

<WEB>

<USE> Java7ML;

<USE> <OJ7UTIL>;  // use Oakjava7 util package

<PACK>  sampleml1

{

<CLASS>  misctype1

    {

           public void main()

        {

            

            //chisquare test

            ArrayList observedvalue = new ArrayList();

            ArrayList expectedvalue = new ArrayList();

            observedvalue.add(85);

            observedvalue.add(15);

            expectedvalue.add(75);

            expectedvalue.add(25);

            double chi = Java7ML.ChiSquare.chisquaretest(observedvalue, expectedvalue);

            <PRINTLN>("Observed value=" + Java7ML.ChiSquare.osum);

            <PRINTLN>("Expected value=" + Java7ML.ChiSquare.esum);

            <PRINTLN>("Chi-Square value=" + chi);

//MeanMedianMode

            int n = 5;

            int[] a = { 2, 6, 7, 4, 9 };

            <PRINTLN>("Mean ::" + Java7ML.MeanMedianMode.Mean(a, n));

            int[] values = { 2, 3, 6, 12, 15, 34, 65, 78, 99 };

            // calculate median

            double median1 = Java7ML.MeanMedianMode.median(values);

            <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>(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>("SUM=" + sum1);

            double avg1 = Java7ML.MeanMedianMode.AVG(sum1, a1.Length);

            <PRINTLN>("AVG=" + avg1);

            //stdvariance

            double [] arr = { 32, 111, 138, 28, 59, 77, 97 };

            int n1 = arr.Length;

            <PRINTLN>("Variance: " +

                                 Java7ML.stdvariance.variance(arr, n1));

            <PRINTLN>("Standard Deviation: " +

                                 Java7ML.stdvariance.standardDeviation(arr, n1));

            //percentile

            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>("Percentile=" + Java7ML.Percentile.Studentpercentile(StudentMarks, n2, percent));

            //scale

            double[] ar = { 32, 111, 138, 28, 59, 77, 97 };

            double mean1 = Java7ML.Scale.median(ar);

            <PRINTLN>("Mean=" + mean1);

            int n3 = ar.Length;

            double std1 = Java7ML.stdvariance.variance(ar, n3);

            <PRINTLN>("STD=" + std1);

            double[] cr = new double[ar.Length];

            cr = Java7ML.Scale.calculate(ar, mean1, std1);

            for (int i = 0; i < cr.Length; i++)

                <PRINTLN>("" + cr[i]);

            Console.ReadKey();

 

        }

    }

}

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 repetation.

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  StudentPercentile based  on  given 

array  StudentMarks 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:

=======

================================================================================================

                                                                     SAMPLE-2 : Bernouli Distribution

==============================================================================================

Write  a  Java7.0 Program  for  Bernouli Distribution using Oj7ua framework:-


Bernouli5.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>


SAMPLE-2: Write  a  Java7.0 Program  for  Bernouli Distribution

===================================================

Bernoulli.web

=============

<WEB>

<USE> Java7MLGraphics;

<PACK> Bernoulli1

{

<CLASS> binomialdist

    {

           public void main()

        {

            

           Bernoulli.Draw(32, 1000, 0, 0.2);

            Console.ReadKey();

 

        }

    }

}

Note:  This  can  be  done in  just  one line

ie)  Bernoulli.Draw(32, 1000, 0, 0.2)

Syntax  For  Bernoulli  Distribution  is

Bernoulli.Draw(int n, int trials,int coord1,double coord2)

Note: You  can  to include   Java7MLGraphics.dll,IKVM.OpenJDK.SwingAWT.dll

in  Java7.0 properties  file..

Output

======

======================================================================================

                                                      SAMPLE-3 : Binomial Distribution

=====================================================================================

Q)  Write  a  Java7.0 Program  for  Binomial Distribution using Oj7ua framework:-



Binomialdist.oj7ua

<OJ7ML>

<DESIGN  


SRC='

'> 

</DESIGN>


<OakJava7 Package='ML' Database='wnosql' J7Lib='{Java7MLGraphics}' Names='graphicsa,Binomial5' Type='exe'  

MAIN='    Binomial.Draw();   ?>  '

LOGIC='   '>

</OakJava7>

</OJ7ML>



SAMPLE-3: Write  a  Java7.0 Program  for  Binomial Distribution

====================================================

Binomial.web

============

<WEB>

<USE> Java7MLGraphics;

<PACK> ConsoleApp28

{

<CLASS> binomialdist

    {

           public void main()

        {

            

           Binomial.Draw();

            Console.ReadKey();

 

        }

    }

}

Note:  This  can  be  done in  just  one line

ie)  Binomial.Draw()

Note: You  must include   Java7MLGraphics.dll,IKVM.OpenJDK.SwingAWT.dll

in  Java7.0 properties  file..

Output

======

================================================================================================

SAMPLE-4: Write  a  Java7.0 Program  for COS WAVE  and  SIN WAVE

================================================================================================

Q) Write  a  Java7.0 Program  for  CosWave using Oj7ua framework:-


<OJ7ML>

<DESIGN  


SRC='

'> 


</DESIGN>


<OakJava7 Package='ML' Database='wnosql' J7Lib='{Java7MLGraphics}' Names='graphicsa,Coswave5' Type='exe'  

 MAIN='       Java7MLGraphics.Wave.Draw(2);  ?>  '


LOGIC='   '>

</OakJava7>

</OJ7ML>



SAMPLE-4: Write  a  Java7.0 Program  for COS WAVE  and  SIN WAVE

========================================================

CosWave.web

===========

<WEB>

<USE> Java7MLGraphics;

<PACK> ConsoleApp28

{

<CLASS> CosWave

    {

           public void main()

        {

            

           Java7MLGraphics.Wave.Draw(2);

            Console.ReadKey();

 

        }

    }

}

Note:  This  can  be  done in  just  one line

ie)  Java7MLGraphics.Wave.Draw(2); where  choice 2 represent coswave.

but where choice 1  represent SineWave.

Note: You  can  to include   Java7MLGraphics.dll,IKVM.OpenJDK.SwingAWT.dll

in  Java7.0 properties  file..

Output

======

=================================================================================================

                                  SAMPLE-5: JAVA7.0 Scatter  chart

=================================================================================================

Q) Write  a  Java7.0 Program  for  Scatterchart5 using Oj7ua framework and Scroll server

 to  display the chart in google browser.



Scatterchart5.oj7ua


<OJ7ML>

<DESIGN  

SRC='   '> 


</DESIGN>


<OakJava7 Package='wil' Database='wnosql' J7Lib='{java7displayurl,format}' Names='fusion,charts' Type='exe' MAIN=' display();?> '


LOGIC=' public static void display() {


String data="[[ l$Agel$, l$Weightl$], [ 8,12],[ 4,5.5],[ 11,14],[ 4,5],[ 3,3.5],[ 6.5,7]]";


String display=Oj7ui.OJ7ML.Oj7Html("scatter.html",data,"scatter1.html");PRINTLN(display);


}  '>



</OakJava7>


</OJ7ML>



Note: This l$ represent Special character ( ' ).


Explanation

Here in this example we pass scatter.html and data and scatter1.html to the

method  Oj7ui.OJ7ML.Oj7Html("scatter.html",data,"scatter1.html");

After passing it, it will display a scatter chart in Google browser or  any server.



JAVA7.0 Scatter  chart

==================

Programs12.web

==============

<WEB>

<PACK> Program121

{

  

    <CLASS> Prog

   {

  

      public void main()

      {

 

String data="[['Age', 'Weight'], [ 8,12],[ 4,5.5],[ 11,14],[ 4,5],[ 3,3.5],[ 6.5,7]]";

//display the  contents  of  html

HTML.displayhtml("scatter.html");

//print  the  data  in  web

<PRINTLN>(""+data);

//display  the  contents  of  html

HTML.displayhtml("scatter1.html");

 

      }

   }

}

scatter.html

============

<html>

  <head>

    <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>

    <script type="text/javascript">

      google.charts.load('current', {'packages':['corechart']});

      google.charts.setOnLoadCallback(drawChart);

      function drawChart() {

        var data = google.visualization.arrayToDataTable(

scatter1.html

=============

);

        var options = {

          title: 'Age vs. Weight comparison',

          hAxis: {title: 'Age', minValue: 0, maxValue: 15},

          vAxis: {title: 'Weight', minValue: 0, maxValue: 15},

          legend: 'none'

        };

        var chart = 

new google.visualization.ScatterChart(document.getElementById('chart_div'));

        chart.draw(data, options);

      }

    </script>

  </head>

  <body>

    <div id="chart_div" style="width: 900px; height: 500px;"></div>

  </body>

</html>

Explanation:

============

JAVA7.0 Scatterchart can be  achieved  by  Google chart  and  OakJava7(Java7.0).web.

But  here  you  had  to  include  HTML.dll  in JAVA7.0 Properties  file.

      

Output

======

=================================================================================================

          SAMPLE-6: Geographical  charts with  fusion charts using  JAVA7.0

=================================================================================================

Q) Write  a  Java7.0 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='wnosql' J7Lib='{java7displayurl,format}' Names='fusion,charts' 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>","");

String display=Oj7ui.OJ7ML.Oj7Html("fusion.html",s,"fusion1.html");PRINTLN(display);   }  '>


</OakJava7>


</OJ7ML>


Note: Here  java7displayurl , format  are oakjava7 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

===============

<WEB>

//load this  packages

<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  Java7.0 properties  file..

Fusionchart  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

=======

=================================================================================================

        Sample-7: HeatMapplots in Apexplot  using  Java7.0

=================================================================================================

HeatMapplots in Apexplot  using  Java7.0 and OJ7UA framework

=====================================================================

Apexplot

==========

Apexplot1.oj7ua

<OJ7ML>

<DESIGN  SRC='public static void Display(){  HTML.displayhtml("rounded2.html"); }  '> </DESIGN>

<OakJava7 Package='ML' Database='wnosql'  J7Lib='{}' Names='example2,Apexplot' Type='exe'  MAIN='HTML.displayhtml("rounded1.html");

oj7servleteg1();Display(); ?> '


LOGIC=' public static void oj7servleteg1() {


String s=""; 

s="series: [{";


PRINTLN(s);


 s="         name: l$Metric1l$,";


PRINTLN(s);


 s="         data: generateData(20, {";


PRINTLN(s);


    s="        min: 0,";


PRINTLN(s);


       s="     max: 90";


PRINTLN(s);


          s="})";


PRINTLN(s);


        s="},";


PRINTLN(s);


        s="{";


PRINTLN(s);


         s=" name: l$Metric2l$,";


PRINTLN(s);


          s="data: generateData(20, {";


PRINTLN(s);


            s="min: 0,";


PRINTLN(s);


            s="max: 90";


PRINTLN(s);


          s="})";


PRINTLN(s);


        s="},";


PRINTLN(s);


        s="{";


PRINTLN(s);


         s=" name: l$Metric3l$,";


PRINTLN(s);


          s="data: generateData(20, {";


PRINTLN(s);


           s=" min: 0,";


PRINTLN(s);


            s="max: 90";


PRINTLN(s);


          s="})";


PRINTLN(s);


        s="},";


PRINTLN(s);


        s="{";


PRINTLN(s);


          s="name: l$Metric4l$,";


PRINTLN(s);


         s=" data: generateData(20, {";


PRINTLN(s);


            s="min: 0,";


PRINTLN(s);


           s=" max: 90";


PRINTLN(s);


         s=" })";


PRINTLN(s);


       s=" },";


PRINTLN(s);


        s="{";


PRINTLN(s);


          s="name: l$Metric5l$,";


PRINTLN(s);


          s="data: generateData(20, {";


PRINTLN(s);


           s=" min: 0,";


PRINTLN(s);


            s="max: 90";


PRINTLN(s);


          s="})";


PRINTLN(s);


        s="},";


PRINTLN(s);


        s="{";


PRINTLN(s);


          s="name: l$Metric6l$,";


PRINTLN(s);


         s=" data: generateData(20, {";


PRINTLN(s);


            s="min: 0,";


PRINTLN(s);


            s="max: 90 ";


PRINTLN(s);


         s=" })";


PRINTLN(s);


        s="},";


PRINTLN(s);


        s="{";


PRINTLN(s);


          s="name: l$Metric7l$,";


PRINTLN(s);


         s=" data: generateData(20, {";


PRINTLN(s);


           s=" min: 0,";


PRINTLN(s);


           s=" max: 90";


PRINTLN(s);


         s=" })";


PRINTLN(s);


       s=" },";


PRINTLN(s);


       s=" {";


PRINTLN(s);


          s="name: l$Metric8l$,";


PRINTLN(s);


         s=" data: generateData(20, {";


PRINTLN(s);


            s="min: 0,";


PRINTLN(s);


           s=" max: 90";


PRINTLN(s);


         s=" })";


PRINTLN(s);


        s="},";


PRINTLN(s);


        s="{";


PRINTLN(s);


          s="name: l$Metric8l$,";


PRINTLN(s);


          s="data: generateData(20, {";


PRINTLN(s);


           s=" min: 0,";


PRINTLN(s);


           s=" max: 90";


PRINTLN(s);


         s=" })";


PRINTLN(s);


        s="}";


PRINTLN(s);


        s="],";


PRINTLN(s);


          s="chart: {";


PRINTLN(s);


          s="height: 350,";


PRINTLN(s);


          s="type: l$heatmapl$,";


PRINTLN(s);


       s=" },";


PRINTLN(s);


       s=" stroke: {";


PRINTLN(s);


          s="width: 0";


PRINTLN(s);


        s="},";


PRINTLN(s);


        s=" plotOptions: {";


PRINTLN(s);


         s=" heatmap: {";


PRINTLN(s);


          s="  radius: 30,";


PRINTLN(s);


            s=" enableShades: false,";


PRINTLN(s);


           s=" colorScale: {";


PRINTLN(s);


              s=" ranges: [{";


PRINTLN(s);


                 s=" from: 0,";


PRINTLN(s);


                 s=" to: 50,";


PRINTLN(s);

                 s=" color:l$#008FFBl$";


PRINTLN(s);


               s=" },";


PRINTLN(s);


               s=" {";


PRINTLN(s);


              s="    from: 51,";


PRINTLN(s);


                 s=" to: 100,";


PRINTLN(s);


                s="  color:l$#00E396l$";


PRINTLN(s);


             s="   },";


PRINTLN(s);


          s="    ],";


PRINTLN(s);


        s="    },";


PRINTLN(s);


         s=" }";


PRINTLN(s);


       s=" },";


PRINTLN(s);


        s="dataLabels: {";


PRINTLN(s);


          s="enabled: true,";


PRINTLN(s);


          s="style: {";


PRINTLN(s);


            s="colors: [l$#fffl$]";


PRINTLN(s);


          s="}";


PRINTLN(s);


       s=" },";


PRINTLN(s);


        s="xaxis: {";


PRINTLN(s);


        s="  type: l$categoryl$,";


PRINTLN(s);


       s=" },";


PRINTLN(s);


      s="  title: {";


PRINTLN(s);


   s="       text: l$Rounded (Range without Shades)l$";


PRINTLN(s);


s="        },";


PRINTLN(s);

}'>

</OakJava7>

</OJ7ML>


rounded1.html

============

<!DOCTYPE html>

<html lang="en">

  <head>

    <meta charset="UTF-8" />

    <meta name="viewport" content="width=device-width, initial-scale=1.0" />

    <meta http-equiv="X-UA-Compatible" content="ie=edge" />

    <title>Simple HeatMap</title>

    <link href="../../assets/styles.css" rel="stylesheet" />

    <style>

      

        #chart {

      max-width: 650px;

      margin: 35px auto;

    }

      

    </style>

    <script>

      window.Promise ||

        document.write(

          '<script src="https://cdn.jsdelivr.net/npm/promise-polyfill@8/dist/polyfill.min.js"><\/script>'

        )

      window.Promise ||

        document.write(

          '<script src="https://cdn.jsdelivr.net/npm/eligrey-classlist-js-polyfill@1.2.20171210/classList.min.js"><\/script>'

        )

      window.Promise ||

        document.write(

          '<script src="https://cdn.jsdelivr.net/npm/findindex_polyfill_mdn"><\/script>'

        )

    </script>

    

    <script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>

    

    <script>

  function generateData(count, yrange) {

    var i = 0;

    var series = [];

    while (i < count) {

      var x = (i + 1).toString();

      var y = Math.floor(Math.random() * (yrange.max - yrange.min + 1)) + yrange.min;

  

      series.push({

        x: x,

        y: y

      });

      i++;

    }

    return series;

  }

  </script>

  </head>

  <body>

     <div id="chart"></div>

    <script>

      

        var options = {

         

rounded2.html

==============

        };

        var chart = new ApexCharts(document.querySelector("#chart"), options);

        chart.render();

      

      

    </script>

    

  </body>

</html>

Apexplot.web

============

<WEB>

<PACK> Program121

{

  

    <CLASS> Prog

   {

  

      public void main()

      {

 

String s="";

HTML.displayhtml("rounded1.html");

s="series: [{";

<PRINTLN>(s);

 s="         name: 'Metric1',";

<PRINTLN>(s);

 s="         data: generateData(20, {";

<PRINTLN>(s);

    s="        min: 0,";

<PRINTLN>(s);

       s="     max: 90";

<PRINTLN>(s);

          s="})";

<PRINTLN>(s);

        s="},";

<PRINTLN>(s);

        s="{";

<PRINTLN>(s);

         s=" name: 'Metric2',";

<PRINTLN>(s);

          s="data: generateData(20, {";

<PRINTLN>(s);

            s="min: 0,";

<PRINTLN>(s);

            s="max: 90";

<PRINTLN>(s);

          s="})";

<PRINTLN>(s);

        s="},";

<PRINTLN>(s);

        s="{";

<PRINTLN>(s);

         s=" name: 'Metric3',";

<PRINTLN>(s);

          s="data: generateData(20, {";

<PRINTLN>(s);

           s=" min: 0,";

<PRINTLN>(s);

            s="max: 90";

<PRINTLN>(s);

          s="})";

<PRINTLN>(s);

        s="},";

<PRINTLN>(s);

        s="{";

<PRINTLN>(s);

          s="name: 'Metric4',";

<PRINTLN>(s);

         s=" data: generateData(20, {";

<PRINTLN>(s);

            s="min: 0,";

<PRINTLN>(s);

           s=" max: 90";

<PRINTLN>(s);

         s=" })";

<PRINTLN>(s);

       s=" },";

<PRINTLN>(s);

        s="{";

<PRINTLN>(s);

          s="name: 'Metric5',";

<PRINTLN>(s);

          s="data: generateData(20, {";

<PRINTLN>(s);

           s=" min: 0,";

<PRINTLN>(s);

            s="max: 90";

<PRINTLN>(s);

          s="})";

<PRINTLN>(s);

        s="},";

<PRINTLN>(s);

        s="{";

<PRINTLN>(s);

          s="name: 'Metric6',";

<PRINTLN>(s);

         s=" data: generateData(20, {";

<PRINTLN>(s);

            s="min: 0,";

<PRINTLN>(s);

            s="max: 90 ";

<PRINTLN>(s);

         s=" })";

<PRINTLN>(s);

        s="},";

<PRINTLN>(s);

        s="{";

<PRINTLN>(s);

          s="name: 'Metric7',";

<PRINTLN>(s);

         s=" data: generateData(20, {";

<PRINTLN>(s);

           s=" min: 0,";

<PRINTLN>(s);

           s=" max: 90";

<PRINTLN>(s);

         s=" })";

<PRINTLN>(s);

       s=" },";

<PRINTLN>(s);

       s=" {";

<PRINTLN>(s);

          s="name: 'Metric8',";

<PRINTLN>(s);

         s=" data: generateData(20, {";

<PRINTLN>(s);

            s="min: 0,";

<PRINTLN>(s);

           s=" max: 90";

<PRINTLN>(s);

         s=" })";

<PRINTLN>(s);

        s="},";

<PRINTLN>(s);

        s="{";

<PRINTLN>(s);

          s="name: 'Metric8',";

<PRINTLN>(s);

          s="data: generateData(20, {";

<PRINTLN>(s);

           s=" min: 0,";

<PRINTLN>(s);

           s=" max: 90";

<PRINTLN>(s);

         s=" })";

<PRINTLN>(s);

        s="}";

<PRINTLN>(s);

        s="],";

<PRINTLN>(s);

          s="chart: {";

<PRINTLN>(s);

          s="height: 350,";

<PRINTLN>(s);

          s="type: 'heatmap',";

<PRINTLN>(s);

       s=" },";

<PRINTLN>(s);

       s=" stroke: {";

<PRINTLN>(s);

          s="width: 0";

<PRINTLN>(s);

        s="},";

<PRINTLN>(s);

        s=" plotOptions: {";

<PRINTLN>(s);

         s=" heatmap: {";

<PRINTLN>(s);

          s="  radius: 30,";

<PRINTLN>(s);

            s=" enableShades: false,";

<PRINTLN>(s);

           s=" colorScale: {";

<PRINTLN>(s);

              s=" ranges: [{";

<PRINTLN>(s);

                 s=" from: 0,";

<PRINTLN>(s);

                 s=" to: 50,";

<PRINTLN>(s);

                 s=" color: '#008FFB'";

<PRINTLN>(s);

               s=" },";

<PRINTLN>(s);

               s=" {";

<PRINTLN>(s);

              s="    from: 51,";

<PRINTLN>(s);

                 s=" to: 100,";

<PRINTLN>(s);

                s="  color: '#00E396'";

<PRINTLN>(s);

             s="   },";

<PRINTLN>(s);

          s="    ],";

<PRINTLN>(s);

        s="    },";

<PRINTLN>(s);

        

         s=" }";

<PRINTLN>(s);

       s=" },";

<PRINTLN>(s);

        s="dataLabels: {";

<PRINTLN>(s);

          s="enabled: true,";

<PRINTLN>(s);

          s="style: {";

<PRINTLN>(s);

            s="colors: ['#fff']";

<PRINTLN>(s);

          s="}";

<PRINTLN>(s);

       s=" },";

<PRINTLN>(s);

        s="xaxis: {";

<PRINTLN>(s);

        s="  type: 'category',";

<PRINTLN>(s);

       s=" },";

<PRINTLN>(s);

      s="  title: {";

<PRINTLN>(s);

   s="       text: 'Rounded (Range without Shades)'";

<PRINTLN>(s);

s="        },";

<PRINTLN>(s);

HTML.displayhtml("rounded2.html");

 

      }

   }

}

Note:

Apexplot  is  used  for  heatmapplot.

Here you  must follow  Java7.0 -Servlet  ie)  If  you  print   html code line  by line

by  using <PRINTLN> statement  is  known  as  JAVA7.0 Servlet.

Here you  must  include  series data by  Java7.0 Servlet  by  this  format  to  display  Apex charts.

Here you  must  include  HTML.dll  in Java7.0 properties file..

  

Output

======

=================================================================================================

SAMPLE -8 : BarChart3D  with  Jfreechart  with  Java7.0

=================================================================================================

BarChart3D.java7

===============

<JAVA7> 

<IMPORT> org.jfree.chart.ChartFactory; 

<IMPORT> org.jfree.chart.JFreeChart; 

<IMPORT> org.jfree.chart.plot.PlotOrientation; 

<IMPORT> org.jfree.data.category.DefaultCategoryDataset; 

<IMPORT> org.jfree.chart.ChartUtilities; 


public <CLASS> BarChart3D <%

   

 <MAIN> //Java7  main program

throws Exception <%

   // <J7String>  is  String  type  in java7.0

        final <J7String> fait = "FAIT";              

      final <J7String> audi = "AUDI";              

      final <J7String> ford = "FORD";              

      final <J7String> speed = "Speed";              

      final <J7String> popular = "Popular";              

      final <J7String> mailage = "Mailage";              

      final <J7String> userrating = "User Rating";              

      final <J7String> safety = "safety";        

      final DefaultCategoryDataset data <NEW> DefaultCategoryDataset( ); 


      data.addValue( 1.0 , fait , speed );              

      data.addValue( 4.0 , fait , popular );              

      data.addValue( 3.0 , fait , userrating );              

      data.addValue( 5.0 , fait , mailage );              

      data.addValue( 5.0 , fait , safety );              

      

      data.addValue( 5.0 , audi , speed );              

      data.addValue( 7.0 , audi , popular );              

      data.addValue( 6.0 , audi , userrating );              

      data.addValue( 10.0 , audi , mailage );              

      data.addValue( 4.0 , audi , safety ); 

      

      data.addValue( 4.0 , ford , speed );              

      data.addValue( 3.0 , ford , popular );              

      data.addValue( 2.0 , ford , userrating );              

      data.addValue( 3.0 , ford , mailage );              

      data.addValue( 6.0 , ford , safety );                 

      

      JFreeChart barChart = ChartFactory.createBarChart3D(

         "Car Usage Statistics",             

         "Category",             

         "Score",             

         data,            

     // <Vertical>   is  vertical type

        PlotOrientation.<Vertical>,             

         true, true, false);

         

      int width = 640; /* Width of the image */              

      int height = 480; /* Height of the image */                              

      File barChart3D <NEW> File( "barChart3D.jpeg" );                            

      ChartUtilities.saveChartAsJPEG( barChart3D, barChart, width, height);

  %>

</JAVA7>


Note:

======

You  can  also  compile  this  Java7.0 file  in JAVA7SHELL prompt using  javac7  BarChart3D.java7

and  run  the  program  using  java7 BarChart3D in Java7Shell.

For  BarChart3D  you  had  to follow  Freechart..

when you  run this  Java7.0 program  it  generates barChart3D.jpeg file.

Now  You  can  also use  it  in  your  Java7.0 WebApplication.

simillarly you can   do  for  pie  chart  with  jfreechart.

Now  you  can  see  the  output  which  is  given  below

Output

=======

=================================================================================================

SAMPLE -9 : TimeSeriesChart  with  Jfreechart  with  Java7.0

=================================================================================================

TimeSeriesChart1.java7

=====================

<JAVA7>


<IMPORT> org.jfree.chart.ChartFactory;

<IMPORT> org.jfree.chart.JFreeChart;

<IMPORT> org.jfree.data.general.SeriesException;

<IMPORT> org.jfree.data.time.Second;

<IMPORT> org.jfree.data.time.TimeSeries;

<IMPORT> org.jfree.data.time.TimeSeriesCollection;

<IMPORT> org.jfree.data.xy.XYDataset;

<IMPORT> org.jfree.chart.ChartUtilities;


public <CLASS> TimeSeriesChart1 <%

   

   <MAIN>


throws Exception <%



      final TimeSeries series <NEW> TimeSeries( "Random Data" );

      Second current <NEW> Second();

      double value = 100.0;

      

      for ( int i = 0 ; i < 4000 ; i++ ) <%

         //<TRY> means try block

         <TRY> <%

            value = value + Math.random( ) - 0.5;

            series.add( current , new Double( value ) );

            current = ( Second ) current.next( );

        %> 

     //<CATCH>  means  catch  exception

     <CATCH> ( SeriesException e ) <%

            System.err.println( "Error adding to series" );

        %>

     %>

      

      final XYDataset datas=( XYDataset )new TimeSeriesCollection(series);

      JFreeChart timechart = ChartFactory.createTimeSeriesChart(

         "ComPUTing Test", 

         "Seconds", 

         "Value", 

         datas,

         false, 

         false, 

         false);

         

      int width = 560;   /* Width of the image */

      int height = 370;  /* Height of the image */ 

      File timeChart <NEW> File( "TimeChart.jpeg" ); 

      ChartUtilities.saveChartAsJPEG( timeChart, timechart, width, height );

  %>

</JAVA7>



Note:

=====

You  can  also  compile  this  Java7.0 file  in JAVA7SHELL prompt using  javac7 TimeSeriesChart1.java7

and  run  the  program  using  java7  TimeSeriesChart1 in Java7Shell.

For  TimeSeriesChart  you  had  to follow  Freechart..

when you  run this  Java7.0 program  it  generates TimeChart.jpeg file.

Now  You  can  also use  it  in  your  Java7.0 WebApplication.

Now  you  can  see  the  output  which  is  given  below

Output:

======

=================================================================================================

                                                

                                                  SAMPLE-10:  JAVA7.0 DATE  and  JAVA7.0 DATE AND  TIME MANIPULATION

=================================================================================================

Java7.0 DATE


Q) Write  oakjava7(JAVA7.0)  Servlet program  to  Manipulate  date  and Time and display it in  Google  or any browser?

datetimes.oj7ua

<OJ7ML>

<DESIGN  

SRC=' '> 

</DESIGN>

<OakJava7 Package='ML' Database='wnosql' J7Lib='{}' Names='dattime,dattimes' Type='exe'  MAIN='Oakjava7Servlet(); ?> '

LOGIC=' public static void Oakjava7Servlet() {

           DateTime aDate = DateTime.Now;  

            PRINTLN("g$br>");


            PRINTLN("MM/dd/yyy"+aDate.ToString("MM/dd/yyyy"));  PRINTLN("g$br>");


            PRINTLN(aDate.ToString("dddd, dd MMMM yyyy"));  PRINTLN("g$br>");


            PRINTLN(aDate.ToString("dddd, dd MMMM yyyy"));  PRINTLN("g$br>");


            PRINTLN(aDate.ToString("dddd, dd MMMM yyyy"));  PRINTLN("g$br>");


            PRINTLN(aDate.ToString("dddd, dd MMMM yyyy"));  PRINTLN("g$br>");


            PRINTLN(aDate.ToString("dddd, dd MMMM yyyy"));  PRINTLN("g$br>");


            PRINTLN(aDate.ToString("dddd, dd MMMM yyyy HH:mm:ss"));  PRINTLN("g$br>");


            PRINTLN(aDate.ToString("MM/dd/yyyy HH:mm"));  PRINTLN("g$br>");


            PRINTLN(aDate.ToString("MM/dd/yyyy hh:mm tt"));  PRINTLN("g$br>");


            PRINTLN(aDate.ToString("MM/dd/yyyy H:mm"));  PRINTLN("g$br>");


            PRINTLN(aDate.ToString("MM/dd/yyyy h:mm tt"));  PRINTLN("g$br>");


            PRINTLN(aDate.ToString("MM/dd/yyyy HH:mm:ss")); PRINTLN("g$br>");


             PRINTLN("g$br>");


            PRINTLN(aDate.ToString("MMMM dd"));  PRINTLN("g$br>");


            PRINTLN(aDate.ToString("HH:mm"));  PRINTLN("g$br>");


            PRINTLN(aDate.ToString("hh:mm tt"));  PRINTLN("g$br>");


            PRINTLN(aDate.ToString("H:mm"));  PRINTLN("g$br>");


            PRINTLN(aDate.ToString("h:mm tt"));  PRINTLN("g$br>");


            PRINTLN(aDate.ToString("HH:mm:ss"));  PRINTLN("g$br>");PRINTLN("g$br>");


            PRINTLN(aDate.ToString("yyyy MMMM"));  PRINTLN("g$br>"); } '>


</OakJava7>

</OJ7ML>


date.web

=========

<WEB>

  

<PACK> DateTime 

{  

    <CLASS> Program  

    {  

        public void main()  

        {  

            // Get current DateTime. It can be any DateTime object in your code.  

            DateTime aDate = DateTime.Now;  

  

            // Format Datetime in different formats and display them  

            <PRINTLN>("MM/dd/yyy"+aDate.ToString("MM/dd/yyyy"));  

            <PRINTLN>(aDate.ToString("dddd, dd MMMM yyyy"));  

            <PRINTLN>(aDate.ToString("dddd, dd MMMM yyyy"));  

            <PRINTLN>(aDate.ToString("dddd, dd MMMM yyyy"));  

            <PRINTLN>(aDate.ToString("dddd, dd MMMM yyyy"));  

            <PRINTLN>(aDate.ToString("dddd, dd MMMM yyyy"));  

            <PRINTLN>(aDate.ToString("dddd, dd MMMM yyyy HH:mm:ss"));  

            <PRINTLN>(aDate.ToString("MM/dd/yyyy HH:mm"));  

            <PRINTLN>(aDate.ToString("MM/dd/yyyy hh:mm tt"));  

            <PRINTLN>(aDate.ToString("MM/dd/yyyy H:mm"));  

            <PRINTLN>(aDate.ToString("MM/dd/yyyy h:mm tt"));  

            <PRINTLN>(aDate.ToString("MM/dd/yyyy HH:mm:ss")); 

 

            <PRINTLN>(aDate.ToString("MMMM dd"));  

            <PRINTLN>(aDate.ToString("HH:mm"));  

            <PRINTLN>(aDate.ToString("hh:mm tt"));  

            <PRINTLN>(aDate.ToString("H:mm"));  

            <PRINTLN>(aDate.ToString("h:mm tt"));  

            <PRINTLN>(aDate.ToString("HH:mm:ss"));  

            <PRINTLN>(aDate.ToString("yyyy MMMM"));  

  

 

        }  

    }  

}

Output

JAVA7.0   DATE AND TIME MANIPULATION

dates5.oj7ua

<OJ7ML>

<DESIGN  SRC=' '> 

</DESIGN>

<OakJava7 Package='ML' Database='wnosql' J7Lib='{}' Names='dattime,dattimes' Type='exe'  MAIN='Oakjava7Servlet(); ?> '

LOGIC=' public static void Oakjava7Servlet() {

PRINTLN("g$BR>");

DateTime d1  g$NEW> DateTime(2019, 11, 20, 6, 20, 40);PRINTLN("g$BR>");


      DateTime d2 = d1.AddYears(5);PRINTLN("g$BR>");


      PRINTLN("Initial DateTime = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ", d1);PRINTLN("g$BR>");


      PRINTLN("New DateTime (adding years) = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ", d2);PRINTLN("g$BR>");


      int res = DateTime.Compare(d1, d2); PRINTLN(res);PRINTLN("g$BR>");


 DateTime d11 g$NEW> DateTime(2019, 11, 20, 6, 20, 40);PRINTLN("g$BR>");


      DateTime d21 g$NEW> DateTime(2019, 11, 20, 6, 20, 40);PRINTLN("g$BR>");


      PRINTLN("DateTime 1 = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ", d11);PRINTLN("g$BR>");


      PRINTLN("DateTime 2 = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ", d21);PRINTLN("g$BR>");

      int res1 = DateTime.Compare(d11, d21);

PRINTLN(res1);PRINTLN("g$BR>");PRINTLN("g$BR>");PRINTLN("g$BR>");


} '>


</OakJava7>


</OJ7ML>



dates.web

<WEB>

  

<PACK> DateTimeManipulation  

{  

    <CLASS> Program  

    {  

        public void main()  

        {  

<DATETIME> d1 <NEW> <DATETIME>(2019, 11, 20, 6, 20, 40);

      DateTime d2 = d1.AddYears(5);

      <PRINTLN>("Initial DateTime = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ", d1);

      <PRINTLN>("New DateTime (adding years) = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ", d2);

      int res = DateTime.Compare(d1, d2);

      

      <PRINTLN>(res);

 DateTime d11 <NEW> DateTime(2019, 11, 20, 6, 20, 40);

      DateTime d21 <NEW> DateTime(2019, 11, 20, 6, 20, 40);

      <PRINTLN>("DateTime 1 = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ", d11);

      <PRINTLN>("DateTime 2 = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ", d21);

      int res1 = DateTime.Compare(d11, d21);

      

      <PRINTLN>(res1);

      }  

    }  

}  

OUTPUT

 

=================================================================================================

               SAMPLE-11:JAVA7.0  Data Cleansing

=================================================================================================

What is Data Cleaning?

====================

Data cleaning is the process of preparing data for analysis by removing or modifying data 

that is incorrect, incomplete, irrelevant, duplicated, or improperly formatted. This data 

is usually not necessary or helpful when it comes to analyzing data because it may hinder 

the process or provide inaccurate results. There are several methods for cleaning data depending  on how it is stored along with the answers being sought.

Data cleaning is not simply about erasing information to make space for new data, but rather finding a way to maximize a data set’s accuracy without necessarily deleting information.

Data Cleansing

=============

Q) Write  the  Oakjava7 program  using  Oakjava7 userfriendly framework (Oj7ua)  and display all the details

in  the  webpage  using  scroll server


cleansing5.oj7ua


<OJ7ML>


<DESIGN  

SRC=' '> 

</DESIGN>

<OakJava7 Package='ML' Database='wnosql' J7Lib='{CUTIL}' Names='datacleansing,cleansing' Type='exe'  

 MAIN=' display(); ?> '


LOGIC='public static void display() {

            PRINTLN("=============================");

            PRINTLN(" Missing Values");

            CUTIL.ARRAYS a1 g$NEW> CUTIL.ARRAYS("row");


            a1.add("one");            a1.add("two");            a1.add("three");

            CUTIL.ARRAYS a11 g$NEW> CUTIL.ARRAYS("cols");


            a11.add("a"); a11.add(""); a11.add(""); 


            a11.add("b"); a11.add(""); a11.add(""); 


            a11.add("c"); a11.add(""); a11.add(""); 


            a11.add("d"); a11.add(""); a11.add(""); 


            a11.add("e"); a11.add(""); a11.add(""); 


            a11.add("f"); a11.add(""); a11.add(""); 


            a11.add("g"); a11.add(""); a11.add(""); 


            a11.add("h"); a11.add(""); a11.add(""); 


            CUTIL.ARRAYS a111 g$NEW> CUTIL.ARRAYS("randoms");


            Random random g$NEW> Random();

            for (int i = 1; i g$ 25; i++)


            {


                int r = random.Next(i);


                if ((i >= 10) &amp;&amp; (i g$= 12))


                    a111.add("NULL");


                   else


                if ((i >= 4) &amp;&amp; (i g$= 6))


                    a111.add("NULL");


                else


                if ((i >= 19) &amp;&amp; (i g$= 21))


                    a111.add("NULL");


                else


                    a111.add(r);


                


            }


            PRINTLN(" ");            PRINTLN("  "+" " + a1.ret(1) + " " + a1.ret(2) + " " + a1.ret(3));

            for (int i1 = 1; i1 g$ 25; i1++)


            {

                    Console.Write(" " + a11.ret(i1));


                Console.Write(" " + a111.ret(i1));


                if (i1 % 3 == 0)


                    PRINTLN(" ");


                                


            }


             PRINTLN("=============================");


            PRINTLN("Check for Missing Values");


            for (int i11 = 1; i11 g$ 25; i11++)


            {


               

                Console.Write(" " + a11.ret(i11));


                Console.Write(" " + a111.ret(i11).Equals("NULL"));


                if (i11 % 3 == 0)


                    PRINTLN(" ");


              


            }


            PRINTLN("=============================");            


            PRINTLN("Replace NAn  with a  Scalar Value");


            CUTIL.ArrayList ar =  new CUTIL.ArrayList(); 


            for (int i11 = 0; i11 g$ 25; i11++)


            {


                Console.Write(" " + a11.ret(i11));


                if (a111.ret(i11).Equals("NULL"))


                  ar.add(i11,"0");


                else


                  ar.add(i11, a111.ret(i11));


                if (i11 % 3 == 0)


                    PRINTLN(" ");

            }


             PRINTLN("Replace NAn  with a  Scalar Value"+ar);

             PRINTLN("=============================");

            PRINTLN("Replace NAn  with a  Missing value" );

            CUTIL.ARRAYS ar1 g$NEW> CUTIL.ARRAYS("cols");

            ar1.add("122");

            ar1.add("123");

            ar1.add("124");

            ar1.add("125");

            ar1.add("126");

            ar1.add("127");

            ar1.add("128");

            ar1.add("129");

            ar1.add("120");


            CUTIL.ArrayList ar2 g$NEW> CUTIL.ArrayList();  int c1 = 0;


            for (int i11 = 0; i11 g$ 25; i11++)


            {

                PRINTLN(" " + a11.ret(i11));

                if (a111.ret(i11).Equals("NULL"))

                {


                    c1++;

                    ar2.add(i11, ar1.ret(c1));

                }

                else

                    ar2.add(i11, a111.ret(i11));              

                if (i11 % 3 == 0)

                    PRINTLN(" ");


            }


            PRINTLN("Replace NAn  with a  Missing Value" + ar2);

            PRINTLN("=============================");



            PRINTLN("Replace Missing (or) Generic Values");

            CUTIL.ArrayList ar21 g$NEW> CUTIL.ArrayList();


            for (int i11 = 0; i11 g$ 25; i11++)


            {                


                PRINTLN("k= " + ar2.get(i11).ToString());


                if (a111.ret(i11).Equals(0))


                {

                    ar21.add(i11,"100" );

                }

                else

                    ar21.add(i11, a111.ret(i11));

                if (i11 % 3 == 0)

                    PRINTLN(" ");                


            }


PRINTLN("Replace Missing (or) Generic Values"+ar21);

PRINTLN("=============================");


}

'>

</OakJava7>

</OJ7ML>


Note:  &amp; is equivalent  to special character "&"

so in this userfriendly framework (oj7ua)  &amp is used instead of 

special character "&".

 

// Java7.0 data cleansing

cleansing.web

<WEB>

<USE> CUTIL;

<PACK> datacleansing

{

    <CLASS> Program

    {

        public void main()

        {

<PRINTLN>("=============================");

            <PRINTLN>(" Missing Values");

// add one,two,three  as  values  to  JAVA7 -CUTIL.ARRAYS 

            CUTIL.ARRAYS a1 <NEW> CUTIL.ARRAYS("row");

            a1.add("one");

            a1.add("two");

            a1.add("three");

            //a1.u1.add(1);

/*

Let  Add   this  values  in CUTIL  ARRAY like  a  matrix format using  CUTIL package.

   

  one two three

 a 0  1  2 

 b NULL  NULL  NULL 

 c 1  1  3 

 d NULL  NULL  NULL 

 e 10  13  5 

 f 2  16  8 

 g NULL  NULL  NULL 

 h 10  15  9 

*/

            CUTIL.ARRAYS a11 <NEW> CUTIL.ARRAYS("cols");

            

            a11.add("a"); a11.add(""); a11.add(""); 

            a11.add("b"); a11.add(""); a11.add(""); 

            a11.add("c"); a11.add(""); a11.add(""); 

            a11.add("d"); a11.add(""); a11.add(""); 

            a11.add("e"); a11.add(""); a11.add(""); 

            a11.add("f"); a11.add(""); a11.add(""); 

            a11.add("g"); a11.add(""); a11.add(""); 

            a11.add("h"); a11.add(""); a11.add(""); 

            CUTIL.ARRAYS a111 <NEW> CUTIL.ARRAYS("randoms");

//  declare  as  random  and  generate  random  values  using random.Next function

            Random random <NEW> Random();

            for (int i = 1; i < 25; i++)

            {

                int r = random.Next(i);

                if ((i >= 10) && (i <= 12))

                    a111.add("NULL");

else

                if ((i >= 4) && (i <= 6))

                    a111.add("NULL");

                else

                if ((i >= 19) && (i <= 21))

                    a111.add("NULL");

                else

                    a111.add(r);

                

            }

            <PRINTLN>(" ");

            <PRINTLN>("  "+" " + a1.ret(1) + " " + a1.ret(2) + " " + a1.ret(3));

            

            for (int i1 = 1; i1 < 25; i1++)

            {

               

                    Console.Write(" " + a11.ret(i1));

                Console.Write(" " + a111.ret(i1));

                if (i1 % 3 == 0)

                    <PRINTLN>(" ");

                                

            }

<PRINTLN>("=============================");

            ///Check for Missing Values

// IF  there  is  no  missing  value then  print true  otherwise  print false.

            

            <PRINTLN>("Check for Missing Values");

            for (int i11 = 1; i11 < 25; i11++)

            {

                // if (i1 == 1)

                Console.Write(" " + a11.ret(i11));

                Console.Write(" " + a111.ret(i11).Equals("NULL"));

                if (i11 % 3 == 0)

                    <PRINTLN>(" ");

                //<PRINTLN>(" "+a11.ret(i1));

            }

<PRINTLN>("=============================");

            /// Replace NAn  with a  Scalar Value  with  zeros

            

            <PRINTLN>("Replace NAn  with a  Scalar Value");

            CUTIL.ArrayList ar =  new CUTIL.ArrayList(); 

            

            for (int i11 = 0; i11 < 25; i11++)

            {

                // if (i1 == 1)

                Console.Write(" " + a11.ret(i11));

                

                if (a111.ret(i11).Equals("NULL"))

                  ar.add(i11,"0");

                else

                  ar.add(i11, a111.ret(i11));

                if (i11 % 3 == 0)

                    <PRINTLN>(" ");

            }

             <PRINTLN>("Replace NAn  with a  Scalar Value"+ar);

<PRINTLN>("=============================");

            <PRINTLN>("Replace NAn  with a  Missing value" );

// This  values added given  below in CUTIL Array ar1  to  be used  for  replacing  the  null  values present  in  given matrix array.  

            CUTIL.ARRAYS ar1 <NEW> CUTIL.ARRAYS("cols");

            ar1.add("122");

            ar1.add("123");

            ar1.add("124");

            ar1.add("125");

            ar1.add("126");

            ar1.add("127");

            ar1.add("128");

            ar1.add("129");

            ar1.add("120");

            CUTIL.ArrayList ar2 <NEW> CUTIL.ArrayList();

            int c1 = 0;

            for (int i11 = 0; i11 < 25; i11++)

            {

                // if (i1 == 1)

                Console.Write(" " + a11.ret(i11));

                if (a111.ret(i11).Equals("NULL"))

                {

                    //Console.Write(" " + a111.ret(i11));

                    c1++;

                    ar2.add(i11, ar1.ret(c1));

                }

                else

                    ar2.add(i11, a111.ret(i11));

                //Console.Write($" " + a111.ret(i11).Equals("NULL"));

                if (i11 % 3 == 0)

                    <PRINTLN>(" ");

                //<PRINTLN>(" "+a11.ret(i1));

                

            }

            <PRINTLN>("Replace NAn  with a  Missing Value" + ar2);

<PRINTLN>("=============================");

//replace  zero  value  with  100  without  changing the  matrix array  values.

    

            <PRINTLN>("Replace Missing (or) Generic Values");

            CUTIL.ArrayList ar21 <NEW> CUTIL.ArrayList();

          

            for (int i11 = 0; i11 < 25; i11++)

            {

                // if (i1 == 1)

                // Console.Write(" " + a11.ret(i11));

                <PRINTLN>("k= " + ar2.get(i11).ToString());

                //if (ar2.get(i11).Equals("0"))

                if (a111.ret(i11).Equals(0))

                {

                    //Console.Write(" " + a111.ret(i11));

                    

                    ar21.add(i11,"100" );

                }

                else

                    ar21.add(i11, a111.ret(i11));

                //Console.Write($" " + a111.ret(i11).Equals("NULL"));

                if (i11 % 3 == 0)

                    <PRINTLN>(" ");

                //<PRINTLN>(" "+a11.ret(i1));

            }

            <PRINTLN>("Replace Missing (or) Generic Values"+ar21);

<PRINTLN>("=============================");

            //a111.display();

            Console.ReadKey();

            

        }

    }

}

Note:  Here you  must  include  Java7Lib.dll  in  Java7.0 properties  file..

but  in other  programming  languages some times  it  may   fail when their  is  large amount of  data  with  more  comparision  . But in

Java7.0 datacleansing  will  also  solve the  complex problem  when  the  matrix array size  increases  with  rows and  cols  with  high  accuracy.

You  can  also   modify  it  to  be  displayed  in table  format  in

Java7.0 - Scroll web application 

  I has  given  this  logic  with  for  loop  and  you developers can  modify  in  any way. 

and  Nan indicates  null value  in  this   example

Output

=================================================================================================

SAMPLE-12: DATAWRANGLING

=================================================================================================

DATAWRANGLING

================

What  is  datawrangling in  machinelearning?

Data Wrangling is the process of converting and mapping data from its raw form to another format

 with the purpose of making it more valuable and appropriate for advance tasks 

such as Data Analytics and Machine Learning.

Q) Write  a oakjava7  program   using  Oj7ua framework , Scroll server   for   datawrangling:-


datawrangling.oj7ua

<OJ7ML>

<DESIGN  

SRC=' '> 

</DESIGN>

<OakJava7 Package='ML' Database='wnosql' J7Lib='{CUTIL}' Names='datawrangling,wrangling' Type='exe'   MAIN=' display();?>'


LOGIC=' public static void display(){


  PRINTLN("g$BR>");  PRINTLN("g$BR>");  PRINTLN("g$BR>");

PRINTLN("---------------------------------");  PRINTLN("g$BR>");  PRINTLN("g$BR>");


PRINTLN("g$body bgcolor=pink >");



PRINTLN("Merging  Data  in Java7.0 ARRAYS1 and  Java7.0 ARRAYS2 ");PRINTLN("g$BR>");


            CUTIL.ARRAYS u g$NEW>  CUTIL.ARRAYS("ID");


            u.add(1);u.add(2); u.add(3);u.add(4);u.add(5);


            CUTIL.ARRAYS u1 g$NEW> CUTIL.ARRAYS("Name");


            u1.add("wil"+1);u1.add("wil"+2);u1.add("wil"+3);u1.add("wil"+4);u1.add("wil"+5);


            CUTIL.ARRAYS u2 g$NEW> CUTIL.ARRAYS("Subject");


            u2.add("sub1" + 1); u2.add("sub1" + 2); u2.add("sub1" + 3); u2.add("sub1" + 4); u2.add("sub1" + 5);


            CUTIL.ARRAYS u11 g$NEW> CUTIL.ARRAYS("Name");


            u11.add("jemi" + 1); u11.add("jemi" + 2); u11.add("jemi" + 3);u11.add("jemi" + 4);u11.add("jemi" + 5);


            CUTIL.ARRAYS u21 g$NEW> CUTIL.ARRAYS("Subject");


            u21.add("sub1" + 5);u21.add("sub1" + 2); u21.add("sub1" + 4); u21.add("sub1" + 3);u21.add("sub1" + 1);


            PRINTLN("g$BR>");


            Console.Write(" " + u.ret(0)+" " +u1.ret(0)+" "+u2.ret(0)); PRINTLN("");PRINTLN("g$BR>");


            for (int i = 1; i g$ u.size(); i++)


            {  PRINTLN("g$BR>");


                Console.Write(" " + u.ret(i) + " " + u1.ret(i) + " " + u2.ret(i));PRINTLN("g$BR>");


                PRINTLN("");PRINTLN("g$BR>");


            }


           

            PRINTLN("g$BR>");

            Console.Write(" " + u.ret(0) + " " + u1.ret(0) + " " + u2.ret(0));PRINTLN("g$BR>");


            PRINTLN("");PRINTLN("g$BR>");


            for (int i = 1; i g$ u.size(); i++)


            {

                  PRINTLN("g$BR>");

                Console.Write(" " + u.ret(i) + " " + u11.ret(i) + " " + u21.ret(i));PRINTLN("g$BR>");


                PRINTLN("");PRINTLN("g$BR>");


            }


           PRINTLN("g$BR>");PRINTLN("g$BR>");


           PRINTLN("---------------------------------");PRINTLN("g$BR>");


            PRINTLN("Grouping data  in  Java7.0 -Arrays  and  list  the  data  based on  2014   year...  ");PRINTLN("g$BR>");


            CUTIL.ARRAYS a g$NEW> CUTIL.ARRAYS("Team");


            a.add("A"); a.add("B"); a.add("A"); a.add("A"); a.add("B"); 

             CUTIL.ARRAYS a1 g$NEW> CUTIL.ARRAYS("Rank");


            a1.add("1");a1.add("3");a1.add("2");a1.add("5"); a1.add("4");


            CUTIL.ARRAYS y g$NEW> CUTIL.ARRAYS("Year");


            y.add("2019"); y.add("2013"); y.add("2014"); y.add("2019"); y.add("2014");


            CUTIL.ARRAYS y1 g$NEW> CUTIL.ARRAYS("Score");


            y1.add(90); y1.add(50);y1.add(70); y1.add(80);y1.add(35);PRINTLN("g$BR>");


            Console.Write(" " + a.ret(0) + " " + a1.ret(0) + " " + y.ret(0) + " " + y1.ret(0));PRINTLN("g$BR>");


            PRINTLN("");PRINTLN("g$BR>"); PRINTLN("g$BR>");

          

            for (int i1=1;i1 g$ a.size();i1++)


            {



          if (y.ret(i1)==("2014"))


                {

                     PRINTLN("g$BR>");

                    Console.Write(" " + a.ret(i1) + " " + a1.ret(i1) + " " + y.ret(i1) + " " + y1.ret(i1));PRINTLN("g$BR>");


                    PRINTLN("");PRINTLN("g$BR>");


                }


            } 


PRINTLN("g$BR>");  PRINTLN("g$BR>");


PRINTLN("---------------------------------");


          

   

             PRINTLN("g$BR>");  PRINTLN("g$BR>");

            PRINTLN("Concatenating Data and  split  into  two  sections  that is  section A and  Section B using JAVA7.0 Arrays");PRINTLN("g$BR>");PRINTLN("g$BR>");


            CUTIL.ARRAYS c1 g$NEW> CUTIL.ARRAYS("12thClass");


            c1.add("SectionA");  c1.add("SectionB");


            CUTIL.ARRAYS u111 g$NEW> CUTIL.ARRAYS("ID");


            u111.add(1);u111.add(2);u111.add(3); u111.add(4);u111.add(5);


            CUTIL.ARRAYS u112 g$NEW> CUTIL.ARRAYS("Name");


            u112.add("wil" + 1); u112.add("wil" + 2); u112.add("wil" + 3);  u112.add("wil" + 4); u112.add("wil" + 5);


            CUTIL.ARRAYS u113 g$NEW> CUTIL.ARRAYS("Subject");


            u113.add("sub1" + 1); u113.add("sub1" + 2);u113.add("sub1" + 3); u113.add("sub1" + 4);u113.add("sub1" + 5);


            CUTIL.ARRAYS m g$NEW> CUTIL.ARRAYS("Marks_scored");


            m.add(35); m.add(75); m.add(95); m.add(65); m.add(50);PRINTLN("g$BR>");


            PRINTLN("" + c1.ret(0));PRINTLN("g$BR>");PRINTLN("g$BR>");


            Console.Write(" " + u111.ret(0) + " " + u112.ret(0) + " " + u113.ret(0) + " " + m.ret(0));PRINTLN("g$BR>"); PRINTLN("");


            


            for (int i3 = 1; i3 g$ u111.size(); i3++)


            {

                 PRINTLN("g$BR>");

                if (i3  == 1)

                       {

                     PRINTLN("g$BR>");

                    PRINTLN("" + c1.ret(1));PRINTLN("g$BR>");}


                if (i3==4)

                     {

                     PRINTLN("g$BR>");

                    PRINTLN(""+c1.ret(2));PRINTLN("g$BR>");}


                Console.Write(" " + u111.ret(i3) + " " + u112.ret(i3) + " " + u113.ret(i3) + " " + m.ret(i3));PRINTLN("g$BR>");


                PRINTLN("");PRINTLN("g$BR>");


            }

            }





'>




</OakJava7>


</OJ7ML>


//datawrangling in Java7.0

datawrangling.web

<WEB>

<USE> CUTIL;

<PACK> datawrangling

{

    <CLASS> Program

    {

        public void main()

        {

<PRINTLN>("---------------------------------");

<PRINTLN>("Merging  Data  in Java7.0 ARRAYS1 and  Java7.0 ARRAYS2 ");

            CUTIL.ARRAYS u <NEW>  CUTIL.ARRAYS("ID");

            u.add(1);

            u.add(2);

            u.add(3);

            u.add(4);

            u.add(5);

            CUTIL.ARRAYS u1 <NEW> CUTIL.ARRAYS("Name");

            u1.add("wil"+1);

            u1.add("wil"+2);

            u1.add("wil"+3);

            u1.add("wil"+4);

            u1.add("wil"+5);

            CUTIL.ARRAYS u2 <NEW> CUTIL.ARRAYS("Subject");

            u2.add("sub1" + 1);

            u2.add("sub1" + 2);

            u2.add("sub1" + 3);

            u2.add("sub1" + 4);

            u2.add("sub1" + 5);

            CUTIL.ARRAYS u11 <NEW> CUTIL.ARRAYS("Name");

            u11.add("jemi" + 1);

            u11.add("jemi" + 2);

            u11.add("jemi" + 3);

            u11.add("jemi" + 4);

            u11.add("jemi" + 5);

            CUTIL.ARRAYS u21 <NEW> CUTIL.ARRAYS("Subject");

            u21.add("sub1" + 5);

            u21.add("sub1" + 2);

            u21.add("sub1" + 4);

            u21.add("sub1" + 3);

            u21.add("sub1" + 1);

            //data1

            Console.Write(" " + u.ret(0)+" " +u1.ret(0)+" "+u2.ret(0));

            <PRINTLN>("");

            for (int i = 1; i < u.size(); i++)

            {

                Console.Write(" " + u.ret(i) + " " + u1.ret(i) + " " + u2.ret(i));

                <PRINTLN>("");

            }

            //data2

            Console.Write(" " + u.ret(0) + " " + u1.ret(0) + " " + u2.ret(0));

            <PRINTLN>("");

            for (int i = 1; i < u.size(); i++)

            {

                Console.Write(" " + u.ret(i) + " " + u11.ret(i) + " " + u21.ret(i));

                <PRINTLN>("");

            }

            //sample-2

<PRINTLN>("---------------------------------");

            <PRINTLN>("Grouping data  in  Java7.0 -Arrays  and  list  the  data  based on  2014   year...  ");

            CUTIL.ARRAYS a <NEW> CUTIL.ARRAYS("Team");

            a.add("A");

            a.add("B");

            a.add("A");

            a.add("A");

            a.add("B");

            CUTIL.ARRAYS a1 <NEW> CUTIL.ARRAYS("Rank");

            a1.add("1");

            a1.add("3");

            a1.add("2");

            a1.add("5");

            a1.add("4");

            CUTIL.ARRAYS y <NEW> CUTIL.ARRAYS("Year");

            y.add("2019");

            y.add("2013");

            y.add("2014");

            y.add("2019");

            y.add("2014");

            CUTIL.ARRAYS y1 <NEW> CUTIL.ARRAYS("Score");

            y1.add(90);

            y1.add(50);

            y1.add(70);

            y1.add(80);

            y1.add(35);

            Console.Write(" " + a.ret(0) + " " + a1.ret(0) + " " + y.ret(0) + " " + y1.ret(0));

            <PRINTLN>("");

            /*

            Console.Write(" " + a.ret(2) + " " + a1.ret(2) + " " + y.ret(2) + " " + y1.ret(2));

            Console.Write(" " + a.ret(4) + " " + a1.ret(4) + " " + y.ret(4) + " " + y1.ret(4));

            */

            //int i1 = 5;

            for (int i1=1;i1<a.size();i1++)

            {

//check  if  the  year  is  2014  or  not

          if (y.ret(i1)==("2014"))

                {

                    Console.Write(" " + a.ret(i1) + " " + a1.ret(i1) + " " + y.ret(i1) + " " + y1.ret(i1));

                    <PRINTLN>("");

                }

            }

<PRINTLN>("---------------------------------");

            //Concatenating Data

            // Concatenation is  nothing  but  joining  and  printing two array  matrix.

// Concatenation and  spliting is  another  kind of  Java7.0 DataWrangling for  a  given  two  array matrix.    

            <PRINTLN>("Concatenating Data and  split  into  two  sections  that is  section A and  Section B using JAVA7.0 Arrays");

            CUTIL.ARRAYS c1 <NEW> CUTIL.ARRAYS("12thClass");

            c1.add("SectionA");

            c1.add("SectionB");

            CUTIL.ARRAYS u111 <NEW> CUTIL.ARRAYS("ID");

            u111.add(1);

            u111.add(2);

            u111.add(3);

            u111.add(4);

            u111.add(5);

            CUTIL.ARRAYS u112 <NEW> CUTIL.ARRAYS("Name");

            u112.add("wil" + 1);

            u112.add("wil" + 2);

            u112.add("wil" + 3);

            u112.add("wil" + 4);

            u112.add("wil" + 5);

            CUTIL.ARRAYS u113 <NEW> CUTIL.ARRAYS("Subject");

            u113.add("sub1" + 1);

            u113.add("sub1" + 2);

            u113.add("sub1" + 3);

            u113.add("sub1" + 4);

            u113.add("sub1" + 5);

            CUTIL.ARRAYS m <NEW> CUTIL.ARRAYS("Marks_scored");

            m.add(35);

            m.add(75);

            m.add(95);

            m.add(65);

            m.add(50);

            <PRINTLN>("" + c1.ret(0));

            Console.Write(" " + u111.ret(0) + " " + u112.ret(0) + " " + u113.ret(0) + " " + m.ret(0));

            <PRINTLN>("");

            

            for (int i3 = 1; i3 < u111.size(); i3++)

            {

                if (i3  == 1)

                    <PRINTLN>("" + c1.ret(1));

                if (i3==4)

                    <PRINTLN>(""+c1.ret(2));

                Console.Write(" " + u111.ret(i3) + " " + u112.ret(i3) + " " + u113.ret(i3) + " " + m.ret(i3));

                <PRINTLN>("");

            }

            Console.ReadKey();

            

        }

    }

}

Note:  Here you  must  include  Java7Lib.dll  in  Java7.0 properties  file..

but  in other  programming  languages some times  it  may   fail when their  is  large amount of  data  with  more  comparision . But in

Java7.0 datawrangling  will  also  solve the  complex problem  when  the  matrix array size  increases  with  rows and  cols  with  high  accuracy.

Java7.0 datawrangling  uses  Java7.0 - CUTIL.ARRAYS.    

You  can  also   modify  it  to  be  displayed  in table  format  in

Java7.0 - Scroll web application 

  I has  given  this  logic  with  for  loop  and  you developers can  modify  in  any way. 

OUTPUT:

=================================================================================================

                                         SAMPLE-13 : Java7.0 CSVFileProcess

=================================================================================================

 Write  a  Java7.0 CSVFileProcess  by  passing  student object ,  add  to  arraylist

and  writetocsvfile  and  read  from  csvfile  with  a  limited  code .


CsvFileProcess1.java7

===================

<JAVA7>

<IMPORT> <J7>.io.*;

<IMPORT> <J7>.util.*;

public <CLASS> CsvFileProcess1 


<%



    //CSV file header

    private static final <J7String> FILE_HEADER = "id firstName lastName gender age,";


<MAIN>

throws Exception


<%

//call student class with object  and  pass the  parameters values

        Student student1 <NEW> Student(1, "Ahmed", "Mohamed", "M", 25);


<J7.ArrayList> <Student> ar  =  new <J7.ArrayList><Student>();


// Add  the  Student object  values  at  Map

Map<Integer,Student> ts <NEW> TreeMap<Integer,Student>();

         ts.PUT(1, new Student(2, "Sara", "Said", "F", 23));


         ts.PUT(2, new Student(3, "Ali", "Hassan", "M", 24));

         ts.PUT(3, new Student(4, "Sama", "Karim", "F", 20));

         ts.PUT(4, new Student(5, "Khaled", "Mohamed", "M", 22));

         ts.PUT(5, new Student(6, "Ghada", "Sarhan", "F", 21));


int  c=0;

// now  the ts map  value  is  assigned to  Map entry


for (Map.En<TRY><Integer, Student> ent : ts.en<TRY>Set()) 


<%


// get the  key  and  value

int k = ent.GETKey();

Student v = ent.GETValue();


// add  the  value  to  Arraylist  having student object

ar.add(c,v);


c++;

}

// now  pass  the  File_HEADER and  arraylist  value  to  writeCsvFile api and  such  data  is  written  at //file1.csv  

CsvFileProcessj7.writeCsvFile("file1.csv",ar,FILE_HEADER);

// Read  the  File1.csv  file  and  print it.

<PRINTLINE>(""+CsvFileProcessj7.readCsvFile("file1.csv"));

</JAVA7>


Note:  

======

You  had use  the  package CsvFileProcessj7  and  write  some  logic  

and  call  the  api  writeCsvFile and  ReadCsvFile...

after  that  you  must  compile  the  program  using  Java7Shell prompt.

Output:

=======


=================================================================================================

 

                                                       SAMPLE -14: Java7.0  Excel  Processing 

================================================================================================

Java7.0  Excel Data Processing

=========================

Q) Write the Oakjava7 program using Oj7UA framework to write  arraylist contents in  excel sheet using Datascience library.

Excel5.oj7ua

<OJ7ML>

<DESIGN  

SRC='  '> 

</DESIGN>

<OakJava7 Package='ML' Database='wnosql' J7Lib='{Datascience}' Names='datacleansing,cleansing' Type='exe' MAIN=' display();?> '


LOGIC=' public static void display() {


 g$OJ7UTIL>.ArrayList ar g$NEW> g$OJ7UTIL>.ArrayList();


            ar.add("wilmix1");ar.add( "wilmix2");ar.add( "wilmix3");ar.add( "wilmix4"); ar.add( "wilmix5"); ar.add( "wilmix6"); ar.add( "wilmix7");

            Datascience.Excels.call(ar, "wilmix.xls", "names", 0, 1); PRINTLN(""+Datascience.Excels.call(ar, "wilmix.xls", "names", 0, 2)); } '>


</OakJava7>

</OJ7ML>


Excel.web

==========

<WEB>

// load  Datascience  library

<USE> Datascience;

// load oakjava7 -<OJ7UTIL>  util  packages  

 <USE> <OJ7UTIL>;

<PACK> Excel

{

    <CLASS> Class1

    {

        public void main()

        {

//add  to  arraylist

          ArrayList ar <NEW> ArrayList();

            ar.add("wilmix1");

            ar.add( "wilmix2");

            ar.add( "wilmix3");

            ar.add( "wilmix4");

            ar.add( "wilmix5");

            ar.add( "wilmix6");

            ar.add( "wilmix7");

// Pass  the  Arraylist  ar  object  to  Datascience.Excels.call api and last  1  values indicates for  writing into  excel sheet. 

 

            Datascience.Excels.call(ar, "wilmix.xls", "names", 0, 1);

// Print  the  Contents  from  Wilmix.txt  to   Java7Shell prompt  console and last  2  values indicates for  Reading from  excel sheet.

            <PRINTLN>(""+Datascience.Excels.call(ar, "wilmix.xls", "names", 0, 2));

                      

        }

    }

}

Note:

======

You  Must  include  Excels.dll in Java7.0  Properties  file

Output

======

==============================================================================================

SAMPLE-15 : Java7.0 Supervised and  Unsupervised learning

==============================================================================================

Supervised learning

====================

In Supervised Learning, the dataset on which we train our model is labeled. 

There is a clear and distinct mapping of input and output. Based on the example 

inputs, the model is able to get trained in the instances. An example of supervised

 learning is spam filtering. Based on the labeled data, the model is able to determine 

if the data is spam or ham. This is an easier form of training. Spam filtering is an example of this type of machine learning algorithm.

Unsupervised Learning

=====================

In Unsupervised Learning, there is no labeled data. The algorithm identifies the patterns within the dataset and learns them. The algorithm groups the data into various clusters based on their density. Using it, one can perform visualization on high dimensional data. One example of this type of Machine learning algorithm is the Principle Component Analysis. Furthermore, K-Means Clustering is another type of Unsupervised Learning where the data is clustered in groups of a similar order.

The learning process in Unsupervised Learning is solely on the basis of finding patterns in the data. After learning the patterns, the model then makes conclusions.


A) Write  the  Oakjava7  program for  supervised and  unsupervised learning  using  Oj7ua  framework 

Learning5.oj7ua

<OJ7ML>

<DESIGN  

SRC=' '> 

</DESIGN>

<OakJava7 Package='ML' Database='wnosql' J7Lib='{}' Names=' supervisedandunsupervisedlearning,learning' Type='exe'  MAIN=' display(); ?>'

LOGIC='public static void display() {

 PRINTLN("g$br>");

g$OJ7UTIL>.ArrayList  key  g$NEW>   g$OJ7UTIL>.ArrayList();


            key.add("wooden with cap");            key.add("stick with pointer");


            g$OJ7UTIL>.ArrayList item g$NEW> g$OJ7UTIL>.ArrayList();


            item.add("pen");    item.add("pencil");


            String keys = "stick red image";        PRINTLN("g$br>");


            PRINTLN(Java7ML.unslearning.unlearningassign(key, item, keys));


            g$OJ7UTIL>.ArrayList   key1   g$NEW>   g$OJ7UTIL>.ArrayList();


            key1.add("violetandoval");      key1.add("redandcircleoval");


            g$OJ7UTIL>.ArrayList      item1    g$NEW>    g$OJ7UTIL>.ArrayList();


            item1.add("Brinjal");      item1.add("Tomato");     String keys1 = "violetandoval";      PRINTLN("g$br>");

            PRINTLN(Java7ML.slearning.learningassign(key1, item1, keys1));

              PRINTLN("g$br>"); PRINTLN("g$br>"); } '>  

 </OakJava7> 

</OJ7ML>


learning.web

<WEB>

//load java7ml packages

<USE> Java7ML;

<USE>  <OJ7UTIL>;

<PACK> ConsoleApp28

{

<CLASS> Program

    {

           public void main()

        {

            

            // supervised learning  and  unsupervised learning

            ArrayList key = new ArrayList();

            key.add("wooden with cap");

            key.add("stick with pointer");

            ArrayList item = new ArrayList();

            item.add("pen");

            item.add("pencil");

            String keys = "stick red image";

// you  notice that you may  give any keyword found in  key  arraylist will  display  output as pencil for unlearning. 

            <PRINTLN>(Java7ML.unslearning.unlearningassign(key, item, keys));

            ArrayList key1 = new ArrayList();

            key1.add("violetandoval");

            key1.add("redandcircleoval");

            ArrayList item1 = new ArrayList();

            item1.add("Brinjal");

            item1.add("Tomato");

            String keys1 = "violetandoval";

// you  notice  that  you  must  give  the  exact  value  violet and  oval  that  will  display output as  brinjal for learning.

            <PRINTLN>(Java7ML.slearning.learningassign(key1, item1, keys1));

            Console.ReadKey();

 

        }

    }

}

Note:

======

You  must  include  Java7Ml.dll  in Java7.0 properties file..

Output:

=======

=============================================================================================

                                                     SAMPLE-16 :CHISQUARE - Statistic

=============================================================================================


What  is  Chi-Square  (χ2) statistic ?

=============================

A chi-square (χ2) statistic is a test that measures how a model compares to actual observed data. 

Chi-square tests are often used in hypothesis testing. 


Draw  a graph  for  temperature for cities, use  oakjava7 program in this case.

Use  Oj7UA framework  to  display  it  in  webpage.


ChiSquare5.oj7ua


<OJ7ML>

<DESIGN  

SRC='   '> 

</DESIGN>

<OakJava7 Package='ML' Database='wnosql' J7Lib='{}' Names='Chisquaregraph,Chisquaretest' Type='exe'  MAIN=' display();  ?> '


LOGIC='   public static void display(){

            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);

 g$OJ7UTIL>.ArrayList observedvalue1 = new  g$OJ7UTIL>.ArrayList();

             g$OJ7UTIL>.ArrayList expectedvalue1 = new  g$OJ7UTIL>.ArrayList();

            observedvalue1.add(95);observedvalue1.add(25);expectedvalue1.add(85);expectedvalue1.add(35);

 double chi1 = Java7ML.ChiSquare.chisquaretest(observedvalue1, expectedvalue1);

            double chi = Java7ML.ChiSquare.chisquaretest(observedvalue, expectedvalue);

 g$OJ7UTIL>.ArrayList chis = new  g$OJ7UTIL>.ArrayList();

chis.add("["+"l$0l$");chis.add(chi);chis.add(chi1+"]");chis.add("["+"l$1l$");chis.add(0.02092);chis.add(0.04460+"]");

String display=Oj7ui.OJ7ML.Oj7Html("chisquare1.html",chis.ToString(),"chisquare2.html"); PRINTLN(display); }  '>


</OakJava7>


</OJ7ML>


Chisquareweb.web

=================


<WEB>


<USE> Java7ML;


<USE> <OJ7UTIL>;




<PACK> ConsoleApp28


{


<CLASS> Programchisquare


    {


           public void main()


        {



         


            //chisquare test


            ArrayList observedvalue = new ArrayList();


            ArrayList expectedvalue = new ArrayList();


            observedvalue.add(85);


            observedvalue.add(15);


            expectedvalue.add(75);


            expectedvalue.add(25);


ArrayList observedvalue1 = new ArrayList();


            ArrayList expectedvalue1 = new ArrayList();


            observedvalue1.add(95);


            observedvalue1.add(25);


            expectedvalue1.add(85);


            expectedvalue1.add(35);


 double chi1 = Java7ML.ChiSquare.chisquaretest(observedvalue1, expectedvalue1);



            double chi = Java7ML.ChiSquare.chisquaretest(observedvalue, expectedvalue);


           HTML.displayhtml("chisquare1.html");

ArrayList chis = new ArrayList();


chis.add("["+"'0'");


chis.add(chi);


chis.add(chi1+"]");


chis.add("["+"'1'");


chis.add(0.02092);


chis.add(0.04460+"]");



       <PRINTLN>(""+chis.ToString());       

               

       

HTML.displayhtml("chisquare2.html");

 


        }


    }


}


Note: use  Java7ML.dll,HTML.dll  in  properties.txt  file.



chisquare1.html

================


<html>


   <head>


      <title>CHI Square </title>


      <script type = "text/javascript" src = "https://www.gstatic.com/charts/loader.js"></script>


      <script type = "text/javascript">


         google.charts.load('current', {packages: ['corechart','line']});  


      </script>


   </head>

   

   <body>


      <div id = "container" style = "width: 550px; height: 400px; margin: 0 auto">


      </div>


      <script language = "JavaScript">


         function drawChart() {


           

            var data = new google.visualization.DataTable();


            data.addColumn('string', 'Value');


            data.addColumn('number', 'Tokyo');


            data.addColumn('number', 'New York');


         

            data.addRows(




chisquare2.html

================


);

            

            

            var options = {'title' : 'Average Temperatures of Cities',


               hAxis: {


                  title: 'X^2 Values'


               },


               vAxis: {


                  title: 'P-value-frequency'


               }, 

  

               'width':550,


               'height':400,


               curveType: 'function'


            };


            

            var chart = new google.visualization.LineChart(document.getElementById('container'));


            chart.draw(data, options);


         }


         google.charts.setOnLoadCallback(drawChart);


      </script>


   </body>


</html>



OUTPUT



=============================================================================================


                                            SAMPLE-17 :Polynomial Regression - Machine Learning


=============================================================================================


What  is  Polynomial Regression ?


Polynomial Regression is a regression algorithm that models the relationship between a dependent(y) 

and independent variable(x) as nth degree polynomial. 


Explanation

===========

The Polynomial Regression equation is given below:


y= b0+b1x1+ b2x1^2+ b2x1^3+...... bnx1^n


For  polynomial  regression  use the  method which is given below


Polynomialreg(int a , int b,int x, String  list, int pow)


eg)  let  us  consider  an  example  


y= ax +b  is  a  linear regression example


Now  compare  the method  Polynomialreg(...)

having  params a,b,x  which  indicates y=ax+b  when pow value =1.

When the  pow value is 3 in this  example

the   equation  is  automatically  formed as

  y=  a1 x^3 + a2 x^2 + ax +b

   

where  a1,a2 ,a are  coefficiant of the equation.

so list indicates coefficiant a1,a2.

now  consider  the  given below  method


 y = Java7Mathexp.Java7Mathfx.Polynomialreg(-58 , 285,(3+c),sval, 3);

which  will form  the polynomial equation  which is given below..

y= 2x^3+ 3x^2 -58x +285

and  we  can find Y for many X  values and  we  can  plot  the Polynomial regression 

graph  for the  given  x and y  values...



Write  a  oakjava7  program  for plotting the  Polynomial regression graph for  given  x (Elephant Age)  and  y (Weight) values  which  we  get  from   the  polynomial equation...


Polynomial25.oj7ua

<OJ7ML>


<DESIGN  


SRC='    '> 


</DESIGN>

<OakJava7 Package='ML' Database='wnosql' J7Lib='{}' Names='PolyReg1,Polynomial' Type='exe'   MAIN=' display(); ?> '

LOGIC='public static void display() {


  double y=0.0;

CUTIL.ArrayList lvalue = new CUTIL.ArrayList();

lvalue.add(0,"[l$Elephant Agel$");lvalue.add(1,"l$Weightl$]");

String  sval= "3,2";int c=0;

 for (int i = 2; i g$ 20; i += 2)

            {

                lvalue.add(i, "["+(3+c));

                y = Java7Mathexp.Java7Mathfx.Polynomialreg(-58 , 285,(3+c),sval, 3);

                lvalue.add(i+1, y+"]");  c++;            }

String  display=Oj7ui.OJ7ML.Oj7Html("polynomialtrendlines1.html",lvalue.ToString(),"

polynomialtrendlines2.html");

PRINTLN(display);

} '>

</OakJava7>

</OJ7ML>



Polynomial2.web

==============


<WEB>


<USE> CUTIL;

<USE> format; // load  format package for J7Html


<USE> Java7Mathexp;


<PACK> polynomialexp

{

    <CLASS> roots

    {

       public void main()

        {

            double y=0.0;



J7HTML.displayhtml("polynomialtrendlines1.html");



CUTIL.ArrayList lvalue = new CUTIL.ArrayList();

lvalue.add(0,"['Elephant Age'");

lvalue.add(1,"'Weight']");


// 2 coefficiant for  polynomial equation

String  sval= "3,2";


int c=0;

 for (int i = 2; i < 20; i += 2)

            {



                //add  x value

                lvalue.add(i, "["+(3+c));

             

                 // automatically  form  the  equation for given x  and  y values.

                y = Java7Mathexp.Java7Mathfx.Polynomialreg(-58 , 285,(3+c),sval, 3);

                // add  y value

                lvalue.add(i+1, y+"]");


                

               c++;

             


               

            }


            <PRINTLN>("" + lvalue);




J7HTML.displayhtml("polynomialtrendlines2.html");


 


 




}



}


}


Note: Include J7HTML.dll,Java7Mathfx.dll  in properties.txt file..



polynomialtrendlines1.html

=========================


<html>

 <head>

   <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>

   <script type="text/javascript">

     google.charts.load("current", {packages:["corechart"]});

     google.charts.setOnLoadCallback(drawChart);

     function drawChart() {

       var data = google.visualization.arrayToDataTable(





polynomialtrendlines2.html

========================


);


       var options = {

         title: 'Elephant Age vs. Weight comparison',

         legend: 'none',

         crosshair: { trigger: 'both', orientation: 'both' },

         trendlines: {

           0: {

             type: 'polynomial',

             degree: 3,

             visibleInLegend: true,

           }

         }

       };


       var chart = new google.visualization.ScatterChart(document.getElementById('polynomial2_div'));

       chart.draw(data, options);

     }

   </script>

 </head>

 <body>

  <div id='polynomial2_div' style='width: 900px; height: 500px;'></div>

 </body>

</html>


OUTPUT

=======


==============================================================================================

                                     SAMPLE-18 :Logistic Regression in Machine Learning

==============================================================================================


Definition of the logistic function

=====================================


An explanation of logistic regression can begin with an explanation of the standard logistic function. The logistic function is a sigmoid function, 

which takes any real input t, and outputs a value between zero and one. For the logit, this is interpreted as taking input log-odds and 

having output probability. 



Let us assume that t is a linear function of a single explanatory variable x (the case where t is a linear combination of multiple explanatory variables


 is treated similarly). We can then express t as follows:


t= Beta-0  +Beta-1 *  x


And the general logistic function  p:R->(0,1) can now be written as:


p(x) = alpha(t) =  1/ 1+ e ^ (-(Beta-0  +Beta-1 *  x))


In the logistic model, p(x) is interpreted as the probability of the dependent variable Y 

equaling a success/case rather than a failure/non-case.



Write  a  oakjava7  program  for plotting the  Logistic Regression graph for  given  x (Elephant Age)  and  y (Weight) values  which  we  get  from   the  Logistic Regression using Oj7ua framework.

Logisticreggraph.oj7ua

<OJ7ML>

<DESIGN  

SRC=' '> 

</DESIGN>

<OakJava7 Package='ML' Database='wnosql' J7Lib='{CUTIL}' Names='datacleansing,cleansing' Type='exe'  MAIN=' display();?>'

LOGIC='public static void display(){

double y=0.0;double p=0.0;

CUTIL.ArrayList lvalue = new CUTIL.ArrayList();

lvalue.add(0,"[l$Elephant Agel$");lvalue.add(1,"l$Weightl$]");

 for (int i = 2; i g$ 20; i += 2)      { 

lvalue.add(i, "["+2*(i+1));

 y = Java7Mathexp.Java7Mathfx.linearfx(1*i, (1+i), 2*(i+1));

   p=Java7Mathexp.Java7Mathfx.Logisticreg(y); lvalue.add(i+1, p+"]"); }

String display=Oj7ui.OJ7ML.Oj7Html("polynomialtrendlines1.html",lvalue.ToString(),"polynomialtrendlines2.html"); PRINTLN(display);

}  '>

</OakJava7>

</OJ7ML>


logisticreg.web

=============


<WEB>


<USE> CUTIL;

<USE> format;


<USE> Java7Mathexp;


<PACK> linearexp

{

    <CLASS> roots

    {

       public void main()

        {

        


            double y=0.0;


double p=0.0;

J7HTML.displayhtml("polynomialtrendlines1.html");

CUTIL.ArrayList lvalue = new CUTIL.ArrayList();

lvalue.add(0,"['Elephant Age'");

lvalue.add(1,"'Weight']");

 for (int i = 2; i < 20; i += 2)

            {


  lvalue.add(i, "["+2*(i+1));

//call  the linear regression  function

 y = Java7Mathexp.Java7Mathfx.linearfx(1*i, (1+i), 2*(i+1));

// submit  the  y  values to  logistic  regression  api

                p=Java7Mathexp.Java7Mathfx.Logisticreg(y);

                lvalue.add(i+1, p+"]");

              

            }


            <PRINTLN>("" + lvalue);


J7HTML.displayhtml("polynomialtrendlines2.html");


 


}



}


}


Note: Include J7HTML.dll,Java7Mathfx.dll  in properties.txt file..


polynomialtrendlines1.html

=========================


<html>


 <head>


   <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>


   <script type="text/javascript">


     google.charts.load("current", {packages:["corechart"]});


     google.charts.setOnLoadCallback(drawChart);


     function drawChart() {


       var data = google.visualization.arrayToDataTable(



polynomialtrendlines2.html

========================




);




       var options = {


         title: 'Elephant Age vs. Weight comparison',


         legend: 'none',


         crosshair: { trigger: 'both', orientation: 'both' },


         trendlines: {


           0: {


             type: 'polynomial',


             degree: 3,


             visibleInLegend: true,


           }


         }


       };




       var chart = new google.visualization.ScatterChart(document.getElementById('polynomial2_div'));


       chart.draw(data, options);


     }


   </script>


 </head>


 <body>


  <div id='polynomial2_div' style='width: 900px; height: 500px;'></div>


 </body>


</html>


Output

==============================================================================================

                                         SAMPLE-19 :Multiple Regression in Machine Learning


==============================================================================================


What  is multiple regression?



Multiple regression is a statistical technique that can be used to analyze the relationship between a single dependent variable 

and several independent variables. The objective of multiple regression analysis is to use the independent variables whose values

 are known to predict the value of the single dependent value.


The  Equation  for multiple regression is 


y=b0+b1x1+b2x2+b3x3 +......+bnxn


where


Y= Output/Response variable


b0, b1, b2, b3 , bn....= Coefficients of the model.


x1, x2, x3, x4,...= Various Independent/feature variable



Write  a  oakjava7  program  for plotting the  Multiple Regression graph for  given  x (Plant Age)  and  y (Plant Status) values  which  we  get  from   the  Multiple Regression api  using  OJ7UA framework.

<OJ7ML>

<DESIGN  SRC=' '> 

</DESIGN>

<OakJava7 Package='ML' Database='wnosql' J7Lib='{CUTIL}' Names='datacleansing,cleansing' Type='exe'  MAIN='display(); ?> '

LOGIC=' public static void display() {

 double y=0.0;

CUTIL.ArrayList lvalue = new CUTIL.ArrayList();

String  sval= "3,2";String xval ="3,2";

int c=0;

 for (int i = 0; i g$ 20; i += 2) {

                lvalue.add(i, "["+(3+c));            

                y = Java7Mathexp.Java7Mathfx.Multiplelinearreg(-58 , 285,(3+c),xval, sval, 3);

                lvalue.add(i+1, y+"]"); c++; }

          String display=Oj7ui.OJ7ML.Oj7Html("splitpoints1.html",lvalue.ToString(),"splitpoints2.html"); PRINTLN(display);

}'>

</OakJava7>

</OJ7ML>


Note: Status of  a plant means growth,reproduction,pollination, seed spreading stages,death stages.



multiplereg.web

===============


<WEB>


<USE> CUTIL;

<USE> format;


<USE> Java7Mathexp;


<PACK> linearexp

{

    <CLASS> roots

    {

       public void main()

        {

         


 

 


            double y=0.0;



J7HTML.displayhtml("splitpoints1.html");



CUTIL.ArrayList lvalue = new CUTIL.ArrayList();





String  sval= "3,2";


String xval ="3,2";


int c=0;

 for (int i = 0; i < 20; i += 2)

            {



                

                lvalue.add(i, "["+(3+c));

             


                y = Java7Mathexp.Java7Mathfx.Multiplelinearreg(-58 , 285,(3+c),xval, sval, 3);


               


                lvalue.add(i+1, y+"]");


                

               c++;

             


               

            }


            <PRINTLN>("" + lvalue);




J7HTML.displayhtml("splitpoints2.html");



}



}


}



Note: Include J7HTML.dll,Java7Mathfx.dll  in properties.txt file..



splitpoints1.html

=================


<html>

  <head>

    <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>

    <script type="text/javascript">


  google.charts.load("current", {packages:["corechart"]});

      google.charts.setOnLoadCallback(drawChart);


      function drawChart() {

        var data = new google.visualization.DataTable();

       data.addColumn('number', 'Plant Age');

      data.addColumn('number', 'Plant Status');

     

      data.addRows(




splitpoints2.html

=================


);

        


        var options = {


title: 'Age of a plant  vs Status of  a plant',

    hAxis: {title: 'Age of a Plant'},

    vAxis: {title: 'Status of a Plant'},

          legend: 'none',


colors: [ 'blue', 'red', 'green', 'yellow', 'gray'],

trendlines: { 0: {},1:{} } ,

          crosshair: { trigger: 'both' } 

        };



var chart = new google.visualization.ScatterChart(document.getElementById('chart_div'));

        chart.draw(data, options);

        var chart1 = new google.visualization.LineChart(document.getElementById('linechart_div'));

        chart1.draw(data, options); 


      }

    </script>

  </head>

  <body>

    <div id="chart_div" style="width: 900px; height: 500px;"></div>

  <div id="linechart_div" style="width: 900px; height: 500px;"></div>

  </body>

</html>


OUTPUT


=============================================================================================


                   SAMPLE-20 :K-Nearest Neighbor(KNN) Algorithm - Machine Learning


=============================================================================================



How does K-NN work?

===================


The K-NN working can be explained on the basis of the below algorithm:


Step-1: Select the number K of the neighbors

Step-2: Calculate the Euclidean distance of K number of neighbors

Step-3: Take the K nearest neighbors as per the calculated Euclidean distance.

Step-4: Among these k neighbors, count the number of the data points in each category.

Step-5: Assign the new data points to that category for which the number of the neighbor is maximum.

Step-6: Our model is ready.


Firstly, we will choose the number of neighbors, so we will choose the k=5.

Next, we will calculate the Euclidean distance between the data points. 

The Euclidean distance is the distance between two points, which we have already studied in geometry.

 It can be calculated as:

Euclidean distance  between  A1 and B2 = Squareroot of  ((x2-x1) ^ 2 + (y2-y1) ^ 2).

By calculating the Euclidean distance we got the nearest neighbors.



How to select the value of K in the K-NN Algorithm?

================================================


There is no particular way to determine the best value for "K", so we need to try some values to find the best out of them.

 The most preferred value for K is 5.A very low value for K such as K=1 or K=2, can be noisy and lead to the effects of outliers 

in the model. Large values for K are good, but it may find some difficulties.


Advantages of KNN Algorithm:

============================

It is simple to implement.

It is robust to the noisy training data

It can be more effective if the training data is large.

Disadvantages of KNN Algorithm:

==============================

Always needs to determine the value of K which may be complex some time.

The computation cost is high because of calculating the distance between the data points for all the training samples.


Write   a  Oakjava7  program to find  the  unknown  train  is belong to  set electric trains 

or  normal trains set. Given  the  datasets  are 



SETA Train Dataset

=================


String dataset="[1,2,3,4,5,6,7,8,9,10]";

String dataset2="[11,51,61,31,71,81,91,251,101,131]";


Unknown train 

==============

String dataset1="[12]";


String dataset3="[111]";



SETB  trains Dataset

=================


String datasetB="[10,9,8,7,6,5,4,3,2,1]";String dataset2B="[21,52,65,35,77,88,99,255,130,101]";

Unknown train coordinates="12,111"

Use  OakJava7- Knn Algorithm in this case. with  userfriendly framework oj7ua.


Knnalgo2.oj7ua

<OJ7ML>

<DESIGN  SRC='  '> </DESIGN>

<OakJava7 Package='wil' Database='wnosql' J7Lib='{AdvancedJava7ML,format}' Names='knnalgo,roots' Type='exe'   MAIN=' display(); ?>'

LOGIC=' public static void display() {

String dataset="[1,2,3,4,5,6,7,8,9,10]";

String dataset1="[12]";

String dataset2="[11,51,61,31,71,81,91,251,101,131]";

String dataset3="[111]";

String datasetB="[10,9,8,7,6,5,4,3,2,1]";String dataset2B="[21,52,65,35,77,88,99,255,130,101]";

String newpoint="12,111";

String outputdata= KNNAlgo.KNNProces(dataset,dataset1,dataset2,dataset3,datasetB,dataset2B,newpoint,5,4);

String display=Oj7ui.OJ7ML.Oj7Html("knnalgo1.html",outputdata,"knnalgo2.html");

PRINTLN(display);

}'>

</OakJava7>

</OJ7ML>


Knnalgo.web

============


<WEB>


// load advanced Java7 machine learning package

<USE> AdvancedJava7ML;


<USE> format;

<PACK> knnalgo

{

    <CLASS> roots

    {

       public void main()

        {

         


 

 


J7HTML.displayhtml("knnalgo1.html");



String dataset="[1,2,3,4,5,6,7,8,9,10]";


String dataset1="[12]";


String dataset2="[11,51,61,31,71,81,91,251,101,131]";


String dataset3="[111]";




String datasetB="[10,9,8,7,6,5,4,3,2,1]";String dataset2B="[21,52,65,35,77,88,99,255,130,101]";


String newpoint="12,111";


// pass  the   dataset  and  unknown trains co-ordinates


String outputdata= KNNAlgo.KNNProces(dataset,dataset1,dataset2,dataset3,datasetB,dataset2B,newpoint,5,4);



// print the Trains setA and  SetB distances.


            <PRINTLN>("" + outputdata);

J7HTML.displayhtml("knnalgo2.html");

}

}

}



Note:-

====== 


Use J7HTML.dll,AdvancedMLJava7.dll  in  the  Java7 properties file.




Output:

=============


==============================================================================================


                                  SAMPLE-21:Naïve Bayes Classifier Algorithm - Type 1


==============================================================================================


Naïve Bayes Classifier Algorithm

==============================

Naïve Bayes algorithm is a supervised learning algorithm, which is based on Bayes theorem and used for solving classification problems.

It is mainly used in text classification that includes a high-dimensional training dataset.

Naïve Bayes Classifier is one of the simple and most effective Classification algorithms which helps in building

 the fast machine learning models that can make quick predictions.

It is a probabilistic classifier, which means it predicts on the basis of the probability of an object.

Some popular examples of Naïve Bayes Algorithm are spam filtration, Sentimental analysis, and classifying articles.



Bayes' Theorem:

===============

Bayes' theorem is also known as Bayes' Rule or Bayes' law, which is used to determine the probability of a hypothesis with prior knowledge.

 It depends on the conditional probability.

The formula for Bayes' theorem is given as:


P(A|B) = P(B|A)  * P(A) / P(B)




P(A|B) is Posterior probability: Probability of hypothesis A on the observed event B.


P(B|A) is Likelihood probability: Probability of the evidence given that the probability of a hypothesis is true.


P(A) is Prior Probability: Probability of hypothesis before observing the evidence.


P(B) is Marginal Probability: Probability of Evidence.



Advantages of Naïve Bayes Classifier:

===============================

Naïve Bayes is one of the fast and easy ML algorithms to predict a class of datasets.

It can be used for Binary as well as Multi-class Classifications.

It performs well in Multi-class predictions as compared to the other Algorithms.

It is the most popular choice for text classification problems.


Disadvantages of Naïve Bayes Classifier:

==================================

Naive Bayes assumes that all features are independent or unrelated, so it cannot learn the relationship between features.


Applications of Naïve Bayes Classifier:

======================================

It is used for Credit Scoring.

It is used in medical data classification.

It can be used in real-time predictions because Naïve Bayes Classifier is an eager learner.

It is used in Text classification such as Spam filtering and Sentiment analysis.





Given below the  datasets find  whether  player can  able play the  game or not?

Use OakJava7 in this case. and  use  Oj7ua userfriendly framework.

  

  outlook= "[Rainy,sunny,overcast,overcast,sunny,rainy,sunny,overcast,rainy,sunny,sunny,rainy,overcast,overcast]"

 Play="[yes,yes,yes,yes,no,yes,yes,yes,no,no,yes,no,yes,yes]"

 features="[yes,no,sunny]";

Naivepart5.web

<OJ7ML>

<DESIGN  SRC=' '>  </DESIGN>

<OakJava7 Package='ML' Database='wnosql' J7Lib='{AdvancedJava7ML}' Names='Naivepart1,Naivegraph' Type='exe'  MAIN=' display(); ?>'


LOGIC=' public static void display(){

 String outlook= "[Rainy,sunny,overcast,overcast,sunny,rainy,sunny,overcast,rainy,sunny,sunny,rainy,overcast,overcast]";


String Play="[yes,yes,yes,yes,no,yes,yes,yes,no,no,yes,no,yes,yes]";

String features="[yes,no,sunny]";

double a=NaiveBayes.NaviBayesprocessType1(outlook,Play,features);


features="[no,yes,sunny]";


double  b=NaiveBayes.NaviBayesprocessType1(outlook,Play,features);


if  (a>b)

PRINTLN("Hence on a Sunny day, Player can play the game.");

} '>


</OakJava7>

</OJ7ML>


Naivepart1.web

==============



<WEB>



<USE> AdvancedJava7ML;

<USE> format;

<PACK> Naivepart1

{

    <CLASS> roots

    {

       public void main()

        {

         


 String outlook= "[Rainy,sunny,overcast,overcast,sunny,rainy,sunny,overcast,rainy,sunny,sunny,rainy,overcast,overcast]";


String Play="[yes,yes,yes,yes,no,yes,yes,yes,no,no,yes,no,yes,yes]";



String features="[yes,no,sunny]";


double a=NaiveBayes.NaviBayesprocessType1(outlook,Play,features);




features="[no,yes,sunny]";



double  b=NaiveBayes.NaviBayesprocessType1(outlook,Play,features);



if  (a>b)


<PRINTLN>("Hence on a Sunny day, Player can play the game.");

}



}


}



Explanation



Given  the  dataset


  outlook= "[Rainy,sunny,overcast,overcast,sunny,rainy,sunny,overcast,rainy,sunny,sunny,rainy,overcast,overcast]";


 Play="[yes,yes,yes,yes,no,yes,yes,yes,no,no,yes,no,yes,yes]";



 features="[yes,no,sunny]";


call  the NaviBayesprocessType1 method and  passing 


outlook,Play,features as parameters in the method..


 NaiveBayes.NaviBayesprocessType1(outlook,Play,features)


you will  get  the value for P(Yes|Sunny).


Now change  the  features values as


features="[no,yes,sunny]" you will get


the value  for P(NO|Sunny).


Note:-

====== 

Use J7HTML.dll,AdvancedMLJava7.dll  in  the  Java7 properties file.


OUTPUT


Hence on a Sunny day, Player can play the game.

==============================================================================================

                                       SAMPLE-22:Naïve Bayes Classifier Algorithm - Type 2

==============================================================================================


NavieBayesType-1  is followed  only  when there is  only  one  feature.

If there  are  more  features present  then  

X= x1, x2,x3 .... xn

Here x1,x2….xn represent the features, i.e they can be mapped to Color, Type, and Origin.

 By substituting for X and expanding using the chain rule we get,


P(y| x1,x2..xn) =  (p(x1|y) * p(xn|y) *p(y)) / (p(x1)* p(x2) ... p(xn))


                   

Consider the car theft problem with attributes Color, Type, Origin, and the target, Stolen can be either Yes or No.


To find the probability of  YES with respect to  X ,  whose dataset  is given below..


for  color the given dataset is


 color="[red,red,red,yellow,yellow,yellow,yellow,yellow,red,red]";


 stolen="[yes,no,yes,no,yes,no,yes,no,no,yes]";


features=[yes,no,red]


for Type  the  given  dataset  is


type="[sports,sports,sports,sports,sports,SUV,SUV,SUV,SUV,sports]";


features="[yes,no,SUV]";


 stolen="[yes,no,yes,no,yes,no,yes,no,no,yes]";


for  Target  the given dataset is


Target="[domestic,domestic,domestic,domestic,imported,imported,imported,domestic,imported,imported]";


features="[yes,no,domestic]";


==================================


To find the probability of  NO with respect to  X ,  whose dataset  is given below..


for  color the given dataset is


 color="[red,red,red,yellow,yellow,yellow,yellow,yellow,red,red]";


 stolen="[yes,no,yes,no,yes,no,yes,no,no,yes]";


features=[no,yes,red]


for Type  the  given  dataset  is


type="[sports,sports,sports,sports,sports,SUV,SUV,SUV,SUV,sports]";


features="[no,yes,SUV]";


 stolen="[yes,no,yes,no,yes,no,yes,no,no,yes]";


for  Target  the given dataset is


Target="[domestic,domestic,domestic,domestic,imported,imported,imported,domestic,imported,imported]";


features="[no,yes,domestic]";


Use OakJava7 program  with  Oj7UA  userfriendly framework  in this  case.



Naivepart52.oj7ua

<OJ7ML>


<DESIGN  SRC=' '>  </DESIGN>



<OakJava7 Package='ML' Database='wnosql' J7Lib='{AdvancedJava7ML}' Names='Naivepart1,Naivegraph' Type='exe'  MAIN=' display(); ?>'


LOGIC=' public static void display(){

 String outlook= "[Rainy,sunny,overcast,overcast,sunny,rainy,sunny,overcast,rainy,sunny,sunny,rainy,overcast,overcast]";

String Play="[yes,yes,yes,yes,no,yes,yes,yes,no,no,yes,no,yes,yes]";

String features="[yes,no,sunny]";

double a=NaiveBayes.NaviBayesprocessType1(outlook,Play,features);

features="[no,yes,sunny]";

double  b=NaiveBayes.NaviBayesprocessType1(outlook,Play,features);


if  (a>b)

PRINTLN("Hence on a Sunny day, Player can play the game.");

} '>

</OakJava7>

</OJ7ML>


Naviebayest2.web

===================

<WEB>

<USE> AdvancedJava7ML;

<USE> format;

<PACK> Naivepart2

{

    <CLASS> roots

    {

       public void main()

        {

         


String outlook="[red,red,red,yellow,yellow,yellow,yellow,yellow,red,red]";


String Play="[yes,no,yes,no,yes,no,yes,no,no,yes]";


String  features="[yes,no,red]";


double c=NaiveBayes.NaviBayesprocessType2(outlook,Play,features);




outlook="[sports,sports,sports,sports,sports,SUV,SUV,SUV,SUV,sports]";


features="[yes,no,SUV]";


double c1=NaiveBayes.NaviBayesprocessType2(outlook,Play,features);



outlook="[domestic,domestic,domestic,domestic,imported,imported,imported,domestic,imported,imported]";


features="[yes,no,domestic]";


double c11=NaiveBayes.NaviBayesprocessType2(outlook,Play,features);


features="[yes,no,yes]";


double c1111=NaiveBayes.NaviBayesprocessType2(Play,Play,features) ;

double result = c *c1 *c11 * c1111;

<PRINTLN>("P(yes|X)="+result);


outlook="[red,red,red,yellow,yellow,yellow,yellow,yellow,red,red]";


Play="[yes,no,yes,no,yes,no,yes,no,no,yes]";


features="[no,yes,red]";


double c2=NaiveBayes.NaviBayesprocessType2(outlook,Play,features) ;


outlook="[sports,sports,sports,sports,sports,SUV,SUV,SUV,SUV,sports]";


features="[no,yes,SUV]";


double c12=NaiveBayes.NaviBayesprocessType2(outlook,Play,features);


outlook="[domestic,domestic,domestic,domestic,imported,imported,imported,domestic,imported,imported]";


features="[no,yes,domestic]";


double c111=NaiveBayes.NaviBayesprocessType2(outlook,Play,features) ;



features="[no,yes,no]";


double c1112=NaiveBayes.NaviBayesprocessType2(Play,Play,features) ;



double result1 = c2 *c12 *c111 *c1112;

<PRINTLN>("P(NO|X)="+result1);




if  (result1 >result)


<PRINTLN>("Since 0.144 > 0.048, Which means given the features RED SUV and Domestic, our example gets <CLASS>ified as ’NO’ the car is not stolen.");

 



}



}


}



Explanation

============


Now call  the NaviBayesprocessType2 method and  pass

outlook,Play,features as parameters in the method..

 NaiveBayes.NaviBayesprocessType2(outlook,Play,features)

you will  get  the value for P(red|yes),P(SUV|yes),P(domestic|yes),P(yes).

for getting  the  value of  P(yes) feature dataset  should  be features="[yes,no,yes]".

and statement result = c *c1 *c11 * c1111; means

P(yes|X) =P(red|yes)*P(SUV|yes)*P(domestic|yes) *P(yes)


Now change  the  features values as

features=[no,yes,red],features=[no,yes,SUV], features=[no,yes,domestic],

for getting  the  value of  P(No) feature dataset  should  be  features=[no,yes,no].

 You will get the value  for P(NO|X)  when

the statement result1 = c2 *c12 *c111 *c1112; means

P(no|X) =P(red|no)*P(SUV|no)*P(domestic|no) *P(no).



Note:-

====== 

Use J7HTML.dll,AdvancedMLJava7.dll  in  the  Java7 properties file.



Output

========

P(yes|X)=0.048

P(NO|X)=0.144

Since 0.144 > 0.048, Which means given the features RED SUV and Domestic, our example gets classified as 'NO' the car is not stolen.


==============================================================================================

                                    Sample 23: Gaussian Naïve Bayes Classifier


==============================================================================================


Gaussian Naïve Bayes Classifier: 

===================================


In Gaussian Naïve Bayes, continuous values associated with each feature 

are assumed to be distributed according to a Gaussian distribution (Normal distribution).

 When plotted, it gives a bell-shaped curve.



Given below the  dataset  for  NavieBayesclassifier


arr = { 86, 96,80, 65, 70, 80, 70,90,75 }


 arr1 = { 85,90,70,95,91}


find  the  mean and  standard deviation  for  that  

given dataset and  plot  the  NavieBayes-Gausian curve  for mean 

and  standard  deviation for given X value from 0  to 1.0.

use  OakJava7    program   in this  case  and use  OJ7UA  framework  in this case.


NaiveGausian.oj7ua

<OJ7ML>


<DESIGN  SRC=' '> </DESIGN>



<OakJava7 Package='ML' Database='wnosql' J7Lib='{AdvancedJava7ML,format}' Names='NaiveGausan,Naivegraph' Type='exe'  MAIN=' display(); ?> '


LOGIC=' public static void display() {


J7HTML.displayhtml("normaldistrib1.html");

double x=0;

double  xu=0;

double sigma=0;

  double [] arr = { 86, 96,80, 65, 70, 80, 70,90,75 };

            int n1 = arr.Length;

int[] values = {86, 96,80, 65, 70, 80, 70,90,75  };

            xu = Java7ML.MeanMedianMode.Mean(values,n1);

sigma=Java7ML.stdvariance.standardDeviation(arr, n1-1);


for (double i = -74; i g$ 1.0; i += 0.1) 



{

x=74+i;

double gausian=NaiveBayes.Gausianprocess(x, xu, sigma);


            PRINTLN("arr.g$PUSH>(" + gausian+");");


}


 double [] arr1 = { 85,90,70,95,91};


            int n11 = arr1.Length;


int[] values1 = {85,90,70,95,91  };


            xu = Java7ML.MeanMedianMode.Mean(values1,n11);

sigma=Java7ML.stdvariance.standardDeviation(arr1, n11-1);

for (double i = -74; i g$ 1.0; i += 0.1) 

{

x=74+i;

double gausian1=NaiveBayes.Gausianprocess(x, xu, sigma);

 PRINTLN("arr.g$PUSH>(" + gausian1+");");

}

J7HTML.displayhtml("normaldistrib2.html");

}

'>


</OakJava7>

</OJ7ML>


Note: Here we  can't use  Oj7ui.OJ7ML.Oj7Html because

it  accept only  3 parameters ie) filename1.html",outputdata,"filename2.html"

Here two data(eg. outputdata1,outputdata2) should be used.So this condition failed 

so we use J7HTML.displayhtml and two data proceed after J7HTML statement

and finally we use J7HTML.displayhtml.


navieGausian.web

===================


<WEB>

<USE> Java7ML;

<USE> AdvancedJava7ML;

<USE> format;

<PACK> Gausian

{

    <CLASS> roots

    {

       public void main()

        {

         


 

 


J7HTML.displayhtml("normaldistrib1.html");



double x=0;

double  xu=0;

double sigma=0;


  double [] arr = { 86, 96,80, 65, 70, 80, 70,90,75 };


            int n1 = arr.Length;




int[] values = {86, 96,80, 65, 70, 80, 70,90,75  };


            // calculate median


            xu = Java7ML.MeanMedianMode.Mean(values,n1);


         



sigma=Java7ML.stdvariance.standardDeviation(arr, n1-1);


       

for (double i = -74; i < 1.0; i += 0.1) 


{

x=74+i;

double gausian=NaiveBayes.Gausianprocess(x, xu, sigma);




            <PRINTLN>("arr.<PUSH>(" + gausian+");");


}




 double [] arr1 = { 85,90,70,95,91};


            int n11 = arr1.Length;




int[] values1 = {85,90,70,95,91  };


            // calculate median


            xu = Java7ML.MeanMedianMode.Mean(values1,n11);


         


       


sigma=Java7ML.stdvariance.standardDeviation(arr1, n11-1);


       

for (double i = -74; i < 1.0; i += 0.1) 


{

x=74+i;

double gausian1=NaiveBayes.Gausianprocess(x, xu, sigma);


 <PRINTLN>("arr.<PUSH>(" + gausian1+");");


}


J7HTML.displayhtml("normaldistrib2.html");


 


 




}



}


}




Explanation

==============


Pass  the  X(x) , Mean(xu) ,Standard deviation(sigma)  to

method NaiveBayes.Gausianprocess(x, xu, sigma) we will get the NavieBayes-Gausian value.

For given  X=  0  to  1.0 we  can plot  the  NavieBayes-Gausian curve

using statement arr.<PUSH>(" + gausian+").


Note:

Use J7HTML.dll,AdvancedMLJava7.dll,Java7ML.dll  in  the  Java7 properties file. 



Output




==============================================================================================

                                                                 Sample 24: Decision  Tree  in Oakjava7

==============================================================================================


What  is Decision Tree?

=======================


Decision Tree is a Supervised learning technique that can be used for both classification and Regression problems, but mostly it is preferred for solving Classification problems. It is a tree-structured classifier, where internal nodes represent the features of a dataset, branches represent the decision rules and each leaf node represents the outcome.

In a Decision tree, there are two nodes, which are the Decision Node and Leaf Node. Decision nodes are used to make any decision and have multiple branches, whereas Leaf nodes are the output of those decisions and do not contain any further branches.

The decisions or the test are performed on the basis of features of the given dataset.

It is a graphical representation for getting all the possible solutions to a problem/decision based on given conditions.

It is called a decision tree because, similar to a tree, it starts with the root node, which expands on further branches  and constructs a tree-like structure.A decision tree simply asks a question, and based on the answer (Yes/No), it further  split the tree into subtrees.



Why we use Decision Trees?

==========================

There are various algorithms in Machine learning, so choosing the best algorithm for the given dataset and problem is the main point to remember while creating a machine learning model. Below are the two reasons for using the Decision tree:

Decision Trees usually mimic human thinking ability while making a decision, so it is easy to understand.           The logic behind the decision tree can be easily understood because it shows a tree-like structure.


Decision Tree Terminologies

============================


Root Node: Root node is from where the decision tree starts. It represents the entire dataset, which further gets divided into two or more homogeneous sets.

Leaf Node: Leaf nodes are the final output node, and the tree cannot be segregated further after getting a leaf node.

Splitting: Splitting is the process of dividing the decision node/root node into sub-nodes according to the given conditions.

Branch/Sub Tree: A tree formed by splitting the tree.

Pruning: Pruning is the process of removing the unwanted branches from the tree.

Parent/Child node: The root node of the tree is called the parent node, and other nodes are called the child nodes.



How does the Decision Tree algorithm Work?

===========================================


In a decision tree, for predicting the class of the given dataset, the algorithm starts from the root node of the tree. 

This algorithm compares the values of root attribute with the record (real dataset) attribute and, based on the comparison, 

follows the branch and jumps to the next node.

For the next node, the algorithm again compares the attribute value with the other sub-nodes and move further. 

It continues the process until it reaches the leaf node of the tree.

The complete process can be better understood using the below algorithm: 

Step-1: Begin the tree with the root node, says S, which contains the complete dataset.

Step-2: Find the best attribute in the dataset using Attribute Selection Measure (ASM).

Step-3: Divide the S into subsets that contains possible values for the best attributes.

Step-4: Generate the decision tree node, which contains the best attribute.

Step-5: Recursively make new decision trees using the subsets of the dataset created in step -3. 

Continue this process until a stage is reached where you cannot further classify the nodes and called the final node as a leaf node.



Attribute Selection Measures

=============================


While implementing a Decision tree, the main issue arises that how to select the best attribute for the root node and for sub-nodes. 

So, to solve such problems there is a technique which is called as Attribute selection measure or ASM. By this measurement, we can easily 

select the best attribute for the nodes of the tree. There are two popular techniques for ASM, which are:


1) Information Gain

2) Gini Index


1. Information Gain:

   =================

Information gain is the measurement of changes in entropy after the segmentation of a dataset based on an attribute.

It calculates how much information a feature provides us about a class.

According to the value of information gain, we split the node and build the decision tree.

A decision tree algorithm always tries to maximize the value of information gain, and a node/attribute having the highest information gain is split first. It can be calculated using the below formula:

Information Gain= Entropy(S)- [(Weighted Avg) *Entropy(each feature)  


Entropy: Entropy is a metric to measure the impurity in a given attribute. It specifies randomness in data. Entropy can be calculated as:



Entropy(s)= -P(yes)log2 P(yes)- P(no) log2 P(no)

Where,

S= Total number of samples

P(yes)= probability of yes

P(no)= probability of no


Note: Here we don't  use  Gini Index..



Advantages of the Decision Tree

================================


It is simple to understand as it follows the same process which a human follow while making any decision in real-life.

It can be very useful for solving decision-related problems.

It helps to think about all the possible outcomes for a problem.

There is less requirement of data cleaning compared to other algorithms.


Disadvantages of the Decision Tree

==================================

The decision tree contains lots of layers, which makes it complex.

It may have an overfitting issue, which can be resolved using the Random Forest algorithm.

For more class labels, the computational complexity of the decision tree may increase.



Question:Consider a  CSV file  contains  information  about  employee with fields 

cno , NAME,Condition,class. We  must  select  a  proper employee

who  accepts the offer and the Condition?

Note: In this  Example Use Oakjava7 program  with  OJ7UA user friendly  framework to construct

  Decision Tree for that. and  use  scrollserver  to display the proper employee   

details in  Decision Tree  diagram  format.

DecisionTree5.oj7ua

<OJ7ML>

<DESIGN  SRC=' '>   </DESIGN>

<OakJava7 Package='ML' Database='wnosql' J7Lib='{}' Names='DecisionTree,Treegraph' Type='exe'  MAIN=' display(); ?> '

LOGIC=' public static void display(){ J7DecisionTree.call("treegraph.properties"); }'>

</OakJava7>

</OJ7ML>



wgraph1.web

===========


<WEB>



<PACK> Taskss

{

<CLASS> Graph

    {

           public void main()

        {

            



    J7DecisionTree.call("treegraph.properties");


 

        }

    }

}



Explanation

This J7DecisionTree.call  method  

will search that  properties file  and

display  it  in a Tree format  in  webapplication.ie)

it  will  filter  according  to  columnname (condition) you has  given.

we must include  Java7AdvancedML.dll  in  oakjava7  properties.txt file.

In this example HR  will  select the  employees -Interview candidates with cno 120 and give offer to him.

Put employee with cno 206 on hold.and  reject  employee with cno 210.

In Oakjava7 we had to write only one line and call  the method J7DecisionTree.call.

So it is  easy  to focus.


treegraph.properties


csvfile = chooseemp

columnname = class


Note: we must  give  the  csvfile  and

which  columnname  you want  to validate  it

in  treegraph.properties file.


Input

Here   we  give   chooseemp.csv  file   as   Input.



OUTPUT


==============================================================================================

                                                                                                              

                                     Sample 25: Random Forest  in Oakjava7


==============================================================================================



Random Forest Algorithm

========================

Random Forest is a popular machine learning algorithm that belongs to the supervised learning technique. 

It can be used for both Classification and Regression problems in ML. It is based on the concept of ensemble learning, 

which is a process of combining multiple classifiers to solve a complex problem and to improve the performance of the model.

As the name suggests, "Random Forest is a classifier that contains a number of decision trees on various subsets of the given dataset and takes the average to improve the predictive accuracy of that dataset." Instead of relying on one decision tree, the random forest takes the prediction from each tree and based on the majority votes of predictions, and it predicts the final output.

The greater number of trees in the forest leads to higher accuracy and prevents the problem of overfitting.


Why use Random Forest?

======================


Below are some points that explain why we should use the Random Forest algorithm:

It takes less training time as compared to other algorithms.

It predicts output with high accuracy, even for the large dataset it runs efficiently.

It can also maintain accuracy when a large proportion of data is missing.



Applications of Random Forest

=============================


There are mainly four sectors where Random forest mostly used:

Banking: Banking sector mostly uses this algorithm for the identification of loan risk.

Medicine: With the help of this algorithm, disease trends and risks of the disease can be identified.

Land Use: We can identify the areas of similar land use by this algorithm.

Marketing: Marketing trends can be identified using this algorithm.


Advantages of Random Forest

============================

Random Forest is capable of performing both Classification and Regression tasks.

It is capable of handling large datasets with high dimensionality.

It enhances the accuracy of the model and prevents the overfitting issue.


Disadvantages of Random Forest

==============================

Although random forest can be used for both classification and regression tasks, it is not more suitable for Regression tasks.


Example : Consider the  weather  forecast example where  members from Meteorological Department 

submit  a report. and  that  data is  entered to 3 csv files. Find the Decision Tree

which  has  many votes. and it is shared to cricket team

but the  cricket team likes only normal temperature.

Write a OakJava7 Program to find that Decision Tree  which  has

many votes  and  assign a  new data point ("Not Able to Play the cricket") to  the

final Decision Tree. Here use  Oakjava7 User friendly framework(OJ7UA).


RFTREE5.oj7ua


<OJ7ML>

<DESIGN  SRC=' '> </DESIGN>

<OakJava7 Package='ML' Database='wnosql' J7Lib='{}' Names='RFTreesample,RandomForest1' Type='exe'  MAIN=' display(); ?> '

LOGIC=' public static void display() {

String rdataset= "treegraph.properties,treegraph.properties,treegraph.properties,treegraph1.properties,treegraph1.properties,treegraph1.properties,treegraph1.properties,treegraph1.properties,treegraph2.properties,treegraph2.properties,treegraph2.properties,treegraph2.properties";

String newdataset="Not Able to Play the cricket";

RandomForest.call(rdataset,newdataset);

}'>

</OakJava7>

</OJ7ML>


RFTree.web

==========


<WEB>



<PACK> Taskss

{

<CLASS> Graph

    {

           public void main()

        {    

// Mention  all the properties  files  you  are  using in rdataset.

//datasets

String rdataset= "treegraph.properties,treegraph.properties,treegraph.properties,treegraph1.properties,treegraph1.properties,treegraph1.properties,treegraph1.properties,treegraph2.properties,treegraph2.properties,treegraph2.properties,treegraph2.properties,treegraph2.properties";


// Mention the new data "Not Able to Play the cricket" to be used in Final decision tree.

String newdataset="Not Able to Play the cricket";


// This  will choose the  correct Decision Tree.And it Insert a  new data at final Tree data selection (Output).

RandomForest.call(rdataset,newdataset);



 

        }

    }

}



Explanation

===========

This RandomForest.call  method  

will search that  properties file  and

display  it  in a Tree format  in  webapplication for  the  given datasets.ie)

it  will  filter  according  to  columnname (condition) you has  given.

we must include  Java7AdvancedML.dll  in  oakjava7  properties.txt file.

In this example Administrator will  filter the data  given by 

his co-workers. By Analysing this  Tree Graph Administrator  will say

that the  humidity  is normal, windy is high.It has sunny temperature with cool

and no mild sometimes.But when the temperature is hot in other day, there is no windy and it is normal

and has mild and no hot sometimes in other day. So Cricket team can't play Cricket game.Since Cricket team from  other  country will  not play in other country since  they likes only Normal temperature. 

In Oakjava7 we had to write only two line and call  the method RandomForest.call.

So it is  easy  to focus.

treegraph.properties

==================

csvfile = test2

columnname =class


We have  used  test2.csv file in properties file


treegraph1.properties

====================

csvfile = test3

columnname =class



We have  used  test3.csv file  in properties file


treegraph2.properties

====================

csvfile = test31

columnname =class



We have  used  test31.csv file  in properties file


Input


test2.csv

=========

outlook,temperature,humidity,windy,class

sunny,hot,high,FALSE,no

sunny,hot,high,TRUE,no

overcast,hot,high,FALSE,yes

rainy,mild,high,FALSE,yes

rainy,cool,normal,FALSE,yes

rainy,cool,normal,TRUE,no

overcast,cool,normal,TRUE,yes

sunny,mild,high,FALSE,no

sunny,cool,normal,FALSE,yes

rainy,mild,normal,FALSE,yes

sunny,mild,normal,TRUE,yes

overcast,mild,high,TRUE,yes

overcast,hot,normal,FALSE,yes

rainy,mild,high,TRUE,no


test3.csv

=========

outlook,temperature,humidity,windy,class

sunny,hot,high,FALSE,yes

sunny,hot,high,TRUE,no

overcast,hot,high,FALSE,no

rainy,mild,high,FALSE,yes

rainy,cool,normal,FALSE,no

rainy,cool,normal,TRUE,yes

overcast,cool,normal,TRUE,yes

sunny,mild,high,FALSE,no

sunny,cool,normal,FALSE,yes

rainy,mild,normal,FALSE,no

sunny,mild,normal,TRUE,no

overcast,mild,high,TRUE,yes

overcast,hot,normal,FALSE,yes

rainy,mild,high,TRUE,yes


test31.csv

==========

outlook,temperature,humidity,windy,class

sunny,hot,high,FALSE,no

sunny,hot,high,TRUE,yes

overcast,hot,high,FALSE,yes

rainy,mild,high,FALSE,yes

rainy,cool,normal,FALSE,yes

rainy,cool,normal,TRUE,no

overcast,cool,normal,TRUE,yes

sunny,mild,high,FALSE,no

sunny,cool,normal,FALSE,yes

rainy,mild,normal,FALSE,yes

sunny,mild,normal,TRUE,yes

overcast,mild,high,TRUE,yes

overcast,hot,normal,FALSE,yes


Output


==============================================================================================

              

                                     Sample 26: Hierarchical clustering  in Oakjava7


==============================================================================================



What  is  hierarchical clustering?


Hierarchical clustering is another unsupervised machine learning algorithm, which is used to group the unlabeled datasets

 into a cluster and also known as hierarchical cluster analysis or HCA.

In this algorithm, we develop the hierarchy of clusters in the form of a tree, and this tree-shaped structure 

is known as the dendrogram.


Why hierarchical clustering?

we have seen in the K-means clustering that there are some challenges with this algorithm, which are a predetermined number of clusters, and it always tries to create the clusters of the same size. To solve these two challenges, we can opt for the hierarchical clustering algorithm because, in this algorithm, we don't need to have knowledge about the predefined number of clusters.



Write  a  Oakjava7  program and  use  OJ7UA framework   for creating a  Denendrogram  for  the  given  distance values and the cluster names:-

 String str="LO1, LO2, LO3, LO4, LO5, LO6 "; where str indicates string type clusternames

String data="2| 1| 9| 6| 11| 13, 1| 0| 3| 3| 10| 10, 9| 4| 0| 6| 2| 8 ,7| 3| 6| 0| 6| 13 , 14| 8| 2| 5| 0| 10 ,15| 10| 8| 16| 12| 0 ";

is  the   TripleArray of  string.

dendrogram.oj7ua

<OJ7ML>


<DESIGN  SRC=' '> </DESIGN>

<OakJava7 Package='ML' Database='wnosql' J7Lib='{AdvancedJava7ML}' Names='Naivepart1,Naivegraph' Type='exe'  MAIN=' display(); ?> '


LOGIC='public static void display(){

 g$TRY>  {


      String str="LO1, LO2, LO3, LO4, LO5, LO6 ";

String data="2| 1| 9| 6| 11| 13, 1| 0| 3| 3| 10| 10, 9| 4| 0| 6| 2| 8 ,7| 3| 6| 0| 6| 13 , 14| 8| 2| 5| 0| 10 ,15| 10| 8| 16| 12| 0 ";


HTML.displayhtml("cluster1.html");


 Dendrogram.process(str,data,6,6);


HTML.displayhtml("cluster2.html");

      }

      g$CATCH> (Exception e)

      {

        PRINTLN("Error.... "+e);

      }  


}'>

</OakJava7>

</OJ7ML>

Note :Here  Dendrogram.process method  is not  a return type. But it print  the data 

in webpage. So  this  method is  consuming the data but  it did not return any value.

So  here in this  case  we  use  HTML.displayhtml.


dendrogram.web

================


<WEB>

<PACK> dendrogram


{

<CLASS> Program


  {

           public void main()


        {



 <TRY>


      {


      String str="LO1, LO2, LO3, LO4, LO5, LO6 ";

String data="2| 1| 9| 6| 11| 13, 1| 0| 3| 3| 10| 10, 9| 4| 0| 6| 2| 8 ,7| 3| 6| 0| 6| 13 , 14| 8| 2| 5| 0| 10 ,15| 10| 8| 16| 12| 0 ";

HTML.displayhtml("cluster1.html");

Dendrogram.process(str,data,6,6);

HTML.displayhtml("cluster2.html");


      }


      <CATCH> (Exception e)


      {


        <PRINTLN>("Error.... "+e);


      }  

    }

        }


    }



Explanation

===========


This Dendrogram.process method is used to create  a dendogram and 

str indicates string type clusternames and data  indicates distances 

and the first 6 indicates rows ,second 6 indicates columns.


Dendrogram process  Syntax  is  given below

Dendrogram.process(String str,String data,int rows,int cols )


Note : We must  use  Java7Clustering.dll,HTML.dll   in  oakjava7  properties.txt file.

Note: 

The String with  Special  Character  | and data  used   in  string str (2| 1| 9| 6| 11| 13, 1| 0| 3| 3| 10| 10, 9| 4| 0| 6| 2| 8 ,7| 3| 6| 0| 6| 13 , 14| 8| 2| 5| 0| 10 ,15| 10| 8| 16| 12| 0 ")

  is  called  as  TripleArray of  string seperated by comma in  OakJava7. 


Output



==============================================================================================


                                                         Sample 27: K-Means clustering  in Oakjava7 


==============================================================================================


What is K-Means Algorithm?


K-Means Clustering is an Unsupervised Learning algorithm, which groups the unlabeled dataset into different clusters. 

Here K defines the number of pre-defined clusters that need to be created in the process, as if K=2, there will be two clusters, and for K=3, there will be three clusters, and so on.

The main aim of this algorithm is to minimize the sum of distances between the data point 

and their corresponding clusters.


Write  a  OakJava7 program  to find the Fertility rate vs life expectancy in selected countries (2021) which  is India,u.k,America for animals like Dog,Cat,Cow,Goat.Create  a  seperate  clusters for this given countries, here use  OJ7UA framework .


KmeansClustering5.oj7ua

<OJ7ML>

<DESIGN  SRC=' '>  </DESIGN>

<OakJava7 Package='ML' Database='wnosql' J7Lib='{AdvancedJava7ML}' Names='Kmeanscluster,kmeansgraph' Type='exe'  MAIN=' display(); ?>'

LOGIC=' public static void display(){

 g$TRY> {

HTML.displayhtml("kmeanchart1.html");

String label="india,u.k,america";

KMeansclustering.process("sample",0, 1,2,3,label);

HTML.displayhtml("kmeanchart2.html");

      }

      g$CATCH> (Exception e)

      {

        PRINTLN("Error.... "+e);

      }  

} '>

</OakJava7>

</OJ7ML>


Note: Here also  KMeansclustering.process method  consumes the  data  and  print the data  in  google browser or  any  other browser.


kclustering.java7

<JAVA>


<PACK> kclustering


{



<CLASS> Program


  {


           public void main()


        {


          


 <TRY>


      {

HTML.displayhtml("kmeanchart1.html");

String label="india,u.k,america";



    KMeansclustering.process("sample",0, 1,2,3,label);



HTML.displayhtml("kmeanchart2.html");


      }


      <CATCH> (Exception e)


      {


        <PRINTLN>("Error.... "+e);


      }  


    }


        }


    }



Explanation 



The Given below method 


KMeansclustering.process("sample",0, 1,2,3,label); 


indicates  sample is the  name  of  the csv file.

and  0,1 values in this method indicates that Xattribute and Yattribute respectively.

2 value  in this  method  indicates  iterations and 3 value in this method indicates clusters 

for  india,u.k,america to be  created.Label String  indicates this clusters labels for

india,u.k,america to be  created.


By reading the output  we can  say Life expectancy in India for animals like Dog,Cat,Cow,Goat

is less when compared to  U.K,America. But Life expectancy in u.k for animals like Dog,Cat,Cow,Goat

is medium.Life expectancy in America for animals like Dog,Cat,Cow,Goat is high.



Note : You must include KMeansclustering.dll,HTML.dll in oakjava7 properties file.


The sample.csv  contains..


sample.csv

1,3

2,4

1,2

3,4

1,2

2,2

2,1

10,12

14,11

12,14

16,13

1,1

4,4

10,11

15,13

13,12

4,1

4,3

4,5

Output


==============================================================================================

                                        Sample 28: Apriori algortithm  in Oakjava7

==============================================================================================


What  is  Apriori algortithm?

The Apriori algorithm uses frequent itemsets to generate association rules, and

 it is designed to work on the databases that contain transactions.

 With the help of these association rule, it determines how strongly or how weakly two objects are connected. 

This algorithm uses a breadth-first search and Hash Tree to calculate the itemset associations efficiently. 

It is the iterative process for finding the frequent itemsets from the large dataset.

This algorithm was given by the R. Agrawal and Srikant in the year 1994.

 It is mainly used for market basket analysis and helps to find those products that can be bought together. 

It can also be used in the healthcare field to find drug reactions for patients.

Advantages of Apriori Algorithm

Disadvantages of Apriori Algorithm


Example :

Suppose we have the following dataset that has various transactions, 

and   from this dataset, we need to find the frequent animals and  birds set and generate the association rules using the Apriori algorithm. use Oakjava7 program with OJ7UA framework in this case to  find it?

Input  is  the  arraylist format which is given below..


ArrayList ar <NEW> ArrayList();

ar.add("3");

ar.add("dog,cat,crow,sparrow");

ar.add("dog,cat,crow");

ar.add("dog,cat");

ar.add("dog,tiger");

ar.add("cow,cat,crow,sparrow");

ar.add("cow,cat,crow");

ar.add("cow,cat");

ar.add("cow,tiger");


First line in Input ArrayList format is numeric and which is the Minimum Value.

and in second line ,etc we add  the  animals and  birds names.


Apriorialgo5.oj7ua

<OJ7ML>

<DESIGN  SRC=' '> </DESIGN>


<OakJava7 Package='ML' Database='wnosql' J7Lib='{AdvancedJava7ML}' Names='Naivepart1,Naivegraph' Type='exe'   MAIN=' display(); ?>'


LOGIC=' public static void display() {


 g$TRY>



      {



g$OJ7UTIL>.ArrayList ar g$NEW> g$OJ7UTIL>.ArrayList();


ar.add("3"); ar.add("dog,cat,crow,sparrow");ar.add("dog,cat,crow");


ar.add("dog,cat");ar.add("dog,tiger");ar.add("cow,cat,crow,sparrow");

ar.add("cow,cat,crow");ar.add("cow,cat");ar.add("cow,tiger");

Apriorialgorithim.process(ar);

      }

      g$CATCH> (Exception e)

      {

        PRINTLN("Error.... "+e);

      }  

}'>

</OakJava7>

</OJ7ML>


j7algo.java7


<JAVA>

//load  Oakjava7 - <OJ7UTIL> util package 

<USE>  <OJ7UTIL>;

<PACK> j7algorithim


{

<CLASS> Program


  {


           public void main()


        {


 <TRY>


      {


ArrayList ar <NEW> ArrayList();

ar.add("3");

ar.add("dog,cat,crow,sparrow");

ar.add("dog,cat,crow");


ar.add("dog,cat");

ar.add("dog,tiger");

ar.add("cow,cat,crow,sparrow");

ar.add("cow,cat,crow");

ar.add("cow,cat");

ar.add("cow,tiger");


Apriorialgorithim.process(ar);


      }


      <CATCH> (Exception e)


      {


        <PRINTLN>("Error.... "+e);


      }  



    }


        }


    }


Explanation 

Given below  method indicates that

Apriorialgorithim.process(ar)


we  are passing the  input in  arraylist format in the given process method.

The Output given below list the frequent animals and  birds set.

Note: Use Apriorialgorithim.dll in OakJava7 properties file.

Output 

==============================================================================================

Note:  This   is the  end  of  MachineLearning  with   OakJava7  for  Version 1. 

=======================================================================================