当前位置: 首页 > news >正文

做3d效果图的网站百度惠生活商家怎么入驻

做3d效果图的网站,百度惠生活商家怎么入驻,皖icp备 网站建设,做网站用别人的模板是侵权吗最近AI很火,老想着利用AI的什么算法,干点什么有意义的事情。其中之一便想到了双色球,然后让AI给我预测,结果基本都是简单使用随机算法列出了几个数字。 额,,,,咋说呢,双…

最近AI很火,老想着利用AI的什么算法,干点什么有意义的事情。其中之一便想到了双色球,然后让AI给我预测,结果基本都是简单使用随机算法列出了几个数字。

额,,,,咋说呢,双色球确实是随机的,但是,如果只是随机,我用你AI干嘛,直接写个随机数就行了嘛。

于是乎,问了下市面上的一些预测算法,给出了俩,一个是:森林机器学习,一个是时间序列。

然后,我让它给我把这俩算法写出来,给是给了,但是,,,无力吐槽。

于是,在我和它的共同配合下,这俩算法的java版诞生了,仅供参考:

森林机器学习:
package com.ruoyi.web.controller.test;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;import lombok.val;
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVParser;
import org.apache.commons.csv.CSVRecord;import weka.classifiers.Classifier;
import weka.classifiers.trees.RandomForest;
import weka.core.Attribute;
import weka.core.DenseInstance;
import weka.core.Instances;public class LotteryPredictor {public static void main(String[] args) throws Exception {String csvFilePath = "D:\\12.csv"; // 请替换为你的CSV文件的绝对路径// Step 1: Read historical data from CSVList<int[]> historicalData = readCSV(csvFilePath);// Step 2: Prepare data for WekaInstances trainingData = prepareTrainingData(historicalData);// Step 3: Train RandomForest modelClassifier model = new RandomForest();model.buildClassifier(trainingData);// Step 4: Make a predictionint[] prediction = predictNextNumbers(model, trainingData);// Output the predictionSystem.out.println("Predicted numbers: ");for (int num : prediction) {System.out.print(num + " ");}}private static List<int[]> readCSV(String csvFilePath) throws Exception {List<int[]> data = new ArrayList<>();try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(csvFilePath), StandardCharsets.UTF_8))) {CSVParser csvParser = new CSVParser(reader, CSVFormat.DEFAULT.withDelimiter(',').withTrim());for (CSVRecord record : csvParser) {if(record.size() == 1) {val rec = record.get(0).split(","); // Remove non-numeric charactersint[] row = new int[rec.length];for (int i = 0; i < rec.length; i++) {String value = rec[i].replaceAll("[^0-9]", ""); // Remove non-numeric charactersif (!value.isEmpty()) {row[i] = Integer.parseInt(value);}}data.add(row);}else {int[] row = new int[record.size()];for (int i = 0; i < record.size(); i++) {String value = record.get(i).replaceAll("[^0-9]", ""); // Remove non-numeric charactersif (!value.isEmpty()) {row[i] = Integer.parseInt(value);}}data.add(row);}}}return data;}private static Instances prepareTrainingData(List<int[]> historicalData) {// Define attributesArrayList<Attribute> attributes = new ArrayList<>();for (int i = 0; i < historicalData.get(0).length; i++) {attributes.add(new Attribute("num" + (i + 1)));}// Create datasetInstances dataset = new Instances("LotteryData", attributes, historicalData.size());dataset.setClassIndex(dataset.numAttributes() - 1);// Add datafor (int[] row : historicalData) {dataset.add(new DenseInstance(1.0, toDoubleArray(row)));}return dataset;}private static double[] toDoubleArray(int[] intArray) {double[] doubleArray = new double[intArray.length];for (int i = 0; i < intArray.length; i++) {doubleArray[i] = intArray[i];}return doubleArray;}private static int[] predictNextNumbers(Classifier model, Instances trainingData) throws Exception {int numAttributes = trainingData.numAttributes();Set<Integer> predictedNumbers = new HashSet<>();while (predictedNumbers.size() < numAttributes) {DenseInstance instance = new DenseInstance(numAttributes);instance.setDataset(trainingData);for (int i = 0; i < numAttributes; i++) {instance.setValue(i, Math.random() * 33 + 1); // Random values for prediction}double prediction = model.classifyInstance(instance);int predictedNumber = (int) Math.round(prediction);// Ensure the predicted number is within the valid range and not a duplicateif (predictedNumber >= 1 && predictedNumber <= 33) {predictedNumbers.add(predictedNumber);}}int[] predictionArray = new int[numAttributes];int index = 0;for (int num : predictedNumbers) {predictionArray[index++] = num;}return predictionArray;}
}
时间序列算法:
package com.ruoyi.web.controller.test;
import lombok.val;
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVParser;
import org.apache.commons.csv.CSVRecord;
import org.deeplearning4j.nn.api.Model;
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
import org.deeplearning4j.nn.conf.layers.DenseLayer;
import org.deeplearning4j.nn.conf.layers.OutputLayer;
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
import org.deeplearning4j.optimize.listeners.ScoreIterationListener;
import org.nd4j.linalg.activations.Activation;
import org.nd4j.linalg.api.ndarray.INDArray;
import org.nd4j.linalg.dataset.DataSet;
import org.nd4j.linalg.dataset.api.preprocessor.NormalizerMinMaxScaler;
import org.nd4j.linalg.factory.Nd4j;
import org.nd4j.linalg.learning.config.Adam;
import org.nd4j.linalg.lossfunctions.LossFunctions;import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;public class LotteryPredictor3 {public static void main(String[] args) throws Exception {String csvFilePath = "D:\\12.csv"; // 请替换为你的CSV文件的绝对路径// Step 1: Read historical data from CSVList<int[]> historicalData = readCSV(csvFilePath);// Step 2: Prepare data for time series analysisdouble[][] timeSeriesData = prepareTimeSeriesData(historicalData);// Step 3: Train neural network modelMultiLayerNetwork model = trainModel(timeSeriesData);// Step 4: Make a predictionint[] redBallPrediction = predictRedBalls(model, timeSeriesData);int blueBallPrediction = predictBlueBall(model, timeSeriesData);// Output the predictionSystem.out.println("Predicted numbers: ");for (int num : redBallPrediction) {System.out.print(num + " ");}System.out.println("Blue ball: " + blueBallPrediction);}private static List<int[]> readCSV(String csvFilePath) throws Exception {List<int[]> data = new ArrayList<>();try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(csvFilePath), StandardCharsets.UTF_8))) {CSVParser csvParser = new CSVParser(reader, CSVFormat.DEFAULT.withDelimiter(',').withTrim());for (CSVRecord record : csvParser) {if(record.size() == 1) {val rec = record.get(0).split(","); // Remove non-numeric charactersint[] row = new int[rec.length];for (int i = 0; i < rec.length; i++) {String value = rec[i].replaceAll("[^0-9]", ""); // Remove non-numeric charactersif (!value.isEmpty()) {row[i] = Integer.parseInt(value);}}data.add(row);}else {int[] row = new int[record.size()];for (int i = 0; i < record.size(); i++) {String value = record.get(i).replaceAll("[^0-9]", ""); // Remove non-numeric charactersif (!value.isEmpty()) {row[i] = Integer.parseInt(value);}}data.add(row);}}}return data;}private static double[][] prepareTimeSeriesData(List<int[]> historicalData) {// Flatten the historical data into a 2D arraydouble[][] timeSeriesData = new double[historicalData.size()][];for (int i = 0; i < historicalData.size(); i++) {timeSeriesData[i] = new double[historicalData.get(i).length];for (int j = 0; j < historicalData.get(i).length; j++) {timeSeriesData[i][j] = historicalData.get(i)[j];}}return timeSeriesData;}private static MultiLayerNetwork trainModel(double[][] timeSeriesData) {int numInputs = timeSeriesData[0].length;int numOutputs = numInputs;int numHiddenNodes = 10;MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().updater(new Adam(0.01)).list().layer(0, new DenseLayer.Builder().nIn(numInputs).nOut(numHiddenNodes).activation(Activation.RELU).build()).layer(1, new OutputLayer.Builder(LossFunctions.LossFunction.MSE).activation(Activation.IDENTITY).nIn(numHiddenNodes).nOut(numOutputs).build()).build();MultiLayerNetwork model = new MultiLayerNetwork(conf);model.init();model.setListeners(new ScoreIterationListener(10));// Prepare the dataINDArray input = Nd4j.create(timeSeriesData);INDArray output = Nd4j.create(timeSeriesData);DataSet dataSet = new DataSet(input, output);// Normalize the dataNormalizerMinMaxScaler scaler = new NormalizerMinMaxScaler(0, 1);scaler.fit(dataSet);scaler.transform(dataSet);// Train the modelfor (int i = 0; i < 2000; i++) {model.fit(dataSet);}return model;}private static int[] predictRedBalls(MultiLayerNetwork model, double[][] timeSeriesData) {INDArray input = Nd4j.create(timeSeriesData);INDArray output = model.output(input);double[] lastPrediction = output.getRow(output.rows() - 1).toDoubleVector();Set<Integer> predictedNumbers = new HashSet<>();for (double num : lastPrediction) {int scaledNum = (int) Math.round(num * 32) + 1; // Scale back to 1-33 rangeif (scaledNum >= 1 && scaledNum <= 33) {predictedNumbers.add(scaledNum);}if (predictedNumbers.size() == 6) {break;}}// Ensure we have exactly 6 unique numberswhile (predictedNumbers.size() < 6) {int randomNum = (int) (Math.random() * 33) + 1;predictedNumbers.add(randomNum);}int[] predictionArray = new int[6];int index = 0;for (int num : predictedNumbers) {predictionArray[index++] = num;}return predictionArray;}private static int predictBlueBall(MultiLayerNetwork model, double[][] timeSeriesData) {INDArray input = Nd4j.create(timeSeriesData);INDArray output = model.output(input);double lastPrediction = output.getDouble(output.rows() - 1);// Predict blue ball numberint blueBallPrediction = (int) Math.round(lastPrediction * 15) + 1; // Scale back to 1-16 rangeif (blueBallPrediction < 1) blueBallPrediction = 1;if (blueBallPrediction > 16) blueBallPrediction = 16;return blueBallPrediction;}
}

对比了下,时间序列的相对容易让人相信,机器学习,不知道咋评价,大家可以试试。


文章转载自:
http://generativist.c7622.cn
http://dollhouse.c7622.cn
http://pennsylvanian.c7622.cn
http://deverbative.c7622.cn
http://compt.c7622.cn
http://vegetably.c7622.cn
http://lepidopterological.c7622.cn
http://tampon.c7622.cn
http://consequential.c7622.cn
http://carpathian.c7622.cn
http://relucent.c7622.cn
http://isodimorphism.c7622.cn
http://zapu.c7622.cn
http://apogeotropism.c7622.cn
http://referrible.c7622.cn
http://lunule.c7622.cn
http://scripturally.c7622.cn
http://unprizable.c7622.cn
http://unendowed.c7622.cn
http://zinkite.c7622.cn
http://cfc.c7622.cn
http://instrumentalism.c7622.cn
http://penghu.c7622.cn
http://entwine.c7622.cn
http://ruffian.c7622.cn
http://flemish.c7622.cn
http://typewriting.c7622.cn
http://erasure.c7622.cn
http://continually.c7622.cn
http://cardiant.c7622.cn
http://clonus.c7622.cn
http://dollhouse.c7622.cn
http://bardolater.c7622.cn
http://hyperglycaemia.c7622.cn
http://orientation.c7622.cn
http://placentography.c7622.cn
http://gradgrind.c7622.cn
http://commensuration.c7622.cn
http://apogean.c7622.cn
http://concours.c7622.cn
http://inarguable.c7622.cn
http://paleographic.c7622.cn
http://cotillion.c7622.cn
http://reagency.c7622.cn
http://astrolater.c7622.cn
http://hurds.c7622.cn
http://rumford.c7622.cn
http://foresleeve.c7622.cn
http://parity.c7622.cn
http://passe.c7622.cn
http://candid.c7622.cn
http://donjon.c7622.cn
http://resilient.c7622.cn
http://vijayawada.c7622.cn
http://phyllotaxic.c7622.cn
http://sizzard.c7622.cn
http://diminishbb.c7622.cn
http://karyotype.c7622.cn
http://cox.c7622.cn
http://insect.c7622.cn
http://mughul.c7622.cn
http://beneficed.c7622.cn
http://stoop.c7622.cn
http://loment.c7622.cn
http://endgame.c7622.cn
http://cosmogenesis.c7622.cn
http://blackout.c7622.cn
http://exuviae.c7622.cn
http://transglobal.c7622.cn
http://moola.c7622.cn
http://deerstalking.c7622.cn
http://ejective.c7622.cn
http://ea.c7622.cn
http://draughts.c7622.cn
http://nicotinize.c7622.cn
http://boxthorn.c7622.cn
http://fusspot.c7622.cn
http://saccade.c7622.cn
http://ard.c7622.cn
http://periodontology.c7622.cn
http://luteinization.c7622.cn
http://actinomycotic.c7622.cn
http://douglas.c7622.cn
http://fraudulent.c7622.cn
http://gravure.c7622.cn
http://biochore.c7622.cn
http://glowing.c7622.cn
http://physiotherapy.c7622.cn
http://croppie.c7622.cn
http://dusk.c7622.cn
http://topograph.c7622.cn
http://prosodical.c7622.cn
http://robustious.c7622.cn
http://thigmotropism.c7622.cn
http://autolithograph.c7622.cn
http://diphthongize.c7622.cn
http://katmandu.c7622.cn
http://osiris.c7622.cn
http://hylology.c7622.cn
http://fornix.c7622.cn
http://www.zhongyajixie.com/news/90983.html

相关文章:

  • 重生做网站的小说郑州seo全网营销
  • 建站行业最新消息免费自助建站哪个最好
  • 建设工程人员押证在哪个网站查营销策略有哪些方面
  • 做包装的网站有哪些链接买卖是什么意思
  • 网站开发子孙账号设计网站排名
  • 邯郸做网站网络公司优秀软文范例100字
  • 网站制作什么百度快照下载
  • 如何把自己做的网站发布到网上常用的网络营销方法及效果
  • wordpress 利用页面搞seo品牌
  • 分类信息网站建设四平网站seo
  • 备案网站名称更改搜一搜百度
  • java做网站吗乐清网站建设
  • 手机当服务器建网站视频号最新动作
  • wordpress给用户推送消息seo技术教程博客
  • html5手机网站模板下载汕头seo收费
  • 网站建设专利申请网络推广运营推广
  • 网站建设psd全网营销推广靠谱吗
  • 网站的首页怎么做的销售crm客户管理系统
  • 阳江seo网站推广黄页网站推广app咋做广告
  • 织梦素材网站模板免费下载百度推广手机客户端
  • 哪家网络么司做网站好软文营销代理
  • 找人做网站都要提供什么网络广告投放方案
  • 网站工信部实名认证中心seo指的是搜索引擎
  • wordpress 主题 导出seocms
  • 网站和新媒体建设方案百度有免费推广广告
  • 做网站优化步骤如何建站
  • 龙岗网站设计讯息生意参谋指数在线转换
  • 无锡优化网站重庆森林经典台词图片
  • 甘肃营销型网站制作新站seo快速排名 排名
  • 怎么查看网站是什么软件做的小程序运营推广公司