python |
Pythonタグが付けられた新着投稿 - Qiita |
BodyPixやーる(Python3.6、Tensorflow、Windows10) |
https://qiita.com/SatoshiGachiFujimoto/items/7dd770d9e1fc118d3040
|
PiPyでBodyPixをインストールしてPythonで使えるようにしているツワモノがいるんやで。 |
2021-05-30 05:05:51 |
海外TECH |
DEV Community |
How to create a binary decision tree in JavaScript |
https://dev.to/dstrekelj/how-to-create-a-binary-decision-tree-in-javascript-330g
|
How to create a binary decision tree in JavaScriptStuck writing large and nested if else if else conditions Trouble following how all these different conditions interact and flow together Here s a tool that can help decision trees Decision trees are a way to model conditional logic in a clear and composable way Although commonly used in machine learning they can be just as useful in more typical use cases which we will explore in this article This article will provide a brief introduction into trees as a data structure and decision trees as a tool as well as their application in software development We will create a binary decision tree in JavaScript step by step and apply it to decide whether a value is a positive number negative number zero or not a number at all Read on to find out more What is a tree data structure A tree data structure is a type of data structure in which data represented by nodes is connected in such a way that every node branches out into zero or more child nodes Visualising node connections gives the structure the appearance of a tree hence the name What is a binary tree data structure A binary tree data structure is a special type of tree data structure where every node can have up to two child nodes a left child node and a right child node A binary tree begins with a root node The root node can then branch out into left and right child nodes each child continuing to branch out into left and right child nodes as well Nodes that branch out into children are called non leaf nodes Nodes without children are called leaf nodes Going through the nodes of a binary tree traversing the tree gives us the choice of moving to either the left or right child node a binary choice earning this type of tree the name binary tree What is a decision tree A decision tree is a tool to help visualise decisions and the consequences of their outcomes At its simplest a decision tree contains decision nodes and outcome nodes also called end nodes Decision trees may also contain chance nodes Chance nodes serve as weights to favour one family of outcomes over another under certain conditions There are many different ways to visualise decision trees one example being flowchart symbols What is a binary decision tree A binary decision tree is a decision tree implemented in the form of a binary tree data structure A binary decision tree s non leaf nodes represent conditions and its leaf nodes represent outcomes By traversing a binary decision tree we can decide on an outcome under a given context and conditions What are decision tree applications Decision trees can be applied for predictive modelling in statistics data mining and machine learning Decision trees can also be applied in game development for building AIs and branching story paths as well as general development scenarios where there is a need to handle large chains of interconnected conditional statements How to turn conditional statements into binary decision tree nodes To turn conditional statements into binary decision tree nodes we have to treat conditional statements and outcomes as arguments passed to decision functions We will begin designing our decision tree data structure API by looking at conditional statements in our example The decideNumberSign function takes in a parameter x and attempts to return its sign or if the sign cannot be determined function decideNumberSign x if x gt return else if x lt return else if x return else return When it comes to making decisions based on a condition we need to define an outcome for the case of the condition being true and another outcome for the case of it being false With that in mind our decision node function would look like this decision x gt Combining decision nodes would then look like this decision x gt decision x lt decision x To support more complex conditions and prevent evaluating conditions on nodes that won t be traversed we can refactor our condition expressions into functions that will only be called when the node is reached const isPositive x gt x gt const isNegative x gt x lt const isZero x gt x decision isPositive decision isNegative decision isZero With the API finalised we can implement the function const decision conditionFunction trueOutcome falseOutcome gt context gt conditionFunction context trueOutcome falseOutcome We can now build a decision tree out of decision nodes but we can t traverse the tree just yet To traverse the tree and reach a decision we must be able to test the conditions by calling them with a context How to perform binary decision tree traversal To traverse a binary decision tree we provide a context to the root node of the tree which then calls its condition function and any decision node condition functions that follow as outcomes Let s again start by outlining the API const context number const numberSignDecision decision isPositive decision isNegative decision isZero decide context numberSignDecision We have to keep in mind that the outcome of our decisions our left and or right child nodes will either be a new decision node function or non callable value anything but a function If the outcome of our decision is another decision node we have to decide the new node s outcome for the current context until we reach a non callable value If the outcome of our decision node is a non callable value we return the value By deciding the outcome of every decision node we reach in that way we will effectively traverse the decision tree and reach a decision const decide context decision gt const outcome decision context return typeof outcome function decide context outcome outcome That s it we re done That s all there is to creating a simple binary decision tree in JavaScript JavaScript binary decision tree example code Decision tree APIconst decision conditionFunction trueOutcome falseOutcome gt context gt conditionFunction context trueOutcome falseOutcome const decide context decision gt const outcome decision context return typeof outcome function decide context outcome outcome Exampleconst isPositive x gt x gt const isNegative x gt x lt const isZero x gt x const numberSignDecision decision isPositive decision isNegative decision isZero const contextValues number Number NaN for const value of contextValues console log value decide value numberSignDecision Homework and next stepsImprove the decision function to check whether the conditionFunction argument is a function or not before calling it This will make the function more robust and provide us with a way to short circuit our decision with truthy or falsey values which can be very useful for debugging purposes Try turning our binary decision tree into an m ary decision tree M ary decision trees can have more than two decision nodes In their case we may not have true and false as outcomes but rather and as well as any value in between which would represent how certain we are in the outcome Thank you for taking the time to read through this article Do you have any experience creating decision trees Have you tried implementing one yourself Leave a comment and start a discussion |
2021-05-29 20:40:32 |
海外TECH |
DEV Community |
Data Structures in JavaScript [Arrays] |
https://dev.to/youssefzidan/data-structures-in-javascript-arrays-47oa
|
Data Structures in JavaScript Arrays What is an Array Arrays amp Big O NotationImplementing an ArrayPush Method Adding Using push MethodBig O With push Methodget Method Access Using the get method Big O With get Methodpop MethodUsing the pop methodBig O With pop Methoddelete MethodUsing delete methodBig O With delete MethodindexOf Method Searching Using indexOf methodBig O With indexOf Methodunshift MethodUsing unshift methodBig O With unshift Method What is an Array Arrays or Lists are used to store data in memory Sequentially In Order Arrays amp Big O NotationIn JavaScript Arrays are built in Data Structures And there are Methods to Access Push Insert and Delete Data Using Big O with these Methods will be Access gt O Add gt O Insert gt O n Delete gt O n Searching gt O n Examplesconst arr a b c Addarr push d console log arr a b c d Accessconsole log arr a Insertarr unshift X console log arr X a b c d arr splice X console log arr a b X c Deletearr splice console log arr a c Searchingconsole log arr indexOf a In order to understand where did these rules come from We can implement our own Array Implementing an ArrayWe don t have to build an array in JavaScript But it s very useful to do so in order to really understand why Big O is different from an operation to another with Arrays class List constructor this length this data Push Method Adding push ele this data this length ele this length return this length Adding the passed element to the data object as the length is the key Increment the length by Return the length Using push Methodconst list new List list push console log list data Big O With push MethodLet s use the roles of Big O to understand why adding an element in an array is O push ele this data this length ele gt O this length gt O return this length gt O The number of operations will be O Eventually Big O with the Push Method will be O get Method Access get index return this data index Using the get method const list new List list push console log list get Big O With get MethodThis function only Returns the value of the given index get index return this data index O Eventually Big O with the Get Method will be O pop Method pop const lastElement this data this length delete this data this length this length return lastElement Store the last element in a variable lastElement Use the delete keyword to remove it from the data object Decrementing the length of the array by Return the lastElement Using the pop methodconst list new List list push a list push b list pop console log list data a Big O With pop Method pop const lastElement this data this length O delete this data this length O this length O return lastElement O So Big O with the pop method will be also O delete Method Delete delete index const ele this data index for let i index i lt this length i this data i this data i delete this data this length this length return ele We get the ele we want to delete Looping starting from the index and replacing it with the next element Deleting the last element of the array Decrementing the length by Returning the deleted element Using delete methodconst list new List list push a list push b list push c list delete console log list data a c Big O With delete Method Delete delete index const ele this data index O for let i index i lt this length i this data i this data i O n delete this data this length O this length O return ele O So Big O with the delete method will be also O n indexOf Method Searching indexOf ele for const i in this data if this data i ele return i return Looping through the object using for in Check if the passed element exists If yes return the index If no as the normal indexOf we will return Using indexOf methodconst list new List list push a list push b list push c console log list indexOf b Big O With indexOf Method indexOf ele for const i in this data O n if this data i ele return i return Because we are Looping the Big O will be O n unshift Method unshift ele for let i this length i gt i this data i this data i this data ele this length Looping backwards and shift every element to the next element adding the passed element to the first index Increasing the length by Using unshift methodconst list new List list push a list push b list push c list unshift X console log list data X a b c Big O With unshift Method unshift ele for let i this length i gt i this data i this data i O n this data ele O this length O Because we are Looping the Big O will be O n |
2021-05-29 20:31:56 |
海外TECH |
DEV Community |
How to Install React in Laravel 8 |
https://dev.to/sureshramani/how-to-install-react-in-laravel-8-54a6
|
How to Install React in Laravel What is React js React is an open source front end JavaScript library for building user interfaces or UI components It is maintained by Facebook and a community of individual developers and companies React can be used as a base in the development of single page or mobile applications In this blog we will learn how to install React JS in Laravel If you don t know how to install Laravel in React JS this example tutorial is for you I will show you step by step to install react js in your Laravel application We will use the Laravel UI package to install React JS in the Laravel application I will show you React JS installation process with auth or without auth in Laravel So let s start our tutorial So you will also see Laravel React auth or Laravel React authentication process If you are a beginner with Laravel I am sure it will help you install React in Laravel It s a straightforward and easy way to install React JS using the Laravel UI composer package Laravel UI package provides a way to install basic bootstrap react and react setup and Vue js or angular js They also offer auth scaffold for login and registration with all of those javascript frameworks or libraries Laravel provides an easy way to work with bootstrap react vue and angular js Install LaravelFirst open Terminal and run the following command to create a fresh Laravel project composer create project laravel laravel react jsor if you have installed the Laravel Installer as a global composer dependency laravel new react js Install Laravel UIInstall Laravel UI package for starting with Laravel with React JS So if you want to start with Laravel with React run the below command composer require laravel ui Install Reactphp artisan ui react Install React with Authphp artisan ui react auth Install Required PackagesI assume that you have the Node and NPM installed on your development machine If not then have a look at this tutorial Install Node js and npmYou can check the Node and NPM version Run the following command Node Versionnode v NPM Versionnpm vNow install NPM Run the following command npm installNow run NPM Run the following command npm run devRun Laravel Serverphp artisan serveThank you for reading this blog |
2021-05-29 20:09:21 |
海外TECH |
Engadget |
New AI supercomputer will help create the largest-ever 3D map of the universe |
https://www.engadget.com/perlmutter-ai-supercomputer-3d-universe-map-200437484.html?src=rss_b2c
|
New AI supercomputer will help create the largest ever D map of the universeA new AI supercomputer Perlmutter is powerful enough that it will be used to help make the largest ever D map of the universe |
2021-05-29 20:04:37 |
海外科学 |
NYT > Science |
These Sisters With Sickle Cell Had Devastating, and Preventable, Strokes |
https://www.nytimes.com/2021/05/23/health/sickle-cell-black-children.html
|
These Sisters With Sickle Cell Had Devastating and Preventable StrokesKyra and Kami never got a simple test that could have protected them Their story exemplifies the failure to care for people with the disease most of whom are Black |
2021-05-29 20:00:47 |
ニュース |
BBC News - Home |
Boris Johnson marries fiancee in secret ceremony - reports |
https://www.bbc.co.uk/news/uk-57296472
|
newspaper |
2021-05-29 20:50:45 |
ニュース |
BBC News - Home |
Antetokounmpo scores triple-double as Bucks sweep series against Heat |
https://www.bbc.co.uk/sport/basketball/57295463
|
Antetokounmpo scores triple double as Bucks sweep series against HeatGiannis Antetokounmpo stars as the Milwaukee Bucks progress to the Eastern Conference semi finals with a series win over the Miami Heat |
2021-05-29 20:34:39 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
教師が「自分一人でできる」最強時短術5選、テスト採点がここまで楽に! - 教師 出世・カネ・絶望 |
https://diamond.jp/articles/-/271716
|
働き方改革 |
2021-05-30 05:25:00 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
副業で「先生・コーチ」になる!【60の仕事と料金相場】、部活指導員は1時間4000円 - 教師 出世・カネ・絶望 |
https://diamond.jp/articles/-/271715
|
部活 |
2021-05-30 05:20:00 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
タワマンを廃虚にしない!高コスパ修繕から資金潤沢経営まで、スゴ腕管理組合に学ぶ - タワマン 全内幕 |
https://diamond.jp/articles/-/271686
|
区分所有 |
2021-05-30 05:15:00 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
タワマン「値上がり度」ランキング【中京圏トップ30】、含み益大のお宝物件はどこだ! - タワマン 全内幕 |
https://diamond.jp/articles/-/271685
|
値上がり |
2021-05-30 05:10:00 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
「ウィズ・コロナ」のあり方とは?いま、川端康成『雪国』を読むべき理由 - ビジネスを強くする教養 |
https://diamond.jp/articles/-/272592
|
川端康成 |
2021-05-30 05:05:00 |
ビジネス |
東洋経済オンライン |
ペット可物件に潜む「高額請求トラブル」の不条理 いきなり送られてきた「70万円の請求書」の衝撃 | ペット | 東洋経済オンライン |
https://toyokeizai.net/articles/-/429134?utm_source=rss&utm_medium=http&utm_campaign=link_back
|
原状回復 |
2021-05-30 05:30:00 |
コメント
コメントを投稿