楼主: xdfhz
318 5

Java for Data Science [推广有奖]

副教授

57%

还不是VIP/贵宾

-

TA的文库  其他...

xdfhz

New Scientist

威望
0
论坛币
6750 个
学术水平
19 点
热心指数
244 点
信用等级
17 点
经验
26182 点
帖子
488
精华
0
在线时间
171 小时
注册时间
2017-10-19
最后登录
2018-11-7

xdfhz 发表于 2018-6-25 12:21:05 |显示全部楼层
Java_for_Data_Science.pdf (8.85 MB, 售价: 12 个论坛币)
51uuSN2S-LL.jpg

Java for Data Science: Explore, Analyse and Visualise Data Effectively Using Java Tools and Techniques

Harness the incredible power of Java-based approaches to data science and create new, innovative applications to explore, visualise and analyse big data. With its tutorial approach and step-by-step instructional style, Java for Data Science is the ultimate data science book for Java developers interested in Java-based data science solutions.

Summary

Get the lowdown on Java and explore big data analytics with Java for Data Science. Packed with examples and data science principles, this book uncovers the techniques & Java tools supporting data science and machine learning.

About the Technology

The stability and power of Java combines with key data science concepts for effective exploration of data. By working with Java APIs and techniques, this data science book allows you to build applications and use analysis techniques centred on machine learning.

About the Book

Java for Data Science gives you the understanding you need to examine the techniques and Java tools supporting big data analytics. These Java-based approaches allow you to tackle data mining and statistical analysis in detail. Deep learning and Java data mining are also featured, so you can explore and analyse data effectively, and build intelligent applications using machine learning.

What’s Inside

  • Understand data science principles with Java support
  • Discover machine learning and deep learning essentials
  • Explore data science problems with Java-based solutions

About the Reader

With its tutorial approach, this data science book has been written for experienced Java programmers who want to better understand the field of data science and learn how Java supports its underlying techniques. The step-by-step instructional style also makes Java for Data Science ideal for beginners, allowing you to get up and running quickly.

About the Author

Richard M. Reese has worked in software development supervision & training for 17 years, and currently teaches at Tarleton State University. He has written several Java books on topics including certification, natural language processing, functional programming, and networks.

Jennifer L. Reese currently teaches Computer Science to high school students, having studied Computer Science and earned her M.Ed. from Tarleton in December 2016.

Table of Contents

  • Getting Started with Data Science
  • Data Acquisition
  • Data Cleaning
  • Data Visualization
  • Statistical Data Analysis Techniques
  • Machine Learning
  • Neural Networks
  • Deep Learning
  • Text Analysis
  • Visual and Audio Analysis
  • Mathematical and Parallel Techniques for Data Analysis
  • Bringing It All Together


本帖被以下文库推荐

Nicolle 学生认证  发表于 2018-9-23 11:14:51 |显示全部楼层
  1. package packt.knnexamples;

  2. import java.io.FileReader;
  3. import static java.lang.System.out;
  4. import weka.classifiers.lazy.IBk;
  5. import weka.classifiers.Evaluation;
  6. import weka.core.Instance;
  7. import weka.core.Instances;
  8. import weka.core.SerializationHelper;

  9. public class KNNExample {

  10.     public KNNExample() {
  11.         // dermatology.arff
  12.         // Training set is first 80% - ends with line 456 of orginal set
  13.         // Testing set is last 20% - Starts with line 457 of original set (lines 457-530)
  14.         String trainingFileName = "dermatologyTrainingSet.arff";
  15.         String testingFileName = "dermatologyTestingSet.arff";

  16.         try (FileReader trainingReader = new FileReader(trainingFileName);
  17.                 FileReader testingReader = new FileReader(testingFileName)) {
  18.             Instances trainingInstances = new Instances(trainingReader);
  19.             trainingInstances.setClassIndex(trainingInstances.numAttributes() - 1);

  20.             Instances testingInstances = new Instances(testingReader);
  21.             testingInstances.setClassIndex(testingInstances.numAttributes() - 1);

  22.             IBk ibk = new IBk();
  23.             ibk.buildClassifier(trainingInstances);
  24.             SerializationHelper.write("knnModel", ibk);
  25.             ibk = null;
  26.             ibk = (IBk) SerializationHelper.read("knnModel");

  27.             // Evaluate
  28.             Evaluation evaluation = new Evaluation(trainingInstances);
  29.             evaluation.evaluateModel(ibk, testingInstances);
  30.             System.out.println(evaluation.toSummaryString());

  31.             // Predict
  32.             for (int i = 0; i < testingInstances.numInstances(); i++) {
  33.                 double result = ibk.classifyInstance(testingInstances.instance(i));
  34.                 // Use for incorrect results
  35.                 if (result != testingInstances
  36.                         .instance(i)
  37.                         .value(testingInstances.numAttributes() - 1)) {
  38.                     out.println("Classify result: " + result
  39.                             + " Correct: " + testingInstances.instance(i)
  40.                             .value(testingInstances.numAttributes() - 1));
  41.                     Instance incorrectInstance = testingInstances.instance(i);
  42.                     incorrectInstance.setDataset(trainingInstances);
  43.                     double[] distribution = ibk.distributionForInstance(incorrectInstance);
  44.                     out.println("Probability of being positive: " + distribution[0]);
  45.                     out.println("Probability of being negative: " + distribution[1]);
  46.                 }
  47.             }
  48.         } catch (Exception ex) {
  49.             ex.printStackTrace();
  50.         }
  51.     }

  52.     public static void main(String[] args) {
  53.         new KNNExample();
  54.     }
  55. }
复制代码
回复

使用道具 举报

Nicolle 学生认证  发表于 2018-9-23 11:15:43 |显示全部楼层
  1. package packt.wekanueralnetworkexamples;

  2. import java.io.FileReader;
  3. import static java.lang.System.out;
  4. import weka.classifiers.Evaluation;
  5. import weka.classifiers.functions.MultilayerPerceptron;
  6. import weka.core.Instance;
  7. import weka.core.Instances;
  8. import weka.core.SerializationHelper;

  9. /*
  10.     <dependencies>
  11.         <!-- https://mvnrepository.com/artifact/nz.ac.waikato.cms.weka/weka-dev -->
  12.         <dependency>
  13.             <groupId>nz.ac.waikato.cms.weka</groupId>
  14.             <artifactId>weka-dev</artifactId>
  15.             <version>3.7.5</version>
  16.         </dependency>
  17.     </dependencies>
  18. */
  19. public class MultilayerPerceptronExample {
  20.    
  21.     public MultilayerPerceptronExample() {
  22.         // dermatology.arff
  23.         // Training set is first 80% - ends with line 456 of orginal set
  24.         // Testing set is last 20% - Starts with line 457 of original set (lines 457-530)
  25.         String trainingFileName = "dermatologyTrainingSet.arff";
  26.         String testingFileName = "dermatologyTestingSet.arff";

  27.         try (FileReader trainingReader = new FileReader(trainingFileName);
  28.                 FileReader testingReader = new FileReader(testingFileName)) {
  29.             Instances trainingInstances = new Instances(trainingReader);
  30.             trainingInstances.setClassIndex(trainingInstances.numAttributes() - 1);

  31.             Instances testingInstances = new Instances(testingReader);
  32.             testingInstances.setClassIndex(testingInstances.numAttributes() - 1);

  33.             MultilayerPerceptron mlp = new MultilayerPerceptron();
  34.             mlp.setLearningRate(0.1);
  35.             mlp.setMomentum(0.2);
  36.             mlp.setTrainingTime(2000);
  37.             mlp.setHiddenLayers("3");
  38.             mlp.buildClassifier(trainingInstances);
  39.             SerializationHelper.write("mlpModel", mlp);
  40.             out.println(mlp.getTrainingTime());
  41.             mlp = (MultilayerPerceptron)SerializationHelper.read("mlpModel");


  42.             // Evaluate
  43.             System.out.println("Starting evaluation");
  44.             Evaluation evaluation = new Evaluation(trainingInstances);
  45.             evaluation.evaluateModel(mlp, testingInstances);
  46.             System.out.println(evaluation.toSummaryString());

  47.             // Predict
  48.             System.out.println("Starting Predicting");
  49.             for (int i = 0; i < testingInstances.numInstances(); i++) {
  50.                 double result = mlp.classifyInstance(testingInstances.instance(i));
  51.                 // Use for incorrect results
  52.                 if (result != testingInstances
  53.                         .instance(i)
  54.                         .value(testingInstances.numAttributes() - 1)) {
  55.                     out.println("Classify result: " + result
  56.                             + " Correct: " + testingInstances.instance(i)
  57.                             .value(testingInstances.numAttributes() - 1));
  58.                     Instance incorrectInstance = testingInstances.instance(i);
  59.                     incorrectInstance.setDataset(trainingInstances);
  60.                     double[] distribution = mlp.distributionForInstance(incorrectInstance);
  61.                     out.println("Probability of being positive: " + distribution[0]);
  62.                     out.println("Probability of being negative: " + distribution[1]);
  63.                 }
  64.             }
  65.         } catch (Exception ex) {
  66.             ex.printStackTrace();
  67.         }
  68.     }

  69.     public static void main(String[] args) {
  70.         new MultilayerPerceptronExample();
  71.     }
  72. }
复制代码
回复

使用道具 举报

Nicolle 学生认证  发表于 2018-9-23 11:16:26 |显示全部楼层
  1. package packt.somexamples;

  2. import java.io.FileReader;
  3. import java.io.IOException;
  4. import static java.lang.System.out;
  5. import weka.core.Instance;
  6. import weka.core.Instances;

  7. /*
  8.     <dependencies>
  9.         <!-- https://mvnrepository.com/artifact/nz.ac.waikato.cms.weka/weka-dev -->
  10.         <dependency>
  11.             <groupId>nz.ac.waikato.cms.weka</groupId>
  12.             <artifactId>weka-dev</artifactId>
  13.             <version>3.7.5</version>
  14.         </dependency>
  15.         <dependency>
  16.             <groupId>weka.plugin.lvq</groupId>
  17.             <artifactId>lvq-bundle</artifactId>
  18.             <version>1.0</version>
  19.         </dependency>   
  20.         <dependency>
  21.             <groupId>weka.plugin.som</groupId>
  22.             <artifactId>som-bundle</artifactId>
  23.             <version>1.0</version>
  24.             <type>jar</type>
  25.         </dependency>            
  26.     </dependencies>
  27. */
  28. public class SOMExample {

  29.     public SOMExample() {
  30.         SelfOrganizingMap som = new SelfOrganizingMap();
  31.         String trainingFileName = "iris.arff";
  32.         try (FileReader trainingReader = new FileReader(trainingFileName)) {
  33.             Instances trainingInstances = new Instances(trainingReader);
  34.             // The following linehas been commented out to avoid
  35.             // the error:Cannot handle any class attribute!
  36.             // This is because SOM uses unsupervised training
  37. //            trainingInstances.setClassIndex(trainingInstances.numAttributes() - 1);

  38.             som.buildClusterer(trainingInstances);
  39.             out.println(som);

  40.             Instances[] clusters = som.getClusterInstances();
  41.             out.println();
  42.             out.println(clusters.length);
  43.             int index = 0;
  44.             for (Instances instances : clusters) {
  45.                 out.println("-------Custer " + index);
  46.                 for (Instance instance : instances) {
  47.                     out.println(instance);
  48.                 }
  49.                 out.println();
  50.                 index++;
  51.             }
  52.         } catch (IOException ex) {
  53.             ex.printStackTrace();
  54.         } catch (Exception ex) {
  55.             ex.printStackTrace();
  56.         }
  57.     }

  58.     public static void main(String[] args) {
  59.         new SOMExample();
  60.     }
  61. }
复制代码
回复

使用道具 举报

Nicolle 学生认证  发表于 2018-9-23 11:21:34 |显示全部楼层
  1. package chap4.java.science.data;

  2. import weka.associations.Apriori;
  3. import weka.core.Instances;
  4. import weka.core.converters.ConverterUtils.DataSource;

  5. public class WekaAssociationRuleTest {
  6.         Instances superMarket = null;
  7.         Apriori apriori;
  8.         public void loadArff(String arffInput){
  9.                 DataSource source = null;
  10.                 try {
  11.                         source = new DataSource(arffInput);
  12.                         superMarket = source.getDataSet();
  13.                 } catch (Exception e1) {
  14.                 }
  15.         }
  16.         public void generateRule(){
  17.                 apriori = new Apriori();
  18.                 try {
  19. //                        apriori.setNumRules(20);
  20.                         apriori.buildAssociations(superMarket);
  21.                         System.out.println(apriori);
  22.                 } catch (Exception e) {
  23.                 }
  24.         }
  25.         public static void main(String args[]){
  26.                 WekaAssociationRuleTest test = new WekaAssociationRuleTest();
  27.                 test.loadArff("C:\\Program Files\\Weka-3-6\\data\\supermarket.arff");
  28.                 test.generateRule();
  29.         }
  30. }
复制代码
回复

使用道具 举报

heiyaodai 发表于 2018-9-24 20:48:51 |显示全部楼层
谢谢分享
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 我要注册

GMT+8, 2018-11-13 15:23