如何在代码中将menu隐藏

In the last couple of years, Artificial intelligence is finding its use in all sorts of applications. It can be in medical, health and fitness, education, video calling, sports… you just name it.

在过去的几年中,人工智能正在各种应用中找到其用途。 它可以用于医疗,健康和健身,教育,视频通话,体育……等等。

If you are wondering that can you use artificial intelligence techniques in your research areas? But you don’t have much idea how to use it.

如果您想知道是否可以在研究领域中使用人工智能技术? 但是您对如何使用它并不了解。

Then I say- Yes, there is a good chance that you can use it and in this article, I am going to explain how to employ already developed artificial intelligence techniques to the application of your choice within 40 lines of code.

然后我说-是的,您很有可能会使用它,在本文中,我将解释如何在40行代码中将已经开发的人工智能技术应用于您选择的应用程序。

Another thing before diving into the code, if you are thinking that do I need to be an expert in coding to understand this?

在深入研究代码之前的另一件事,如果您认为我需要成为编码方面的专家才能理解这一点?

No, you don’t. If you have even basic knowledge of coding or done a little bit of it at the school or maybe at the college level, it should be sufficient to get started.

不,你没有。 如果您甚至具有编码方面的基础知识,或者在学校或大学一级都做了一些编码工作,那么入门就足够了。

I will show you how to apply artificial intelligence or specifically machine learning to an optical or photonics application problem. I have chosen an optical application because my background is in optical engineering. Your’s can be different- it can be in chemistry, physics, material science, biology, or any other. The steps which I am going to explain are transferable to all the research areas. Also, I will be coding in python language as this is commonly used coding language for the application of machine learning.

我将向您展示如何将人工智能或专门的机器学习应用于光学或光子学应用问题。 我选择光学应用是因为我的背景是光学工程。 您的可能会有所不同-化学,物理,材料科学,生物学或任何其他领域都可能不同。 我要解释的步骤可以转移到所有研究领域。 另外,我将使用python语言进行编码,因为这是机器学习应用程序中常用的编码语言。

There are various kinds of machine learning problem categories: Classification, Regression, Clustering, among others. For more details refer to this link. In this article, I am going to show you an example code for a regression problem.

机器学习问题种类繁多:分类,回归,聚类等。 有关更多详细信息,请参考此链接 。 在本文中,我将向您展示一个回归问题的示例代码。

The First step: for a machine learning application/problem is to have/generate a good, clean dataset. But then there is a good chance that the application that you have in mind doesn’t have the dataset freely available online. So, firstly here I briefly show the Photonics problem I am considering and generate the dataset for it.

第一步:对于机器学习应用程序/问题是拥有/生成一个良好的,干净的数据集。 但是,您所想到的应用程序很有可能没有在线免费提供的数据集。 因此,首先,我在这里简要展示我正在考虑的光子学问题,并为其生成数据集。

考虑的问题 (Problem considered)

Photo by Author
作者照片

The left circular structure is how the cross-section of a typical hexagonal Photonic Crystal Fiber (PCF) looks like in an optical/photonics problem. Then I need to decide what are the input parameters for this problem. I have shown five input parameters (in green color) but for this article, I am only using 3 of them (wavelength, diameter, pitch) to keep the problem small and simple. For various combinations of input parameters, I obtain desired output nodes quantities (in orange color) and store these in a pcf_data.xlsx file, as shown below.

左圆形结构是典型的六边形光子晶体光纤(PCF)的横截面在光学/光子学问题中的样子。 然后,我需要确定此问题的输入参数是什么。 我已经显示了五个输入参数(绿色),但是对于本文,我仅使用其中三个参数(波长,直径,间距)来使问题小而简单。 对于输入参数的各种组合,我获得了所需的输出节点数量(橙色),并将其存储在pcf_data.xlsx文件中,如下所示。

Photo by Author
作者照片

Again, I have only considered effective index as output to keep the problem simple. If you want you can have more output nodes as shown in the output layer nodes figure. Also, I have only taken 20 combinations of input parameters. Ideally, it is very less for a typical machine learning problem but for this article to demonstrate the method, it is sufficient.

再次,我只考虑有效索引作为输出,以使问题保持​​简单。 如果需要,可以有更多输出节点,如输出层节点图所示。 另外,我仅采用了20种输入参数组合。 理想情况下,对于典型的机器学习问题而言,它要少得多,但是对于本文中演示的方法而言,它就足够了。

For your case, you first need to figure out the problem, and it’s input and output parameters. Then generate the dataset in the CSV /XLSX format similar to shown above. Some sort of simulator/software or even an experimental/fabrication kit would be fine to generate the data.

对于您的情况,您首先需要弄清楚问题及其输入和输出参数。 然后以类似于上图所示的CSV / XLSX格式生成数据集。 某种模拟器/软件甚至实验/制造套件都可以生成数据。

The Second step: is to normalize the generated/collected data. The goal of normalization is to change the values of numeric columns in the dataset to a common scale. Here, we use the MinMaxScalar() function form Scikit-learn to translate each feature individually such that it is in the given range on the training set, e.g. between zero and one. Note: You may need to install, use pip install scikit-learn.

第二步:标准化生成/收集的数据。 标准化的目的是将数据集中的数字列的值更改为通用比例。 在这里,我们使用Scikit-learnMinMaxScalar()函数来分别转换每个特征,以使其在训练集上处于给定范围内,例如介于零和一之间。 注意:您可能需要安装,请使用pip install scikit-learn

import pandas as pdfrom sklearn.preprocessing import MinMaxScaler# Read the data stored in Excel file using pandas librarydf = pd.read_excel('pcf_data.xlsx', sheet_name='Sheet1')# Scale the input data in range (0,1)scaler = MinMaxScaler(feature_range=(0, 1))scaler.fit(df)df_scaler = scaler.transform(df)

Photo by Author
作者照片

All the input and output values are now scaled between zero and one with minimum and maximum value in every column equated to 0 and 1, respectively. These scaled values will become the inputs to the machine learning model. In the end, we will perform the inverse transform to obtain the original values.

现在,所有输入和输出值都在0和1之间缩放,每列中的最小值和最大值分别等于0和1。 这些缩放后的值将成为机器学习模型的输入。 最后,我们将执行逆变换以获得原始值。

The Third step: is to define your input and output parameter columns for the code to understand and split the whole dataset in training and test sets. In our case, the first 3 columns are inputs and the last column is output. The train_test_split()function is used to split the dataset. The test dataset extracted will be used to check the accuracy of the model. Here, 10% of data is stored separately as the test dataset.

第三步:定义代码的输入和输出参数列,以理解和拆分训练和测试集中的整个数据集。 在我们的例子中,前三列是输入,最后一列是输出。 train_test_split()函数用于拆分数据集。 提取的测试数据集将用于检查模型的准确性。 在这里,10%的数据作为测试数据集单独存储。

from sklearn.model_selection import train_test_splitnum_inputs = 3num_outputs = 1X = df_scaler[:,range(0, num_inputs)]y = df_scaler[:,range(num_inputs, num_inputs+num_outputs)]X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.1)

The Fourth Step: is to define the machine learning model. Here, I use MLPRegressor() function developed by Scikit-learn to quickly define various layers and parameters of the machine learning model. Shuffling of data is done so that the model is not biased towards any particular inputs. For more details about the various parameters of MLPRegressor() , check the official website link. The .fit() function trains the model for the specified number of epochs/iterations.

第四步:定义机器学习模型。 在这里,我使用MLPRegressor() Scikit-learn开发的MLPRegressor()函数来快速定义机器学习模型的各个层和参数。 进行数据改组,以使模型不会偏向任何特定输入。 有关MLPRegressor()各种参数的更多详细信息,请访问官方网站链接 。 .fit()函数针对指定的纪元/迭代次数训练模型。

from sklearn.neural_network import MLPRegressorepochs = 1000mlp = MLPRegressor(shuffle=True, random_state=1, max_iter=epochs)mlp.fit(X_train, y_train)print("Training set score: ", mlp.score(X_train, y_train))

The Fifth step: is to check the prediction on the test set using the already trained model from the previous step. Here, it is required to do the inverse_transform() at the end to obtain the unscaled values. As the test set is randomly generated during the train_test_split() so you need to carefully check and compare the results obtained from the below function with the actual stored values in the test set.

第五步:使用上一步中已经训练好的模型检查测试集上的预测。 在这里,需要最后执行inverse_transform()以获得未缩放的值。 由于测试集是在train_test_split()期间随机生成的,因此您需要仔细检查并将以下函数获得的结果与测试集中的实际存储值进行比较。

import numpy as npdef prediction(data):    # data should already be scaled    pred_output = mlp.predict(data)    final = np.concatenate((data, pred_output.reshape(-1,1)), axis=1)    return scaler.inverse_transform(final)print(prediction(X_test))

Finally: I show how to obtain the output w.r.t to inputs given by the user and not for the test set. Let us say the user wants to predict the output for these inputs: [diaBYpitch, pitch, wavelength] → [0.7, 0.8, 1.8]. To use our machine learning model we take scaled inputs (defined above) with 4 columns in total for this problem. So here I append zero with the user inputs and then do the scaling using scaler.transfor() as we did above. You could append any integer/number in spite of zero and it won’t affect the output as we are not retraining the model. We only need the fourth column to do the scaling using the above defined scaler.

最后:我展示了如何获取用户给定输入而不是测试集输入的输出wrt。 假设用户想要预测这些输入的输出:[diaBYpitch,pitch,波长]→[0.7、0.8、1.8]。 要使用我们的机器学习模型,我们针对此问题采用总共4列的缩放输入(如上定义)。 因此,在这里我将零添加用户输入,然后像上面一样使用scaler.transfor()进行缩放 。 您可以附加任何整数/数字(尽管为零),并且不会影响输出,因为我们没有重新训练模型。 我们只需要第四列使用上面定义的scaler

def predict_on_user_input(user_input):    user_input = np.append(user_input, 0).reshape(1,-1)    user_input = scaler.transform(user_input)    return prediction(user_input[:,0:num_inputs])output = predict_on_user_input([0.7, 0.8, 1.8])print('output: ', output)

所有代码在一起 (All the code together)

The steps described in this article are transferable to any other research area. But of course, you need to figure out the problem you are interested in and maybe collect the dataset by yourself if it is not available online. I hope this article will help you to get started with using machine learning with python even if you have very little coding experience. Cheers!!

本文中描述的步骤可以转移到任何其他研究领域。 但是,当然,您需要弄清楚自己感兴趣的问题,如果无法在线获取数据集,则可以自己收集。 我希望即使您只有很少的编码经验,本文也将帮助您开始使用python进行机器学习。 干杯!!

翻译自: https://medium.com/@sunnychugh/how-to-use-machine-learning-for-an-optical-photonics-application-in-40-lines-of-code-92cc1c6704f6

如何在代码中将menu隐藏


http://www.taodudu.cc/news/show-863706.html

相关文章:

  • pytorch实现文本分类_使用变形金刚进行文本分类(Pytorch实现)
  • python 机器学习管道_构建机器学习管道-第1部分
  • pandas数据可视化_5利用Pandas进行强大的可视化以进行数据预处理
  • 迁移学习 迁移参数_迁移学习简介
  • div文字自动扩充_文字资料扩充
  • ml是什么_ML,ML,谁是所有人的冠军?
  • 随机森林分类器_建立您的第一个随机森林分类器
  • Python中的线性回归:Sklearn与Excel
  • 机器学习中倒三角符号_机器学习的三角误差
  • 使用Java解决您的数据科学问题
  • 树莓派 神经网络植入_使用自动编码器和TensorFlow进行神经植入
  • opencv 运动追踪_足球运动员追踪-使用OpenCV根据运动员的球衣颜色识别运动员的球队
  • 犀牛建模软件的英文语言包_使用tidytext和textmineR软件包在R中进行主题建模(
  • 使用Keras和TensorFlow构建深度自动编码器
  • 出人意料的生日会400字_出人意料的有效遗传方法进行特征选择
  • fast.ai_使用fast.ai自组织地图—步骤4:使用Fast.ai DataBunch处理非监督数据
  • 无监督学习与监督学习_有监督与无监督学习
  • 分类决策树 回归决策树_决策树分类器背后的数学
  • 检测对抗样本_对抗T恤以逃避ML人检测器
  • 机器学习中一阶段网络是啥_机器学习项目的各个阶段
  • 目标检测 dcn v2_使用Detectron2分6步进行目标检测
  • 生成高分辨率pdf_用于高分辨率图像合成的生成变分自编码器
  • 神经网络激活函数对数函数_神经网络中的激活函数
  • 算法伦理
  • python 降噪_使用降噪自动编码器重建损坏的数据(Python代码)
  • bert简介_BERT简介
  • 卷积神经网络结构_卷积神经网络
  • html两个框架同时_两个框架的故事
  • 深度学习中交叉熵_深度计算机视觉,用于检测高熵合金中的钽和铌碎片
  • 梯度提升树python_梯度增强树回归— Spark和Python

如何在代码中将menu隐藏_如何在40行代码中将机器学习用于光学/光子学应用相关推荐

  1. c语言求婚代码大全,继“代码求救”后,程序员用40行代码求婚成功!

    原标题:继"代码求救"后,程序员用40行代码求婚成功! 前段时间,程序员又火了一把. 一名程序员掉入传销组织用代码向同事求救,同事秒懂,程序员被成功救出.大家都为程序员的机智点赞, ...

  2. python人脸识别毕业设计-Python 40行代码实现人脸识别功能

    前言 很多人都认为人脸识别是一项非常难以实现的工作,看到名字就害怕,然后心怀忐忑到网上一搜,看到网上N页的教程立马就放弃了.这些人里包括曾经的我自己.其实如果如果你不是非要深究其中的原理,只是要实现这 ...

  3. 40行代码的人脸识别实践【转】

    转自:http://blog.csdn.net/xingchenbingbuyu/article/details/68482838?ref=myrecommend 版权声明:本文为博主原创文章,转载请 ...

  4. python画人脸编程怎么写_Python 40行代码实现人脸识别功能

    前言 很多人都认为人脸识别是一项非常难以实现的工作,看到名字就害怕,然后心怀忐忑到网上一搜,看到网上N页的教程立马就放弃了.这些人里包括曾经的我自己.其实如果如果你不是非要深究其中的原理,只是要实现这 ...

  5. java selenium_java+selenium,40行代码完成支付宝账单爬取

    java+selenium,40行代码完成支付宝账单爬取 需要jar selenium-server-4.0.0-alpha-5.jar 需要驱动 chromedriver.exe 驱动需要和浏览器版 ...

  6. Crawler:基于requests库+json库+40行代码实现爬取猫眼榜单TOP100榜电影名称主要信息

    Crawler:基于requests库+json库+40行代码实现爬取猫眼榜单TOP100榜电影名称主要信息 目录 输出结果 实现代码 输出结果 实现代码 # -*- coding: utf-8 -* ...

  7. 分享一个开源的JavaScript统计图表库,40行代码实现专业统计图表

    这可能是史上最简单易用的开源统计图表绘制库了.柱状图,饼状图,点状图等等您能想到的类型全部支持. 这个开源库的官网:http://www.chartjs.org/ 直接看如何只用40行代码就实现专业的 ...

  8. python调用计算器卡死_Python+tkinter使用40行代码实现计算器功能

    本文实例为大家分享了40行Python代码实现计算器功能,供大家参考,具体内容如下 偶尔用脚本写点东西也是不错的. 效果图 代码 from tkinter import * reset=True de ...

  9. 40行代码教你利用Python网络爬虫批量抓取小视频

    1. 前言 还在为在线看小视频缓存慢发愁吗?还在为想重新回味优秀作品但找不到资源而忧虑吗?莫要慌,让python来帮你解决,40行代码教你爬遍小视频网站,先批量下载后仔细观看,岂不美哉! 2. 整理思 ...

最新文章

  1. html怎么加载xml文档,在html中解析xml文件(javascript 读取)
  2. 源代码文档生成 Doxygen介绍(转载)
  3. IDEA中创建类时,自动在文件头中添加作者以及创建时间
  4. Tomcat 的 DefaultServlet
  5. ReviewForJob(2)算法分析
  6. 数据结构实验之查找四:二分查找
  7. CentOS 安装go client调用Kubernetes API
  8. java date.from_java datefromat
  9. 前端开发 选择器的优先级 0229
  10. Community Server Resources
  11. 北漂九年 ,雷军终于买房了:壕掷52亿元
  12. Leetcode 147 Insertion Sort List
  13. Fiddler下载视频号中的视频最简教程
  14. 信号及传播介质 综合布线系统
  15. format函数python生成列表_python之自动生成器(持续更新)
  16. 财帮子,一个非常不错的投资理财社区
  17. 更完美 联想乐Phone获取root权限教程
  18. 人工智能与数据挖掘的关系
  19. 【个人使用篇】github代码管理
  20. 扫地机器人噪音响_硬件老兵拆机分析:扫地机器人噪音大小到底与何相关?

热门文章

  1. 正则表达式语法(转)
  2. 微信企业号开发之正式版的本地调试
  3. UIView使用UIMotionEffect效果
  4. 【转】Oracle回收站(recyclebin)
  5. Table definition on master and slave does not match
  6. Apache配置(转载)
  7. 为什么函数式编程很重要:不一样的白板图
  8. NAS优缺点完全剖析
  9. ASP.NET学习笔记 2
  10. 信息系统管理工程师_关于备考信息系统项目管理师、系统集成项目管理工程师考试几点小建议...