<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Quasar Community Blog]]></title><description><![CDATA[Quasar Community Blog brings you all the technical content in an easily understandable manner.]]></description><link>https://blog.quasarcommunity.org</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1648464301451/PY0gc2tbXj.png</url><title>Quasar Community Blog</title><link>https://blog.quasarcommunity.org</link></image><generator>RSS for Node</generator><lastBuildDate>Thu, 10 Sep 2026 04:23:37 GMT</lastBuildDate><atom:link href="https://blog.quasarcommunity.org/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Making Autonomous Vehicles Agree at Intersections]]></title><description><![CDATA[Hi, I am Mathesh. I have been working on this project for the last few months at UC Santa Cruz, with guidance from Professor Mohsen Lesani, and I wanted to share the current updates and findings from ]]></description><link>https://blog.quasarcommunity.org/making-autonomous-vehicles-agree-at-intersections</link><guid isPermaLink="true">https://blog.quasarcommunity.org/making-autonomous-vehicles-agree-at-intersections</guid><category><![CDATA[distributed system]]></category><category><![CDATA[Autonomous vehicles]]></category><category><![CDATA[WirelessNetworks]]></category><category><![CDATA[Consensus]]></category><category><![CDATA[simulation]]></category><category><![CDATA[raft]]></category><dc:creator><![CDATA[Mathesh]]></dc:creator><pubDate>Mon, 15 Jun 2026 00:22:14 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6230a03bc4a093f00c8ac11a/a3d5455e-82c5-484f-af53-a83a94bd89e4.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hi, I am <a href="https://mathesh.me/">Mathesh</a>. I have been working on this project for the last few months at <a href="https://ucsc.edu/">UC Santa Cruz</a>, with guidance from Professor Mohsen Lesani, and I wanted to share the current updates and findings from my research. My broader interest is in distributed systems, especially peer-to-peer and edge computing infrastructure, and this project sits at the intersection of autonomous vehicles, wireless communication, and distributed consensus.</p>
<p>The central question I started with was whether autonomous vehicles can coordinate with each other at an unsignalized intersection without depending on traffic lights, cloud control, or a central roadside unit. At first this looks like an AI problem, because the vehicle needs perception, planning, and control. But when I looked closer, the hard part was not only deciding what one vehicle should do; it was deciding how multiple vehicles should agree on a shared action under time pressure.</p>
<p>Humans already do a loose version of this. At a signalized intersection we mostly obey the light, but when there is no signal we coordinate through arrival order, road rules, emergency-vehicle priority, hesitation, eye contact, or small gestures. That informal negotiation is basically a consensus problem. For autonomous vehicles, I wanted to explore whether that negotiation can be replaced with a deterministic vehicle-to-vehicle protocol.</p>
<p>Autonomous vehicles like Tesla and Waymo are already strong at many perception and control tasks, but intersections still create difficult edge cases. In those cases, relying only on probabilistic decisions from isolated agents feels weak. A better direction is to let vehicles communicate their intent, agree on a pass order, and then execute that decision consistently.</p>
<p>There are already real examples showing why this matters. During a San Francisco blackout, reports showed Waymo vehicles blocking roads after traffic signals stopped working. I am not using that as a criticism of one company; I am using it as a reminder that autonomy needs coordination when infrastructure becomes unreliable. You can read one of the reports <a href="https://www.nbcnews.com/tech/tech-news/videos-show-waymo-self-driving-cars-blocking-roads-san-francisco-black-rcna250483">here</a>.</p>
<p>This problem is not limited to vehicles. Any autonomous system where multiple agents share physical space eventually needs mutual decision-making. Warehouse robots, drones, delivery bots, manufacturing robots, and autonomous vehicles can all be locally intelligent, but local planning does not automatically produce safe group behavior. If two agents both decide that their own next move is valid, the system can still deadlock, block a path, or create unsafe motion.</p>
<p>This short clip shows the same coordination failure at a smaller scale. It is not from my vehicle simulation, but it captures the reason this research is interesting beyond V2V. The issue is not only whether one autonomous agent can sense and plan; the harder question is whether a group of autonomous agents can agree on what should happen next when they share the same physical space.</p>
<p><a href="https://youtube.com/shorts/oSNIcwXwAwg?feature=share"><img src="https://img.youtube.com/vi/oSNIcwXwAwg/hqdefault.jpg" alt="" style="display:block;margin:0 auto" /></a></p>
<p><em>Watch the clip: <a href="https://youtube.com/shorts/oSNIcwXwAwg?feature=share">autonomous robots stuck in a coordination conflict</a>.</em></p>
<h2>Why intersections?</h2>
<p>I chose unsignalized intersections because they are a good baseline problem. They are small enough to simulate and reason about, but still hard enough to expose the issues that matter in real deployments: wireless packet loss, changing membership, partial visibility, fairness, priority handling, and real-time decision-making. If a coordination protocol cannot work in this constrained setting, it is unlikely to work in a larger autonomous traffic environment.</p>
<p>There is also a clear safety motivation. The 2023 FARS table below shows 11,843 intersection fatalities in traffic crashes, which makes intersection coordination a concrete safety problem rather than only an academic distributed systems exercise.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6230a03bc4a093f00c8ac11a/45b99f96-c40d-45db-81f5-0c20fafeab2e.png" alt="" style="display:block;margin:0 auto" />

<p><em>Figure 1: 2023 FARS intersection fatality data used to motivate why intersection coordination is a safety-relevant problem.</em></p>
<p>At a high level, every vehicle has local perception. It can observe its own lane, position, speed, acceleration, and nearby vehicles, but local perception is not always enough. At an intersection, the safety of one vehicle depends on what other vehicles intend to do next, so the decision needs to be coordinated rather than purely local.</p>
<p>This is where the pipeline changes. Traditional autonomous driving is often discussed as PCDA: Perception, Collection, Decision, Action. Prior work in this area, including <a href="https://ieeexplore.ieee.org/document/10041971">this IEEE paper</a>, frames the coordination problem as PICA: Perception, Initiative, Consensus, Action. The important addition is the consensus stage, where a vehicle does not simply decide alone; it participates in a protocol that produces a shared decision.</p>
<h2>What is the goal?</h2>
<p>The goal of this project was to evaluate whether a group of autonomous vehicles approaching an unsignalized intersection can exchange enough state to agree on a safe pass order with low latency and low wireless overhead. The output of the system is a pass queue. Once that queue is committed, vehicles execute the crossing order instead of independently guessing who should move first.</p>
<p>Each vehicle proposal contains the fields needed to reason about the next crossing decision:</p>
<ul>
<li>vehicle id</li>
<li>lane id</li>
<li>position</li>
<li>speed</li>
<li>acceleration or deceleration</li>
<li>expected turn direction</li>
<li>priority flag, for example ambulance or police vehicle</li>
</ul>
<p>This sounds straightforward with four vehicles, but it becomes much harder with 20 or 50 vehicles because the communication layer becomes part of the algorithm. In a data center, consensus protocols can assume relatively stable links, controlled membership, and reliable infrastructure. In vehicle-to-vehicle communication, the network is wireless, shared, lossy, and changing while the protocol is running.</p>
<p>That network constraint is the biggest bottleneck. The system needs decisions on a sub-second timeline, but it cannot depend on data-center style infrastructure. Vehicles communicate over broadcast wireless channels, where messages can collide, delivery can be asymmetric, and two vehicles in the same physical intersection may not hear the same set of neighbors. That makes V2V coordination an edge distributed systems problem, not just an autonomous driving feature.</p>
<p>For this project, I used IEEE 802.11p / WAVE as the wireless model. 802.11p is the Wi-Fi-derived vehicular communication standard behind DSRC-style V2V and V2I communication. It is designed for short-range, low-latency exchange between vehicles and roadside units, usually in the 5.9 GHz ITS band, and it supports infrastructure-less broadcast. That matters for this problem because vehicles at an unsignalized intersection should not need to associate with an access point or wait for a cellular round trip before exchanging safety-critical state.</p>
<p>There are newer V2X directions as well. C-V2X introduced cellular sidelink communication, 5G NR-V2X extends that direction for more advanced connected and automated driving use cases, and IEEE 802.11bd is the next-generation evolution of the 802.11p family. These technologies are important, but the goal of this project was not to benchmark radio standards. I chose 802.11p because OMNeT++ and Veins have mature support for it, it gives a realistic lossy broadcast model, and it is a conservative baseline for testing whether the consensus protocol itself can survive wireless contention, packet loss, and partial visibility. If the coordination layer cannot work over this kind of constrained V2V channel, moving to a newer radio will not automatically solve the distributed systems problem.</p>
<h2>Simulation setup</h2>
<p>To test this properly, I built my application logic on top of a simulation stack using OMNeT++, Veins, and SUMO. SUMO handles the mobility side: vehicles entering lanes, slowing down, stopping, turning, and crossing the intersection. OMNeT++ and Veins handle the network side, including WAVE / IEEE 802.11p communication, which is closer to realistic vehicular wireless behavior than an ideal in-memory network.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6230a03bc4a093f00c8ac11a/75fb56c5-685a-4700-b92d-9e50472a3f8f.png" alt="" style="display:block;margin:0 auto" />

<p><em>Figure 2: SUMO mobility simulation with an OpenStreetMap-based road network and vehicle movement around the intersection.</em></p>
<p>The simulation includes:</p>
<ul>
<li>IEEE 802.11p broadcast messaging</li>
<li>channel contention</li>
<li>packet loss</li>
<li>wireless latency</li>
<li>calibrated urban path loss</li>
<li>Nakagami multipath fading</li>
<li>building and vehicle obstacle shadowing</li>
<li>SINR-based packet delivery</li>
<li>OpenStreetMap-based road layouts</li>
</ul>
<p>I collected telemetry from each run so that I could evaluate the protocol as a system rather than only as an algorithm. The telemetry included vehicle position, speed, acceleration, lane, turn intent, message latency, packet delivery, decision latency, total wait time, and sent/received message counts. The point was not just to implement a protocol and assume it works; it was to observe where a data-center-style protocol starts breaking in a fast-moving wireless edge environment.</p>
<h2>Baseline: all vehicles participate in consensus</h2>
<p>The first version was intentionally simple. Every vehicle broadcasts its status, collects the status of other vehicles, and participates in a consensus process. I used Raft as the baseline because it gives a clean structure for leader election, quorum acknowledgement, and committing a decision.</p>
<p>In this setting, the simplified Raft-style flow is:</p>
<ul>
<li>elect a leader</li>
<li>have the leader collect status from participants</li>
<li>compute the next pass order</li>
<li>commit the decision after quorum acknowledgement, where quorum means a majority of participants, roughly 51 percent or <code>(n / 2) + 1</code> votes</li>
<li>broadcast the committed decision back to the group</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6230a03bc4a093f00c8ac11a/07c32933-93dc-4fe2-bc27-1f2b5c0e4cbb.png" alt="" style="display:block;margin:0 auto" />

<p><em>Figure 3: Baseline all-vehicle Raft flow where every vehicle participates in status collection, consensus, and quorum acknowledgement.</em></p>
<p>This was a useful baseline, but it also exposed why directly applying data-center consensus to vehicles is difficult. Raft was designed for a very different environment: relatively stable nodes, reliable links, and membership that does not change every second. Vehicles at an intersection are not data-center nodes, and as the number of vehicles grows, every participant has to send more, receive more, reply more, and wait for more acknowledgements.</p>
<p>The wireless plots were useful while debugging because they made the network behavior visible. Channel utilization showed when vehicles were actively using the shared WAVE channel, and in these runs it stayed close to 50 percent, so the channel was busy but not in an obviously broken state. SINR showed how signal quality changed over time. Together, these plots revealed an important point: the issue was not simply that the channel was always saturated or that SINR was always terrible. Even when the channel did not look completely overloaded, the protocol could still fail because vehicles did not share the same communication neighborhood.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6230a03bc4a093f00c8ac11a/45c67c5e-a3aa-4880-b77e-9242365a0e4a.gif" alt="" style="display:block;margin:0 auto" />

<p><em>Figure 4: Channel utilization over simulation time, showing when vehicles are actively using the shared WAVE wireless channel.</em></p>
<img src="https://cdn.hashnode.com/uploads/covers/6230a03bc4a093f00c8ac11a/af3ae202-be86-44cc-906d-679f2f23bcd0.gif" alt="" style="display:block;margin:0 auto" />

<p><em>Figure 5: SINR variation over time, used to understand signal quality and packet delivery behavior in the wireless model.</em></p>
<p>As density increased, the all-vehicle design became increasingly expensive. More vehicles meant a larger consensus group, more status messages, more replies, and more quorum pressure. The protocol was not only doing more work; it was doing more work on a wireless channel where delivery is already fragile.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6230a03bc4a093f00c8ac11a/29406adb-c09d-4141-8231-033d3a40a59e.png" alt="" style="display:block;margin:0 auto" />

<p><em>Figure 6: Scaling issue in the all-vehicle approach as more vehicles enter the intersection and the consensus group keeps growing.</em></p>
<h2>What went wrong with the vanilla method</h2>
<p>With a small number of vehicles, all-vehicle Raft works reasonably well. The problem appears as vehicle density increases. Wait time grows, and the number of received messages grows aggressively because every vehicle is trying to participate in the same coordination process. At that point the protocol is no longer just computing a pass order; it is also creating wireless load that makes the pass order harder to commit.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6230a03bc4a093f00c8ac11a/6cf14626-0824-41a7-8c00-a134643c1f3e.png" alt="" style="display:block;margin:0 auto" />

<p><em>Figure 7: Wait-time CDFs and message growth for vanilla all-vehicle Raft under increasing vehicle density.</em></p>
<p>The reply delivery rate shows the issue even more clearly. At 4 vehicles, reply delivery is perfect. At 8 vehicles, it is still high. By 16 vehicles, it is already close to the risk region, and at 20 vehicles the median plotted delivery rate drops to 52 percent, with some minimum values going below 40 percent. That is a dangerous region for a quorum-based protocol because Raft needs a majority of votes to commit. Once delivery is hovering around the 50 percent boundary, and sometimes falling well below it, a small amount of loss or asymmetry can stop the leader from collecting enough acknowledgements on time.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6230a03bc4a093f00c8ac11a/bd3b7819-3520-4f5e-b088-42502ddb3957.png" alt="" style="display:block;margin:0 auto" />

<p><em>Figure 8: Reply delivery rate drops as fleet size increases, making quorum-based coordination harder in the all-vehicle design.</em></p>
<p>Adding more participants does not automatically make a wireless consensus decision stronger. If the additional participants increase contention and reduce reply delivery, they make the decision harder to finish. In the all-vehicle design, the system was asking every vehicle to participate in a process that only a smaller set of vehicles actually needed to decide the next crossing order.</p>
<p>The next problem is communication range. The image below shows the basic issue: every vehicle has a limited wireless neighborhood, so broadcast does not mean "everyone in the intersection receives the packet." A vehicle near the center may hear several approaches, while a vehicle farther back in one lane may only hear vehicles on its own side of the intersection. Vehicles on opposite arms may be outside each other's reliable range, and buildings, other vehicles, multipath fading, and road geometry can reduce delivery even when they look physically close.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6230a03bc4a093f00c8ac11a/4602b47a-bbc7-4875-9910-11936d705d09.png" alt="" style="display:block;margin:0 auto" />

<p><em>Figure 9: Wireless communication range creates partial visibility because each vehicle only receives broadcasts from the vehicles inside its effective radio neighborhood.</em></p>
<p>This means each vehicle builds its own local view of the intersection. One vehicle may know about nine nearby proposals, another may know about six, and another may only know about the vehicles directly ahead or behind it. For all-vehicle Raft, that is a serious problem because the leader is trying to collect acknowledgements from a membership set that may not be equally visible to every participant. Some nodes may never receive the request, some replies may not reach the leader, and different vehicles may believe different sets of vehicles are currently active at the intersection.</p>
<p>So the failure is not only "too many messages." The deeper issue is that the communication graph is local and uneven. Consensus assumes a group that can exchange enough messages to agree, but wireless range turns the intersection into overlapping neighborhoods instead of one fully connected group. This is why forcing every vehicle into one consensus group increases delayed replies, missing acknowledgements, and split views. Wireless range is not a minor networking detail here; it is one of the main constraints shaping the protocol.</p>
<h2>Broadcast can hurt, but it can also help</h2>
<p>At first, broadcast looked like the problem. If every vehicle broadcasts and every other vehicle replies, the channel gets crowded, and more vehicles create more contention and packet loss. But broadcast also has a useful property: many vehicles overhear the same information, even when that information does not reach every node directly.</p>
<p>That observation changed the direction of the protocol. Instead of treating broadcast only as a source of congestion, I started using it as a way to spread proposals through gossip. A vehicle that misses a direct proposal may still learn it from another vehicle that heard it, which helps repair partial visibility without requiring every vehicle to become a voting participant in consensus.</p>
<p>The new idea was to use gossip for visibility and selective clustering for agreement. In the current design, selected vehicles are mainly front-of-lane or lane-leader vehicles, because they represent the next movement from each incoming lane. Instead of 20 vehicles participating in Raft, the cluster can stay bounded around four participants for a four-way intersection.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6230a03bc4a093f00c8ac11a/a0342366-aca4-4932-9cbb-4f792dfc85e4.png" alt="" style="display:block;margin:0 auto" />

<p><em>Figure 10: Gossip helps spread missing proposals and lets lane leaders build a more complete view without making every vehicle a Raft participant.</em></p>
<p>If there are not enough lane leaders available, the system can fall back to inviting additional vehicles to participate so that the consensus group still has enough members for fault tolerance. The full fleet still receives the final pass queue, but the expensive decision process is handled by the small group of vehicles that matter most for the immediate crossing decision.</p>
<h2>Final protocol</h2>
<p>The final protocol has three main parts: perception, consensus, and action. Vehicles first generate and broadcast signed proposals, then lane leaders use the gossiped proposal set to run a bounded Raft decision, and finally the committed pass queue is broadcast and gossiped back to the fleet. The key difference from the baseline is that consensus is scoped to a small group instead of being run across every vehicle.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6230a03bc4a093f00c8ac11a/f6b0909e-cb19-4153-9262-176ceb4e2670.png" alt="" style="display:block;margin:0 auto" />

<p><em>Figure 11: Final protocol design combining perception, signed proposal broadcast, gossip, lane-leader Raft consensus, and pass-queue execution.</em></p>
<p>The flow looks like this:</p>
<ol>
<li>Each vehicle reads local perception data from sensors and simulation state.</li>
<li>It creates a signed proposal containing lane, position, speed, acceleration, turn intent, and priority.</li>
<li>Vehicles broadcast proposals over WAVE.</li>
<li>Other vehicles receive proposals and verify signatures.</li>
<li>Missing proposals are spread through gossip.</li>
<li>Lane leaders are selected for the consensus group.</li>
<li>The selected group runs Raft to agree on a pass queue.</li>
<li>The pass queue is broadcast back to the full group.</li>
<li>Vehicles gossip the decision to nodes that may not have heard the first broadcast.</li>
<li>Vehicles execute the pass order.</li>
</ol>
<p>The protocol also includes several engineering pieces that are important in the wireless setting: message compression to reduce load, public/private key authentication for vehicle identity, application-level CSMA/CA to reduce message collisions, fallback cluster invitation when there are too few lane leaders, and batching to improve fairness while reducing repeated computation. The important point is that every vehicle can share state, but only a bounded set of vehicles participates in the core decision.</p>
<h2>How the decision algorithm thinks</h2>
<p>The decision algorithm takes proposals and converts them into a pass queue. It collects vehicle proposals, groups vehicles by lane and movement, selects front candidates, accounts for priority vehicles, batches compatible movements, and commits the next pass queue through Raft. This is deliberately simple: the point of the project was not to invent a complicated traffic scheduler first, but to understand whether the coordination protocol could survive realistic wireless behavior.</p>
<p>Batching matters because a strictly one-by-one pass order can be safe but inefficient. If two vehicles do not conflict, the system should be able to schedule them together. Fairness also matters, because a protocol that always favors one lane due to better wireless conditions is not acceptable. The decision logic has to balance priority, arrival order, and lane progress.</p>
<h2>Results</h2>
<p>The main result is that clustering reduced the size of the expensive consensus group. In all-vehicle mode, the Raft participant count grows with fleet size; with 20 vehicles, all 20 can become part of the decision process. In cluster mode, the Raft participant count stays around four because only front-of-lane vehicles participate.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6230a03bc4a093f00c8ac11a/d26d057c-585c-4d78-85a0-d96a547af074.png" alt="" style="display:block;margin:0 auto" />

<p><em>Figure 12: Cluster mode keeps the Raft participant count bounded while all-vehicle Raft grows with fleet size.</em></p>
<p>This bounded cluster size is what keeps reply delivery stable. In the plotted runs, cluster mode stayed at 100 percent reply delivery while all-vehicle mode dropped as density increased. The wait-time and message-load results show the same pattern: cluster mode reduced wait time as vehicle density increased and reduced the number of messages each vehicle had to receive.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6230a03bc4a093f00c8ac11a/e316f580-87ee-4151-b0dd-386eb9a0f8ec.png" alt="" style="display:block;margin:0 auto" />

<p><em>Figure 13: Cluster mode reduces wait time and received-message load compared with the all-vehicle baseline.</em></p>
<p>At 20 vehicles, all-vehicle mode had around 1616 received messages per vehicle, while cluster mode had around 535. That difference matters because every extra message competes for the same wireless channel. Reducing received-message load is not only a performance optimization; it directly improves the chance that the coordination protocol can finish within the time budget.</p>
<p>Decision latency also became much more stable. In all-vehicle mode, decision latency increased sharply as the number of vehicles increased, while cluster mode stayed much closer to constant. Throughput improved as well, with cluster mode crossing more vehicles per second than all-vehicle mode, especially at larger fleet sizes. I also tested priority vehicle behavior to make sure that a priority vehicle could benefit from the protocol without completely breaking fairness for normal vehicles.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6230a03bc4a093f00c8ac11a/7a215898-11dc-4d3f-9939-7d10c990294c.png" alt="" style="display:block;margin:0 auto" />

<p><em>Figure 14: Cluster mode improves decision latency and throughput while preserving priority-vehicle behavior.</em></p>
<p>Across these experiments, the overall result was about 2x latency reduction, about 3x throughput improvement, controlled received-message growth, bounded Raft participant count, decision latency around 40 to 50 ms in cluster mode, and 100 percent consensus success in the tested crash-fault tolerant scenarios. The most important point is not just that the numbers improved; it is why they improved. The protocol became aligned with the physical network instead of fighting it.</p>
<h2>Takeaways</h2>
<p>The biggest lesson from this project is that distributed systems protocols cannot be moved blindly into wireless mobile environments. Raft is a strong protocol in the environment it was designed for, but an unsignalized intersection has different constraints: membership changes quickly, wireless links are unstable, packet delivery is asymmetric, range creates partial visibility, acknowledgements can create broadcast storms, and decisions have real-time deadlines.</p>
<p>The first version failed because it treated every vehicle as an equal participant in one global consensus group. The improved version worked better because it accepted the physical shape of the system. Vehicles are naturally organized by lane, and the next crossing decision only needs the front candidates. The rest of the vehicles need to learn the decision, but they do not need to participate in the core consensus process.</p>
<p>That is why gossip and clustering fit this problem. Gossip repairs missing information across the wider group, while selective clustering keeps the consensus group small enough to make progress under wireless constraints. The same principle can apply to other autonomous systems too: warehouse robots, drones, humanoid robots, and multi-agent AI systems can all run into the same issue where each agent is locally intelligent but the group still needs a coordination protocol.</p>
<p>The broader question is not only whether each agent can plan. It is whether the group can agree while communication is local, unreliable, and time-sensitive. This is what makes the problem interesting to me as a distributed systems problem rather than only an autonomous driving problem.</p>
<h2>Limitations</h2>
<p>This work currently focuses on crash-fault tolerant behavior. It does not solve Byzantine or malicious vehicle behavior, and it assumes L4+ autonomous vehicles that can understand and execute a committed pass order. It also works best in a homogeneous fleet where vehicles follow the same protocol and trust model, which is easier than a mixed environment where every manufacturer has a different stack, message format, and security model.</p>
<p>There is more work needed on formal safety proofs, larger road layouts, mixed traffic with human drivers, adversarial wireless behavior, and real hardware validation. So I do not see this as the final protocol for autonomous intersections. I see it as a practical experiment showing that if we want autonomous systems to coordinate in the real world, the consensus layer has to be designed with wireless physics in mind.</p>
<h2>Conclusion</h2>
<p>This project started with a simple question about autonomous vehicles, but it became a project about distributed coordination under physical constraints. The first idea was to run consensus among all vehicles. That was clean, but it did not scale well under realistic wireless behavior because the protocol made the communication problem worse as density increased.</p>
<p>The better approach was to combine gossip with selective clustering. Gossip spreads state, clustering keeps the decision group small, Raft provides agreement inside that bounded group, and the final pass queue is broadcast and gossiped back to the fleet. That combination gave lower latency, higher throughput, and more stable behavior as the number of vehicles increased.</p>
<p>For me, the interesting part is that the same principle may apply beyond vehicles. The core question is how to coordinate many autonomous agents when communication is local, unreliable, and time-sensitive. My current answer is that the protocol should not fight the shape of the environment; it should use it.</p>
<p>The next direction for this research is to make the protocol work under stronger Byzantine settings and connect it with a more complete perception stack. That means moving from "vehicles share honest proposals" toward a system that can reason about faulty or malicious behavior, while still staying fast enough for real autonomous coordination.</p>
<p>If you are interested in this work, want to discuss the protocol, or are working on related problems in autonomous systems and distributed coordination, feel free to email me at <a href="mailto:mthiruma@ucsc.edu">mthiruma@ucsc.edu</a> or <a href="mailto:mati02official@gmail.com">mati02official@gmail.com</a>.</p>
]]></content:encoded></item><item><title><![CDATA[Ultimate VLSI Roadmap: Exploring Every Role in Chip Design]]></title><description><![CDATA[Introduction
This blog is designed for students seeking a complete roadmap of chip design in the industry. While I won’t be teaching subjects here, if you have basic knowledge of VLSI and electronics, you can use this blog to gain clarity on the care...]]></description><link>https://blog.quasarcommunity.org/ultimate-vlsi-roadmap-exploring-every-role-in-chip-design</link><guid isPermaLink="true">https://blog.quasarcommunity.org/ultimate-vlsi-roadmap-exploring-every-role-in-chip-design</guid><category><![CDATA[semiconductor roadmap]]></category><category><![CDATA[physical design engineer]]></category><category><![CDATA[RTL design engineer]]></category><category><![CDATA[DFT engineer]]></category><category><![CDATA[Tapeout engineer]]></category><category><![CDATA[Signoff engineer]]></category><category><![CDATA[Electrical Roadmap]]></category><category><![CDATA[Roles in Chip Design]]></category><category><![CDATA[Chip Architect]]></category><category><![CDATA[#vlsi]]></category><category><![CDATA[semiconductor]]></category><category><![CDATA[SOC]]></category><category><![CDATA[vlsi training]]></category><category><![CDATA[#VLSIDesign #FPGA #SemiconductorTech #DigitalCircuits #ChipDesign #VLSILearnings #CircuitDesign #TechInnovation]]></category><category><![CDATA[Chip Design]]></category><dc:creator><![CDATA[Gowrav Bukkapattana Gururaj]]></dc:creator><pubDate>Sat, 29 Mar 2025 02:27:06 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1743214878446/2f0bc80a-8789-4a30-ae6c-e042a74ee6cb.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-introduction">Introduction</h2>
<p>This blog is designed for students seeking a complete roadmap of chip design in the industry. While I won’t be teaching subjects here, if you have basic knowledge of VLSI and electronics, you can use this blog to gain clarity on the career path you should pursue. I will provide detailed insights into various job roles involved in chip design and fabrication, explaining the responsibilities of engineers at different stages. If you aspire to take on one of these roles, I will also give an in-depth explanation at an engineer's daily work, the tools they use, and the skills required to succeed in that role.</p>
<p>Lets start with some high level perspective of chip design roadmap and then I then i will dive into specifics of each role. There are companies that design the chips(Ex: Nvidia, Micron) and then there are companies that manufacture the chips(Ex: TSMC, Global Foundries) and then there are a few companies that that design and fabricate the chips(Ex: Intel, Samsung). Only a few companies can do both design and fabricate but they are actually good at either fabrication or design not both. Here I will give you in detail explanation of just the design roles I will not be explanation about the roles involved during fabrication of the chips.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743211152323/da3d796c-6402-4031-9e0a-95c50349b38f.jpeg" alt class="image--center mx-auto" /></p>
<p>Ok lets start with how or who decides how the capabilities of a chip(Ex: CPU, GPU). The chip architect typically decides an ASIC’s capabilities, guided by marketing and system-level requirements, Marketing determines market needs and goals, But these days it is the competition between the companies to be the leader in the chip industry, To be the best and have the fastest/reliable CPU and GPU, The world is moving towards AI adoption in every sector and jobs, and to accommodate this AI boom companies are building massive data centers to handle the AI traffic, Just in the year 2025 all the countries in total have agreed to spend 1.3 trillion dollars, to push AI infrastructure and train better models of LLM. So what that means for the chip industry is the world needs billions and billions of GPU in the next decades and will a continue to grow for a foreseeable future.</p>
<p>I believe we are at the dawn of the new era of semiconductor world that powers AI. Just like how industrial revolution made man power useless, The new AI era is trying to make human thinking useless, Now AI is trying to replace most of the simple/creative jobs. We will see silicon valleys popping up in every major country in the next decade. So if you are looking to build a career in chip design, you have made a good choice. You will have a bright and busy future. Semiconductor is the new oil of the world. Everyone needs semiconductor chips but one who controls the supply will become the superpower of the world.</p>
<p>Ok based on the goal the companies want to achieve, a chip architect decides on the some basic parameters on die area, power, temp, performance</p>
<hr />
<h1 id="heading-roadmap">Roadmap</h1>
<p>These are the roles and individuals involved in designing advanced semiconductor chips</p>
<ol>
<li><p>Chip architect</p>
</li>
<li><p>RTL design Engineer</p>
</li>
<li><p>RTL verification Engineer</p>
</li>
<li><p>Physical Design Engineer</p>
</li>
<li><p>DFT Engineer</p>
</li>
<li><p>Signoff/Tapeout Engineer</p>
</li>
</ol>
<p>This does not mean only 6 people can design a chip from scratch, In the real world it involves hundreds of Engineers all closely working together to design the chip. There are also other roles like <strong>Pre-silicon validation engineers, Synthesis Engineer, Physical design verification engineer, Post-silicon validation, Characterization engineers, Firmware/Software integration engineers, Packaging engineers, Test engineers, Analog/Mixed-Signal Design Engineer</strong>, <strong>Product engineers</strong> and many more. Who are also involved in the design process, But I will give a detailed explanation only about the roles I have mentioned in the list, Since they are the main engineers who work on the most complex parts of the chip. I will try to explain the other roles in my second blog.</p>
<p>In this blog, I will provide a comprehensive overview of these six roles, delve into the skills required to pursue each career, and explore what their daily responsibilities might look like. Creating and Fabricate the modern CPU/GPU chips stands as one of the most intricate achievements in human ingenuity. The machinery involved in manufacturing the small node 2nm, 3nm and 5nm are some of the most complex machine ever build by human beings. It costs tens of billions to develop and hundreds of millions of dollars to build some of these machines.</p>
<p>Note: This blog focuses solely on the roles involved in designing a chip from RTL to Tapeout. The processes of fabrication and testing that involve hundreds of additional engineers may be discussed separately in a different blog series.</p>
<hr />
<h2 id="heading-1-chip-architect">1. Chip Architect</h2>
<p><strong>Role</strong> : At the very top of the hierarchy, we have the Architect a pivotal figure in chip design. Think of them as the mastermind or planner of the entire process. They're the ones who set the benchmarks for power, performance, and overall goals for the chip. Essentially, they define the parameters, deciding the acceptable range for factors like area, power consumption, and performance. Guided by marketing and system-level requirements they are the bridge between the management and the engineering teams.</p>
<p>Architect works closely with RTL, Physical and verification teams to the goals are feasible and if it can be met under the timeline. They discuss on the trade offs in terms of power, performance, area, and cost making adjustments to the design as needed. They devise a blueprint of all the blocks and determine how these components should be seamlessly integrated. The Architect is involved and consulted throughout various stages of the chip design process. They also Analyze safety mechanism and hardware software STL (software test libraries) tradeoffs and functional safety architecture solutions, methodology, and certification</p>
<p><strong>Day in the life of Architect :</strong></p>
<ul>
<li><p>Architects spend a significant portion of their time in meetings, discussing solution designs with engineering teams, feasibility with product managers and discuss project updates</p>
</li>
<li><p>Creating TRM : Technical Reference Manual, Documentation and reference models for verification team. Without these it would be difficult to coordinate between different teams.</p>
</li>
<li><p>Modify the design document and specifications and Working out the tradeoff's for different implementation decisions or iterations.</p>
</li>
<li><p>Conduct meeting between different teams of RTL, Physical Design and Verification teams to debug the any issue that may arise.</p>
</li>
</ul>
<p><strong>Skills Needed :</strong></p>
<ul>
<li><p><strong>Technical Skills</strong> : Deep understanding of Computer Architecture, Architecture Modeling, Trade-off Analysis, Memory and Interfaces Implementation, ASIC/FPGA/SOC design and implementation, RISC/ARM architecture, Design flow, Digital and Analog Circuit Design</p>
</li>
<li><p><strong>Soft Skills :</strong> Project Management, Communication Skills, Teamwork</p>
</li>
<li><p><strong>Programming Languages</strong> : C , C++, Verilog, VHDL</p>
</li>
</ul>
<p><strong>How to become a Chip Architect :</strong> Most roles in this field demand at least 6+ years of industry experience and a Master's or Ph.D. in Computer Engineering, Electrical Engineering, or Computer Science. Becoming a Chip Architect right after graduation is exceptionally challenging. As this position sits at the top of the hierarchy, it requires substantial experience, a strong foundation in teamwork, and a track record of success to thrive in the role. For recent college graduates, aiming to become a Chip Architect within five years can be a realistic and ambitious goal.</p>
<p>You should focus on projects/thesis on actual architecture, try to publish in architecture conference like ISCA, MICRO, HPCA, ASPLOS. Read papers from those conferences to get an idea of the current state of research/industry. The best way to start is to apply for positions in performance modeling for a architectural team and start building your way up.</p>
<p>Since Power and Performance are at the core of design, Best way is to start there. You should do a few project about Power/Performance to get a clear idea on how your future work might be.</p>
<p>Note: Skills and requirement will change according to the company, But I have mentioned everything I have researched.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743212054682/80b33b8a-b21b-4b03-9b6a-085f38beb64c.jpeg" alt class="image--center mx-auto" /></p>
<p>Pic Courtesy: <a target="_blank" href="http://www.chip-architect.org/news/2000_08_26_IDF.html">Chip-Architect</a></p>
<hr />
<h2 id="heading-2-rtl-design-engineer">2. RTL Design Engineer</h2>
<p><strong>Role :</strong> An RTL (Register Transfer Level) Design Engineer is a specialist responsible for translating the chip architect's high-level blueprint into a synthesizable RTL description using hardware description languages (HDLs). After the chip architect finalizes the high-level design, the RTL engineer breaks it down into manageable modules, writes and optimizes the code, and ensures the design meets performance, power, and timing requirements. They also collaborate with verification teams to develop testbenches and build simulations for validating the design.</p>
<p>In large projects, there may be anywhere from dozens to hundreds of RTL designers working simultaneously on different sections of the chip. Their role involves optimizing and preparing the RTL for synthesis, ensuring it can be converted into a gate-level design that adheres to timing requirements and resource constraints. This phase represents the initial stage where the chip begins to take form. Additionally, RTL designers have to work closely with verification and physical design teams to achieve timing closure and meet all design specifications. That being said, in smaller companies, a designer often takes on dual responsibilities, handling both design and verification tasks.</p>
<p><strong>Day in the life of RTL Design Engineer :</strong></p>
<ul>
<li><p>RTL designers spend most of their time writing and debugging RTL code for specific modules and running simulations to verify that design.</p>
</li>
<li><p>They would Participate in daily meetings to discuss progress, issues, and coordinate with other teams, to ensure a seamless progression of the design through various stages, focusing on discussions around timing, power, and area optimizations.</p>
</li>
<li><p>Analyzing and resolving errors or warnings reported by their tools, while consulting with colleagues to determine whether specific violations can be waived. RTL coding primarily involves connecting and integrating signals between third-party IPs and certain in-house IPs, typically without direct involvement in high-priority internal modules.</p>
</li>
<li><p>Documenting every design decisions, code, and verification processes.</p>
</li>
</ul>
<p><strong>Skills Needed :</strong></p>
<ul>
<li><p><strong>Technical Skills</strong> : EDA Tools (Synopsys, Cadence, Mentor Graphics), Design fundamentals, FPGA/ASIC design flow of simulation and synthesis, TCL scripting, Computer architecture, Static timing Analysis.</p>
</li>
<li><p><strong>Programming Languages</strong> : Verilog, System Verilog, VHDL.</p>
</li>
</ul>
<p><strong>How to become a RTL Design Engineer :</strong> Most roles in this field demand a BS or Master's in Computer Engineering, Electrical Engineering with focus on Digital design and VLSI. With the necessary skills, it is entirely feasible to step into the role of an RTL Design Engineer immediately after graduating.</p>
<p>Students should gain hands on projects, internships, or research labs where you can write and simulate HDL code. Should have a decent exposure to industry EDA tools for Design and Verification. You should work on a few projects related to RTL design to gain a better understanding of whether this is the field you want to pursue.</p>
<p>Participate in competitions/workshops online/offline related to RTL design. With the right skills and projects, becoming an RTL Design Engineer is achievable. However, since this is a highly competitive industry, you need to excel to secure your place. Build a passion for RTL code.</p>
<p>Note: Skills and requirement will change according to the company, But I have mentioned everything I have researched.</p>
<hr />
<h2 id="heading-3-rtl-verification-engineer">3. RTL Verification Engineer</h2>
<p><strong>Role :</strong> An RTL Verification Design Engineer is responsible for ensuring that the Register Transfer Level (RTL) design of a chip functions as intended according to the architect’s blueprint. Their primary role is to verify that the RTL design meets specifications and operates correctly before proceeding to subsequent stages, such as synthesis or physical design. They create simulation environments and test benches to ensure a reliable design before advancing further in the chip design pipeline. They act as the bridge between the RTL Design Engineer and the Physical Design Engineer by analyzing simulation results, debugging issues, and verify fixes and validating that the RTL code functions correctly according to the design specifications, before it undergoes synthesis.</p>
<p>In large companies, the ratio of RTL Design Engineers to RTL Design Verification Engineers typically ranges from 1:2 to 1:3. This means there are often two to three verification engineers for every design engineer. The larger number of verification engineers highlights the effort needed to thoroughly test and validate complex designs to meet performance standards. Usually there will be a synthesis engineer who optimizes the RTL design into a gate-level netlist representation suitable for further design changes. Verification engineer makes sure the chip will perform reliably once fabricated, reducing the risk of costly post-silicon fixes.</p>
<p><strong>Day in the life of RTL Design Verification Engineer :</strong></p>
<ul>
<li><p>RTL verification designers spend most of their time writing or updating testbenches in SystemVerilog or similar languages While using EDA tools to run simulations and verify the design under various scenarios.</p>
</li>
<li><p>They review requirements to create a verification plan with an emphasis on test cases linked to specific requirements, working on developing components like predictors or sequences for a UVM testbench. also running random regressions to analyze the results, and report any identified bugs to the designer. Once the issues are resolved, rerun the regression and proceed to verify other features.</p>
</li>
<li><p>They will participate in meetings to discuss these finding with their team and possible solutions.</p>
</li>
<li><p>Documenting every design decisions, testbench, and verification processes.</p>
</li>
</ul>
<p><strong>Skills Needed :</strong></p>
<ul>
<li><p><strong>Technical Skills</strong> : Design fundamentals, Computer architecture, Verification methodologies, Scripting skills, EDA Tools (Synopsys VCS, Mentor Graphics, Cadence Xcelium), Python/Perl scripting, UVM, FPGA/ASIC design flow of simulation and synthesis.</p>
</li>
<li><p><strong>Programming Languages</strong> : Verilog, SystemVerilog, Python, Perl</p>
</li>
</ul>
<p><strong>How to become a RTL Design verification Engineer :</strong> Most roles in this field demand a BS or Master's in Computer Engineering, Electrical Engineering with focus on Digital design and VLSI. With the necessary skills, it is entirely feasible to step into the role of an RTL Design Verification Engineer immediately after graduating.</p>
<p>Students should engage in hands-on projects and internships focused on writing and simulating Verilog/SystemVerilog code, as well as applying verification methodologies. Having exposure to Industry tools is a plus, Should have a good understanding of ASIC/FPGA design flow. Also should develop a passion for writing testbench and automation scripts.</p>
<p>Always participate in competitions/workshops online/offline related to Design verification, It is always a good chance for you to put use of the skills you learnt to the test, If you have all these skills you have a chance in becoming a RTL design verification Engineer. and build a passion for RTL code.</p>
<p>Note: Skills and requirement will change according to the company, But I have mentioned everything I have researched.</p>
<hr />
<h2 id="heading-4-physical-design-engineer">4. Physical Design Engineer</h2>
<p><strong>Role :</strong> A Physical Design Engineer is responsible for translating the digital design into a manufacturable physical layout while ensuring various constraints are met. Their primary role is to implement Partitioning, Floor planning, Placement, Routing, Clock tree synthesis, Static timing analysis of the various blocks of the chip to ensure that the design meets timing, power, and signal integrity requirements. They work to close timing paths, reduce power consumption, and optimize area usage through iterative design and simulations. Their role begins after the chip architect and RTL design engineers have developed the RTL code and synthesized it into gate level netlist by Synthesis engineer.</p>
<p>They play a critical role in preparing the chip for tapeout, handling design-rule checks (DRC) and layout-versus-schematic (LVS) checks to ensure the design is ready for fabrication. Physical design stage is indeed one of the most time-consuming and critical parts of semiconductor chip design as even minor adjustments can significantly impact performance or yield. Despite advanced EDA tools, much of their work involves iterative manual fine-tuning. Even minor errors can lead to costly production issues. The complexity of physical design is often underestimated and most companies employ Physical Design verification team to check for error and run simulation for various conditions, it requires both a broad strategic view and meticulous attention to detail, making it one of the most challenging stages in chip design.</p>
<p><strong>Day in the life of Physical Design Engineer :</strong></p>
<ul>
<li><p>Physical design Engineers spend most of their time working on floor planning and placement using EDA tools, perform timing analysis and routing to ensure optimal performance.</p>
</li>
<li><p>They would Participate in daily meetings to discuss progress, issues, and coordinate with other teams, focusing on discussions around timing, power, and area optimizations.</p>
</li>
<li><p>Most of Physical design Engineer time would be spend on running simulation and working around bugs in Innovus or ICC and writing TCL code to automatic something to fix a problem that shouldn't happen in the first place.</p>
</li>
</ul>
<p>The months leading up to the Tapeout are always hectic, as last-minute issues from other teams may require them to work overtime to resolve the bugs and run the simulation.</p>
<p><strong>Skills Needed :</strong></p>
<ul>
<li><p><strong>Technical Skills</strong> : EDA Tools( Genus, Innovus, Tempus, Voltus), Physical design flow, Digital design, ASIC/SOC design and implementation, Computer Architecture, Analog/Digital circuit design, PPA tradeoff, Static timing Analysis.</p>
</li>
<li><p><strong>Programming Languages</strong> : Verilog, SystemVerilog, Python, Perl</p>
</li>
</ul>
<p><strong>How to become a Physical Design Engineer :</strong> Most roles in this field demand a Master's or Ph.D in Computer Engineering, Electrical Engineering with focus on Digital design and Computer Architecture. With the necessary skills, it is entirely feasible to step into the role of an Physical design Engineer immediately after graduating but it is highly competitive job that has fewer number of openings So you have to be the best in this field to increase your chances.</p>
<p>Students should gain hands on projects, internships, or research labs where you can write and simulate RTL to GDSII. Learning every step of floorplanning, Pnr, STA. Also should have a decent exposure to industry EDA tools and You should work on a few projects related to Physical design to gain a better understanding of whether this is the field you want to pursue.</p>
<p>Always participate in competitions/workshops online/offline related to Physical design, In my next blog I will share more details about the projects/workshops needed for different roles, You can refer those projects to make even better projects using the skills you develop, It is always a good chance for you to put use of the skills you learnt to the test, If you have all these skills you have a chance in becoming a Physical Design Engineer.</p>
<p>Note: Skills and requirement will change according to the company, But I have mentioned everything I have researched.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743213035430/8f2797df-21d5-4408-83a8-7e464e3dcd49.png" alt class="image--center mx-auto" /></p>
<p>Pic Courtesy : <a target="_blank" href="https://en.wikipedia.org/wiki/Physical_design_%28electronics%29">Wikipedia</a></p>
<hr />
<h2 id="heading-5-dft-engineer">5. DFT Engineer</h2>
<p><strong>Role :</strong> A DFT (Design-for-Test) Engineer is responsible for designs and implementation of test structures into semiconductor circuits. While Physical Design Engineers translate the logical circuit design into a physical layout ensuring the chip meets area, timing, and power constraints, DFT Engineers then incorporate testability features into the design. Their work ensures that once the chip is fabricated, it can be properly tested with automated test equipment (ATE), They are responsible for integrating scan chains, built-in self-test (BIST) structures, and other test methodologies into the chip design. DFT engineers are required before and after fabricating the chip.</p>
<p>Building on the test structures designed by the DFT team, there will be other teams like pre silicon validation team who tests these feature before the tapeout. DFT engineer commonly use BIST/MBIST design methodology to incorporate testing mechanisms directly into the chip so overall test time is reduced. A BIST contains a Pattern Generator that creates test patterns, using pseudo-random algorithms or predefined sequences. The Response Analyzer compresses circuit outputs into a signature to validate functionality. The Control Logic oversees the BIST process, managing test sequences and transitions between test and normal modes. DFT engineer may use TCL script for handling data, So yeah every stage of semiconductor design is complex.</p>
<p><strong>Day in the life of DFT Engineer :</strong></p>
<ul>
<li><p>DFT Engineers spend most of their time working writing and reviewing scripts for scan insertion and BIST for simulation and verification to ensure that test patterns can effectively cover the design and detect potential faults.</p>
</li>
<li><p>They would Participate in daily meetings with verification and test teams to discuss issues and adapting to the constantly evolving design driven by errors and various other factors.</p>
</li>
<li><p>They develop automation scripts to improve testing time and debug the issue found during simulation and working those changes with other teams. Spend hours writing scripts and debugging the errors.</p>
</li>
<li><p>Documenting every DFT methodologies, test coverage metrics and verification processes.</p>
</li>
</ul>
<p><strong>Skills Needed :</strong></p>
<ul>
<li><p><strong>Technical Skills</strong> : Digital circuit design, DFT methodologies(BIST, Fault simulation, scan insertion), EDA Tools(Mentor Graphics) , Writing scripts and debugging, DFT Architecture Selection, Computer Architecture</p>
</li>
<li><p><strong>Programming Languages</strong> : Verilog, Python, Perl, Tcl,</p>
</li>
</ul>
<p><strong>How to become a DFT Engineer :</strong> Most roles in this field demand a Master's or BS in Computer Engineering, Electrical Engineering with focus on Digital design and semiconductor devices. With the necessary skills, it is entirely feasible to step into the role of an DFT Engineer immediately after graduating.</p>
<p>Students should engage in hands-on projects and internships focused on DFT concepts and debugging, as well as applying DFT methodologies. This is a role where you will write a lot of automation scripts and debug the issue, If you are good at this then you should consider a different role, Should have a good understanding of different DFT methodologies. Also develop a passion for scripting and debugging in order to master this role</p>
<p>Always participate in competitions/workshops online/offline related to DFT, It is always a good chance for you to put use of the skills you learnt to the test, If you have all these skills you have a chance in becoming a DFT Engineer. It's always beneficial to network with people who share a similar background or expertise.</p>
<p>Note: Skills and requirement will change according to the company, But I have mentioned everything I have researched.</p>
<hr />
<h2 id="heading-6-signoff-tapeout-engineer">6. Signoff / Tapeout Engineer</h2>
<p><strong>Role :</strong> A Signoff/Tapeout Engineer Engineer is responsible for verifying and finalizing the physical layout of the chip before design is sent for fabrication or as I like to call “ The last line of defense to avoid a costly error during production”. while DFT engineer integrates test structures and after pre-silicon validation engineers have verified the design's functionality. Signoff / Tapeout Engineer work is a crucial final check, before it is sent to the Fab. So this involves ensuring that the layout adheres to design rules, meets timing and power specifications, and is manufacturable. They perform detailed checks and validations (often called “signoff”) before the design is sent for fabrication.</p>
<p>While Signoff and Tapeout engineer role may overlap and often considered as one position in smaller companies but generally Signoff Engineer focuses on DRC/LVS, Antenna checks and meet all manufacturing requirements, Tapeout Engineer focuses on packaging the design while verifying all the design documents and generating signoff reports before sending it to the foundry, They may also act as bridge between the foundry and the engineering team.</p>
<p><strong>Day in the life of Signoff / Tapeout Engineer :</strong></p>
<ul>
<li><p>Signoff / Tapeout Engineers spend most of their time reviewing and updating layout files based on feedback from DRC/LVS reports, and preparing for meetings with the design and verification teams.</p>
</li>
<li><p>They would Collaborate with colleagues to fine-tune the layout, attending design reviews, and documenting changes as they prepare the signoff reports.</p>
</li>
<li><p>Scheduling a meeting with the foundry to review the design, address any potential errors, and discuss corrective measures and ensure there are no major production level errors.</p>
</li>
<li><p>Documenting all changes, metrics and verification processes.</p>
</li>
</ul>
<p><strong>Skills Needed :</strong></p>
<ul>
<li><p><strong>Technical Skills</strong> : Digital circuit design, Verifications techniques, Physical design flow, Computer architecture, ASIC/SOC design and implementation, EDA Tools</p>
</li>
<li><p><strong>Programming Languages</strong> : Tcl, Perl, Python</p>
</li>
</ul>
<p><strong>How to become a Signoff / Tapeout Engineer :</strong> Most roles in this field demand a Master's or BS in Computer Engineering, Electrical Engineering with focus on Digital design and semiconductor devices. With the necessary skills, it is entirely feasible to step into the role of an DFT Engineer immediately after graduating.</p>
<p>Students should engage in hands-on projects and internships focused on Tapeout concepts and debugging. This is a role where you a lot of attention to detail, clear communication skills, If you are good at this then you should consider a different role also Should have a good understanding of layout design, simulation, and physical verification. Also develop a passion for scripting and debugging in order to master this role.</p>
<p>Always participate in competitions/workshops online/offline related to Design flow, It is always a good chance for you to put use of the skills you learnt to the test, If you have all these skills you have a chance in becoming a Signoff / Tapeout Engineer. It's always beneficial to network with people who share a similar background or expertise.</p>
<p>Note: Skills and requirement will change according to the company, But I have mentioned everything I have researched.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743212779841/44d2d4df-2ed0-4507-abdd-2101ead37d1d.png" alt class="image--center mx-auto" /></p>
<p>Pic courtesy : <a target="_blank" href="https://github.com/TinyTapeout/tinytapeout-chip-renders/blob/main/shuttles/tt09/full_gds.png">Tiny Tapeout</a></p>
<hr />
<p><strong>Additional Information :</strong> I can’t write everything I know or have researched about a role in just a few paragraphs, If explained fully it would take nearly 10 pages for each one! If you’re interested in these blogs or would like to discuss a specific position, feel free to contact me for a conversation.</p>
<p>There are many roles involved in the designing of these chips that I haven’t mentioned here. Explaining every role from RTL to Tapeout would make this blog around 150 pages long, which is why I plan to write a series of blogs exploring each role in detail.</p>
<p>Please note that the skills and the day-to-day responsibilities of an engineer I’ve mentioned are general and may vary depending on the company. I’ll leave my contact information here. If you’re interested in discussing a role or need more details about a position you couldn’t find online, feel free to reach out I’ll do my best to help. You can find similar information in Chat GPT or other LLM but the information found in this blog is from professionals who work in the industry.</p>
<p>If you find any mistake in this blog, Kindly send me a mail so I can verify the error and make changes accordingly.</p>
<p>Gmail : gbukkapa@ucsc.edu</p>
<p>LinkedIn : <a target="_blank" href="http://www.linkedin.com/in/gowrav-raj">www.linkedin.com/in/gowrav-raj</a></p>
<hr />
<h2 id="heading-reference">Reference</h2>
<ul>
<li><p><strong>Wikipedia:</strong> Utilized for broad, crowd-sourced information on semiconductor design roles, providing foundational definitions and context.</p>
</li>
<li><p><strong>Careers Page:</strong> Consulted to obtain detailed role-specific expectations and job descriptions based on established industry standards.</p>
</li>
<li><p><strong>Industry Professionals:</strong> Engaged with experienced professionals to gather real-world insights into day-to-day responsibilities.</p>
</li>
<li><p><strong>Personal Experience:</strong> Incorporated practical, hands-on knowledge and industry-relevant details from my own exposure, reflecting my commitment to a career in semiconductor design.</p>
</li>
</ul>
<hr />
]]></content:encoded></item><item><title><![CDATA[Convolutional neural networks(CNN)]]></title><description><![CDATA[What is CNN?
Convolutional neural networks (CNN/ConvNet) are a kind of deep neural network used most frequently to interpret visual data in deep learning. Normally, matrix multiplications come to mind when we think of a neural network, but that is no...]]></description><link>https://blog.quasarcommunity.org/convolutional-neural-networkscnn</link><guid isPermaLink="true">https://blog.quasarcommunity.org/convolutional-neural-networkscnn</guid><category><![CDATA[pooling layer]]></category><category><![CDATA[Flatten layer]]></category><category><![CDATA[Fully connected  layer]]></category><category><![CDATA[convolutional networks]]></category><category><![CDATA[Machine Learning]]></category><dc:creator><![CDATA[Indirakumar S]]></dc:creator><pubDate>Thu, 13 Oct 2022 14:46:41 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1665487884240/2-xMtybt_.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-what-is-cnn">What is CNN?</h1>
<p>Convolutional neural networks (CNN/ConvNet) are a kind of deep neural network used most frequently to interpret visual data in deep learning. Normally, matrix multiplications come to mind when we think of a neural network, but that is not the case with ConvNet. It makes use of a unique method called convolution. Convolution is a mathematical procedure that takes two functions and creates a third function that explains how the form of one is changed by the other in mathematics.</p>
<h1 id="heading-flow-of-cnn">Flow of CNN</h1>
<p>Convolutional Neural Network or CNN is a type of artificial neural network, which is widely used for image/object recognition and classification. Deep Learning thus recognizes objects in an image by using a CNN.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1664719365285/o7vEl0nPs.png" alt="image.png" /></p>
<h1 id="heading-layers">Layers</h1>
<h2 id="heading-convolution">Convolution</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1665486350131/l4hytH413.png" alt="image.png" /></p>
<p>CNN tests these traits everywhere and in every conceivable place because it is uncertain where they will match in a fresh image. We turn it into a filter by computing the match to a feature over the entire picture. Convolutional Neural Networks get their name from the convolutional math we utilise to do this.</p>
<p>Convolution's arithmetic is simple enough for a sixth-grader to understand. Simply multiply each pixel in the feature by the value of the corresponding pixel in the picture to determine how well a feature matches a region of the image. Divide the total number of pixels in the feature by the sum of the replies. When both pixels have a value of 1 or white, 1 <em> 1 equals 1. If they're both black, (-1) </em> (-1) = 1. In either case, a 1 is produced for each matched pixel. Any discrepancy is also a -1. When all the pixels in a feature match, their sum is 1, and their number is divided by the total number of pixels. Similar to this, the response is a -1 if none of the pixels in a feature match the picture patch.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1665486409253/66KEBh1ip.png" alt="image.png" /></p>
<p>We continue this procedure in order to finish our convolution, aligning the feature with each potential picture patch. On the basis of the location of each patch in the picture, we may take the result of each convolution and create a new two-dimensional array from it. The image we started with has been filtered to create this map of matches. It shows the location of the feature inside the picture on a map. Strong matches are shown by values close to 1, strong matches for the photographic negative of our feature are indicated by values close to -1, and no matches of any kind are indicated by values close to zero.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1665486434877/nfRv3EYg9.png" alt="image.png" /></p>
<p>The complete convolution procedure must then be repeated for each of the additional characteristics. A collection of filtered photos, one for each of our filters, is the outcome. Conveying this entire set of convolution processes as a single processing step is practical. This is referred recognised as a convolution layer in CNNs, indicating that further layers will be added to it shortly.</p>
<p>It's understandable how CNNs gained a reputation for being computation hogs. The number of additions, multiplications, and divisions can pile up quickly even though we can draw our CNN on the back of a napkin. They scale linearly with the number of pixels in the picture, the number of pixels in each feature, and the total number of features, to use mathematical terminology. With so many contributing components, it's simple to multiply this issue by millions without breaking a sweat. It should come as no surprise that chip makers are now producing specialist processors in an effort to keep up with CNN's needs.</p>
<h2 id="heading-pooling-layer">Pooling Layer</h2>
<p>The size of the feature maps is reduced by pooling layers. As a result, it lessens the quantity of network computation and the number of parameters that must be learned. The feature map created by a convolution layer's feature pooling layer summarises the features that are present in a certain area. Therefore, instead of precisely positioned features produced by the convolution layer, additional actions are conducted on summarised features. As a result, the model is more resistant to changes in the features' positions in the input picture.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1665487074569/ioQ-91CT0.png" alt="image.png" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1665487130953/Lyg-zlMru.png" alt="image.png" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1665487163682/Ysmn7M3ea.png" alt="image.png" /></p>
<h2 id="heading-flattening-layer">Flattening Layer</h2>
<p>A flatter layer is a pleasantly straightforward phase in the construction of a convolutional neural network.
It entails converting the pooled feature map produced during the pooling process into a one-dimensional vector. Here is an illustration of how this procedure appears:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1665487412193/E7sraD31G.png" alt="image.png" /></p>
<h2 id="heading-fully-connected-layer">Fully connected  layer</h2>
<p>The entire connection stage entails chaining an artificial neural network onto our pre-existing convolutional neural network, as you can probably surmise from the previous part. The artificial neural network's hidden layer is replaced with a particular kind of hidden layer known as a fully connected layer in this stage, which is why it is known as the full connection step. The neurons in a layer that is totally connected are all linked together, as the name suggests. Here is an illustration of an artificial neural network's completely linked layer in visual form:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1665487543108/4gQqTmSI4.png" alt="image.png" /></p>
<p>In a convolutional neural network, the fully connected layer's job is to identify certain characteristics in an image. A specific feature that could be present in a picture is associated with each neuron in the fully connected layer. The likelihood that the feature is present in the picture is represented by the value that the neuron transmits to the following layer. Convolutional neural network and artificial neural network both come to an end at the same time. To put it another way, CNN's artificial neural network predicts what is there in the image that it is attempting to recognise!</p>
<h1 id="heading-see-you-soon">See you soon</h1>
<p>Turn on your notifications and stay in touch with us to learn about new ideas. Share this blog with your friends and family... I will see you in the next blog. Thank you all.</p>
]]></content:encoded></item><item><title><![CDATA[Natural language processing (NLP)]]></title><description><![CDATA[RECAP
Previous blog, We learned about what reinforcement is and the types of approaches it can take. Here, we are going to see a very interesting concept called "NLP".
What is NLP
The field of computer science known as "natural language processing" (...]]></description><link>https://blog.quasarcommunity.org/natural-language-processing-nlp</link><guid isPermaLink="true">https://blog.quasarcommunity.org/natural-language-processing-nlp</guid><category><![CDATA[nlp]]></category><category><![CDATA[segmentation]]></category><category><![CDATA[Tokenization]]></category><category><![CDATA[natural language processing]]></category><category><![CDATA[lemmatization]]></category><dc:creator><![CDATA[Indirakumar S]]></dc:creator><pubDate>Wed, 21 Sep 2022 15:00:50 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1662879380228/Tb9mzkhWD.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-recap">RECAP</h1>
<p><a target="_blank" href="https://blog.quasarcommunity.org/reinforcement-learning">Previous blog</a>, We learned about what reinforcement is and the types of approaches it can take. Here, we are going to see a very interesting concept called "NLP".</p>
<h1 id="heading-what-is-nlp">What is NLP</h1>
<p>The field of computer science known as "natural language processing" (NLP) is more particularly the field of "artificial intelligence" (AI) that is focused on enabling computers to comprehend spoken and written language like that of humans.</p>
<p>Computational linguistics, or the rule-based modelling  of human language, is combined with statistical, machine learning, and deep learning models to form NLP. With the use of these technologies, computers can now interpret human language in the form of text or audio data and fully "understand" what is being said or written, including the speaker's or writer's intentions and mood.</p>
<p>Computer programmes that translate text between languages, reply to spoken commands, and quickly summarise vast amounts of text even in real-time are all powered by NLP. You've probably used NLP through voice-activated GPS devices, digital assistants, speech-to-text dictation programmes, customer service chatbots, and other consumer conveniences. However, the use of NLP in corporate solutions is expanding as a means of streamlining company operations, boosting worker productivity, and streamlining mission-critical business procedures.</p>
<h1 id="heading-techniques">Techniques:</h1>
<h2 id="heading-segmentation">Segmentation</h2>
<p>In order to identify the lengthier processing units made up of one or more words, sentences must first be segmented. To complete this test, you must recognise the boundaries between sentences and words. Due to the punctuation marks that appear at the ends of sentences in the majority of written languages, sentence segmentation is also known as sentence boundary detection, sentence boundary disambiguation, or sentence boundary identification. Choosing how to segment a text into sentences for further processing is the task that is described by all of these words.</p>
<h2 id="heading-tokenisation">Tokenisation</h2>
<p>By identifying the word boundaries the locations where one-word finishes and another begins and tokenizing the text, the sequence of letters in the text is broken up. These words are sometimes referred to as tokens for computational linguistics reasons. Word segmentation, which is sometimes used synonymously with tokenization in written languages where word boundaries are not explicitly defined by the writing system, is another name for tokenization.</p>
<h2 id="heading-stop-word">Stop word</h2>
<p>The terms "stop words," "stop word list," and even "stop list" are frequently used while dealing with text mining software. In general, stop words are a group of frequently used terms in all languages, not only English.</p>
<p>Determiners: Determiners tend to mark nouns in situations when a determiner ordinarily is followed by a noun. Examples: the, a, an, another</p>
<p>Coordinating conjunctions: Coordinating conjunctions join words, phrases, and clauses. 
Examples include: for, an, nor, but, or, yet, and so.</p>
<p>Prepositions: Prepositions convey geographical or temporal relationships. 
Some examples are in, beneath, toward, and before.</p>
<h2 id="heading-stemming">Stemming</h2>
<p>Stemming is a method for eliminating affixes from words to reveal their basic structure. It is analogous to trimming a tree's branches down to the trunk. For instance, the word eat is the root of the verbs eating, eats, and eaten.</p>
<p>Stemming is used by search engines to index words. Because of this, a search engine can only record the stems of a word rather than all of its variations. Stemming does this by reducing the size of the index and improving retrieval precision.</p>
<h2 id="heading-lemmatization">Lemmatization</h2>
<p>Similar to stemming is the lemmatization approach. The final product of lemmatization is referred to as a "lemma," which is a root word as opposed to a root stem, the final product of stemming. We will obtain a valid term with the same meaning after lemmatization.</p>
<p>The WordNetLemmatizer class from NLTK is a simple wrapper for the WordNet corpus. To locate a lemma, this class employs the WordNet CorpusReader class's Morphy() method.</p>
<h2 id="heading-part-of-speech-pos-tagging">Part of Speech (PoS) Tagging</h2>
<p>A phrase is transformed into forms using this method, which results in a list of words and a list of tuples, each of which has a form (word, tag). Whether a word is a noun, adjective, verb, etc., is indicated by the part-of-speech tag in the instance.</p>
<h2 id="heading-named-entity-recognition">Named Entity Recognition</h2>
<p>The term "Named Entity" was initially suggested at the Message Understanding Conference (MUC-6) to recognise names of businesses, individuals, and places in the text, as well as phrases for money, time, and percentages. Since then, NER and Information Extraction (IE) algorithms using text-based data for numerous scientific events have attracted growing interest.</p>
<h1 id="heading-applications">Applications:</h1>
<p><strong>Speech recognition-</strong>The process of accurately translating voice data into text is known as speech recognition, commonly referred to as speech-to-text. Any programme that responds to voice commands or inquiries must use speech recognition. The way individuals speak quickly, slurring words together, with varied emphasis and intonation, in various dialects, and frequently using improper grammar makes speech recognition particularly difficult.</p>
<p><strong>Part of speech tagging-</strong>Grammatical tagging, also known as part of speech tagging, is the technique of identifying the part of speech of a certain word or passage of text based on its use and context. I can construct a paper plane, and make it classified as a part of speech as a noun in 'What makes of automobile do you own?'</p>
<p><strong>Word sense disambiguation-</strong>Choosing a word's meaning from among its potential meanings by utilising the semantic analysis to determine which word makes the most sense in the given circumstance is known as word sense disambiguation. By way of example, word sense disambiguation helps to distinguish between the meanings of the verbs "make," "make the grade," (accomplish), and "make a bet" (place).</p>
<p><strong>Sentiment analysis-</strong>Sentiment analysis looks for intangible elements in the text, such as attitudes, feelings, sarcasm, bewilderment, and mistrust.</p>
<p><strong>Natural language generation-</strong>Natural language generation is the process of converting structured data into human language; it is frequently referred to as the reverse of voice recognition or speech-to-text.</p>
<h1 id="heading-see-you-soon">See you soon</h1>
<p>Turn on your notifications and stay in touch with us to learn about new ideas. Share this blog with your friends and family... I will see you in the next blog. Thank you all.</p>
]]></content:encoded></item><item><title><![CDATA[Python Programming]]></title><description><![CDATA[Do you want to learn a new programming language or if you have your idea and are looking forward to implementing it? Python is here for you.
What is Python?
Python is an interpreted, object-oriented, and high-level programming language. It was create...]]></description><link>https://blog.quasarcommunity.org/python-programming</link><guid isPermaLink="true">https://blog.quasarcommunity.org/python-programming</guid><category><![CDATA[Programming Blogs]]></category><category><![CDATA[Python 3]]></category><category><![CDATA[Programming In Scratch]]></category><category><![CDATA[Welcome to python ]]></category><category><![CDATA[python blog]]></category><dc:creator><![CDATA[Nandhini L]]></dc:creator><pubDate>Fri, 16 Sep 2022 13:29:18 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1663326293114/RMUW_P7VJ.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Do you want to learn a new programming language or if you have your idea and are looking forward to implementing it? Python is here for you.</p>
<h1 id="heading-what-is-python">What is Python?</h1>
<p>Python is an interpreted, object-oriented, and high-level programming language. It was created by Guido van Rossum in 1991. Python is mainly used to boost the speed of software development by providing an easy-to-learn and readable interface.</p>
<h1 id="heading-what-makes-python-so-popular">What makes Python so popular?</h1>
<ul>
<li>It is a free and open platform that anyone can use</li>
<li>Python is user-friendly due to its simple syntax</li>
<li>Large library and assistance</li>
<li>It can be integrated with other languages</li>
</ul>
<h1 id="heading-applications-of-python">Applications of Python</h1>
<p>Python can be used to develop various kinds of applications such as Web applications, Gaming applications, Machine Learning and Artificial Intelligence, Data science and data visualization, Web scraping applications, etc., All these applications can be built at a rapid speed by using Python frameworks.</p>
<h1 id="heading-what-is-a-framework">What is a Framework?</h1>
<p>A framework is an arrangement that gives some basic structure around which you add your code to have a greater functionality of that system. As frameworks are free and open source it allows you to create an application in a standard way.</p>
<p>Below are some of the frameworks used for various applications.</p>
<ul>
<li>Web applications - Django, CherryPy, TurboGears,  Flask, Web2Py, Bottle</li>
<li>Gaming applications - Pygame, Pyglet, PyKyra, Kivy, Panda3D</li>
<li>Machine Learning - Numpy, Scipy, Scikit-learn, TensorFlow, Keras, PyTorch, Pandas</li>
<li>GUI applications - PyQT, Python Tkinter, PyGTK,  PySide2</li>
</ul>
<p><strong>Before stepping into the learning process, let’s see how to install Python on your machine.</strong></p>
<h1 id="heading-installation-of-python-in-windows">Installation of Python in Windows</h1>
<p><strong>Step 1:</strong> Go to the website python.org, click on the Downloads tab and click on windows.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1663245324354/0B9kgECHx.png" alt="1.png" /></p>
<p><strong>Step 2</strong>: Select the version of python you want to install based on your system configuration. </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1663245469890/WUByuZ1ZS.png" alt="image5.png" />
Then download the executable (.exe) file.</p>
<p><strong>Step 3:</strong> Once downloaded, run the executable file to install python. If you want to customize the location select Customize installation otherwise click on Install Now. Make sure that you select the checkbox at the bottom to add python to PATH.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1663245713855/T_12NNbiE.jpg" alt="ins.jpg" /></p>
<p><strong>Step 4:</strong> Once the installation process is completed the below popup will appear.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1663245849236/ihE6FxHMz.jpg" alt="setup.jpg" /></p>
<p>Now, Python is successfully installed. </p>
<p><strong>Step 5:</strong> To ensure that Python is installed in your system, Follow the below steps</p>
<ul>
<li>Open command prompt</li>
<li>Type 'python' and hit enter </li>
<li>This command will give the version of Python installed</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1663246211760/4HCyl8aap.png" alt="last.png" /></p>
<p>If you can see the Python version you installed, Python has been successfully installed and you are ready to use it.</p>
<h1 id="heading-writing-your-first-python-program">Writing your first python program</h1>
<p>To write your first program in Python, Go to start and search for Python. You can see Python IDLE. As you open it, a Python shell will appear. </p>
<p>Then do the following steps</p>
<ul>
<li>Go to File&gt;New file</li>
<li>Type the code - print(“Hello World!”)</li>
<li>Save the file by adding the extension as .py</li>
<li>To run the code go to Run&gt;Run module or directly press F5 key</li>
<li>The output will be displayed in the Python shell</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1663259515301/WqVGBPkM_.PNG" alt="Capture.PNG" />
Now we have successfully printed “Hello World!” using Python.</p>
]]></content:encoded></item><item><title><![CDATA[How to create Chrome extension]]></title><description><![CDATA[Introduction
A chrome extension is a program that is installed in the Chrome browser that enhances the functionality of the browser. You can build one easily using web technologies like HTML, CSS, and JavaScript.
Creating a chrome extension is simila...]]></description><link>https://blog.quasarcommunity.org/how-to-create-chrome-extension</link><guid isPermaLink="true">https://blog.quasarcommunity.org/how-to-create-chrome-extension</guid><category><![CDATA[chrome extension]]></category><category><![CDATA[Chrome]]></category><dc:creator><![CDATA[Vasanth kumar k]]></dc:creator><pubDate>Mon, 05 Sep 2022 16:08:15 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1662389814676/DQ0gf4biz.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-introduction">Introduction</h1>
<p>A chrome extension is a program that is installed in the Chrome browser that enhances the functionality of the browser. You can build one easily using web technologies like HTML, CSS, and JavaScript.</p>
<p>Creating a chrome extension is similar to creating a web application, but it requires a manifest.json file which we will discuss in the last section of this post.</p>
<h1 id="heading-what-will-our-chrome-extension-look-like">What Will our Chrome Extension Look Like?</h1>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1662388518905/ieZ4Wp1qp.png" alt="Screenshot (93).png" />
As you can see, the above chrome extension will create QR code for website where you clicked the extension.  We will be looking into how to create this extension in this blog post.</p>
<p>Here, we will be using the <a target="_blank" href="https://api.qrserver.com/v1/create-qr-code/?size=150x150&amp;data=">https://api.qrserver.com/v1/create-qr-code/?size=150x150&amp;data=</a> API in the order to create QR code.</p>
<p>The complete source code of this project can be found on <a target="_blank" href="https://github.com/vasanthkumar7/QRCODE_Chrome_extenstion">GitHub</a>.</p>
<h1 id="heading-how-to-create-a-chrome-extension">How to Create a Chrome Extension</h1>
<p>First of all, we need to create an empty folder where we will add our HTML, CSS, and JavaScript files.</p>
<p>Inside the folder, let’s create an index.html file with this HTML boilerplate code:</p>
<pre><code><span class="hljs-operator">&lt;</span>html lang<span class="hljs-operator">=</span><span class="hljs-string">"en"</span><span class="hljs-operator">&gt;</span>
<span class="hljs-operator">&lt;</span>head<span class="hljs-operator">&gt;</span>


<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>head<span class="hljs-operator">&gt;</span>
<span class="hljs-operator">&lt;</span>body<span class="hljs-operator">&gt;</span>
    <span class="hljs-operator">&lt;</span>img src<span class="hljs-operator">=</span><span class="hljs-string">"example"</span> id<span class="hljs-operator">=</span><span class="hljs-string">"qrcode"</span><span class="hljs-operator">&gt;</span>
  <span class="hljs-operator">&lt;</span>script src<span class="hljs-operator">=</span><span class="hljs-string">"Content.js"</span><span class="hljs-operator">&gt;</span><span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>script<span class="hljs-operator">&gt;</span>
<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>body<span class="hljs-operator">&gt;</span>
<span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span>html<span class="hljs-operator">&gt;</span>
</code></pre><p>In the above code it will display QR code of 150px  X 150px.   In the image tag QR code will be displayed.</p>
<p>Now, since the table has been displayed, we need to work on writing JavaScript in order to fetch data from the API.</p>
<p>Let's create a script.js file and add the following code:</p>
<pre><code>chrome.tabs.getSelected(null, <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">tab</span>) </span>{
    document.getElementById(<span class="hljs-string">"qrcode"</span>).src <span class="hljs-operator">=</span> <span class="hljs-string">"https://api.qrserver.com/v1/create-qr-code/?size=150x150&amp;data="</span><span class="hljs-operator">+</span>tab.url;
});
</code></pre><p>Now, let’s break down the above code:</p>
<ul>
<li>Here we are using the API to create a QR code</li>
<li>Then it will display it in the Image tag which as 'qrcode' as ID</li>
</ul>
<p>If we check the browser, we will be able to see the following result.
<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1662388518905/ieZ4Wp1qp.png" alt="Screenshot (93).png" /></p>
<h1 id="heading-manifestjson-file">Manifest.json File</h1>
<p>As we discussed earlier, building a Chrome extension is similar to building any web application. The only difference is that the Chrome extension requires a manifest.json file where we keep all the configurations.</p>
<p>The manifest.json file contains all the necessary information required to build the Chrome extension. It is the first file the extension checks and everything is loaded from this single file.</p>
<p>Now, let's create a manifest.json file in the root folder and add the following code:</p>
<pre><code>{
    <span class="hljs-attr">"name"</span>: <span class="hljs-string">"VK QR"</span>,
    <span class="hljs-attr">"version"</span>: <span class="hljs-string">"1.0"</span>,
    <span class="hljs-attr">"description"</span>: <span class="hljs-string">"demo"</span>,
    <span class="hljs-attr">"manifest_version"</span>:<span class="hljs-number">2</span>,
    <span class="hljs-attr">"browser_action"</span>:{
        <span class="hljs-attr">"default_popup"</span>:<span class="hljs-string">"demo.html"</span>,
        <span class="hljs-attr">"default_icon"</span>:<span class="hljs-string">"logo.png"</span>
    },
    <span class="hljs-attr">"background"</span>: {
        <span class="hljs-attr">"service_worker"</span>: <span class="hljs-string">"Content.js"</span>
      },
    <span class="hljs-attr">"action"</span>:{}
    ,
    <span class="hljs-attr">"permissions"</span>: [
        <span class="hljs-string">"tabs"</span>,
        <span class="hljs-string">"activeTab"</span>,
        <span class="hljs-string">"scripting"</span>,
        <span class="hljs-string">"&lt;all_urls&gt;"</span>
    ]
}
</code></pre><p>Our manifest.json file contains the value of name, version, description, manifest_version (2 in this case, which is the latest manifest version), author, and action fields. In the action field, there's the value for default_popup which contains the path to the HTML file which is index.html in this example.</p>
<p>You can have a look here to see all configurations of a manifest.json file.</p>
<p>Now, since we've also added the manifest.json file we are ready to add this project as an extension in our Chrome browser.</p>
<p>For that, we need to go to Select More Tools and then choose Extensions from the browser menu as shown in the picture below:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1662389444197/_sYcNZpwu.png" alt="Untitled-design--1-.png" />
After choosing Extensions, it redirects to the extensions page in Chrome. Make sure to enable the Developer mode here.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1662389475245/jZk-Yc1we.png" alt="Untitled-design--1--1.png" />
Once that's done, you need to click the Load unpacked button which will allow us to load our project in the Chrome extension store.</p>
<p>Now, the extension is available in our Chrome extension store. You can also pin the extension in the browser as shown in the gif below:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1662389495179/OvAQrUZit.gif" alt="pin_extension.gif" /></p>
<h1 id="heading-conclusion">Conclusion</h1>
<p>If you have some HTML, CSS, and JavaScript knowledge, you can easily build Chrome extensions. I hope after reading this blog post, you will create some cool extensions.</p>
]]></content:encoded></item><item><title><![CDATA[R programming - Data interfaces]]></title><description><![CDATA[R can read and write into various file formats like CSV, Excel, XML, etc. R allows its users to work smoothly with the systems directories with the help of some pre-defined functions that take the path of the directory as the argument or return the p...]]></description><link>https://blog.quasarcommunity.org/r-programming-data-interfaces</link><guid isPermaLink="true">https://blog.quasarcommunity.org/r-programming-data-interfaces</guid><category><![CDATA[Data Science]]></category><category><![CDATA[R Language]]></category><dc:creator><![CDATA[Hitendra K]]></dc:creator><pubDate>Mon, 22 Aug 2022 15:02:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1660995873117/pZQtFn_5-.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>R can read and write into various file formats like CSV, Excel, XML, etc. R allows its users to work smoothly with the systems directories with the help of some pre-defined functions that take the path of the directory as the argument or return the path of the current directory that the user is working on. </p>
<h3 id="heading-csv-file">CSV File :</h3>
<p>A Comma-Separated Values (CSV) file is a plain text file containing a data list. These files are often used for the exchange of data between different applications. For example, databases and contact managers primarily support CSV files.</p>
<p>These files can sometimes be called character-separated values or comma-delimited files. They often use the comma character to separate data, but occasionally use other characters such as semicolons. The idea is that we can export the complex data from one application to a CSV file, and then import the data in that CSV file to another application.</p>
<p><strong>Creation</strong>
A text file in which a comma separates the value in a column is known as a CSV file. Let's start by creating a CSV file with the help of the data, which is mentioned below by saving with the .csv extension using the save As All files(<em>.</em>) option in the notepad.</p>
<p><strong>Reading</strong>
R has a rich set of functions. R provides the read.csv() function, which allows us to read a CSV file available in our current working directory. This function takes the file name as an input and returns all the records present on it.</p>
<p><strong><em>Syntax</em></strong></p>
<p><em>read.csv(filename, header = FALSE, sep = "")</em></p>
<p>Let's use our File.csv file to read records from it using the read.csv() function.</p>
<pre><code>Example

data <span class="hljs-operator">&lt;</span><span class="hljs-operator">-</span> read.csv(<span class="hljs-string">"File.csv"</span>)  
print(data)
</code></pre><p><strong>Analysing</strong></p>
<p>By default, the read.csv() function gives the output as a data frame. This can be easily checked as follows. Also, we can check the number of columns and rows.</p>
<h3 id="heading-excel-file">Excel File :</h3>
<p>The xlsx is a file extension of a spreadsheet file format that was created by Microsoft to work with Microsoft Excel. In the present era, Microsoft Excel is a widely used spreadsheet program that stores data in the .xls or .xlsx format. R allows us to read data directly from these files by providing some excel specific packages.</p>
<p><strong>Reading</strong></p>
<p>Like the CSV file, we can read data from an excel file. R provides the read.xlsx() function, which takes two arguments as input, i.e., file name and index of the sheet. This function returns the excel data in the form of a data frame in the R environment. There is the following syntax of the read.xlsx() function:</p>
<p><strong><em>Syntax</em></strong></p>
<p><em>read.xlsx(file_name,sheet_index)</em></p>
<h3 id="heading-r-binary-files">R - Binary Files :</h3>
<p>A binary file is a file that contains information stored only in form of bits and bytes. (0’s and 1’s). They are not humanly readable as the bytes in them translate to characters and symbols which contain many other non-printable characters. Attempting to read a binary file using any text editor will show characters like Ø and ð.</p>
<p>Sometimes, the data generated by other programs are required to be processed by R as a binary file. Also, R is required to create binary files which can be shared with other programs.</p>
<p>R has two functions WriteBin() and readBin() to create and read binary files.</p>
<p><strong><em>Syntax</em></strong></p>
<p><em>writeBin(object, con)</em></p>
<p><em>readBin(con, what, n )</em></p>
<p>Following is the description of the parameters used −</p>
<ul>
<li><p>con is the connection object to read or write the binary file.</p>
</li>
<li><p>the object is the binary file in which it is written.</p>
</li>
<li><p>what is the mode like character, integer, etc. representing the bytes to be read?</p>
</li>
<li><p>n is the number of bytes to read from the binary file.</p>
</li>
</ul>
<h3 id="heading-r-xml-files">R - XML Files :</h3>
<p>XML is a file format that shares both the file format and the data on the World Wide Web, intranets, and elsewhere using standard ASCII text. It stands for Extensible Markup Language (XML). Similar to HTML it contains markup tags. But unlike HTML where the markup tag describes the structure of the page, in XML the markup tags describe the meaning of the data contained in the file.</p>
<p>You can read an XML file in R using the "XML" package. This package can be installed using the following command.</p>
<p><em>install.packages("XML")</em></p>
<p><strong>Reading XML File</strong></p>
<p>The XML file is read by R using the function xmlParse(). It is stored as a list in R.</p>
<h3 id="heading-r-json-files">R - JSON Files :</h3>
<p>JSON file stores data as text in a human-readable format. JSON stands for JavaScript Object Notation. R can read JSON files using the R-JSON package.</p>
<p><strong>Install rjson Package</strong>
In the R console, you can issue the following command to install the R-JSON package.</p>
<p><em>install.packages("rjson")</em></p>
<h3 id="heading-r-web-data">R - Web Data :</h3>
<p>Using R programs, we can programmatically extract specific data from such websites. Some packages in R which are used to scrap data from the web are − "RCurl",XML+
33
", and "stringr". They are used to connect to the URLs+ required links for the files and download them to the local environment.</p>
<p>We will use the function getHTMLLinks---+() to gather the URLs of the files. Then we will use the function download.file() to save the files to the local system. As we will be applying the same code again and again for multiple files, we will create a function to be called multiple times. The filenames are passed as parameters in form of an R list object to this function.</p>
<p>This is about R programming. We will look into projects based on R in future blogs. Follow us for more interesting blogs. Subscribe to our newsletter.</p>
]]></content:encoded></item><item><title><![CDATA[Basic Array Methods in Javascript]]></title><description><![CDATA[In a previous blog, we have seen the essential introduction to array on how to create and access array elements and in this blog, we are going to explore basic array methods in javascript.
1. Length Property:
Before moving to methods in the array, we...]]></description><link>https://blog.quasarcommunity.org/basic-array-methods-in-javascript</link><guid isPermaLink="true">https://blog.quasarcommunity.org/basic-array-methods-in-javascript</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[array]]></category><category><![CDATA[array methods]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[webdev]]></category><dc:creator><![CDATA[Anusha V]]></dc:creator><pubDate>Sun, 21 Aug 2022 16:08:44 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1661091362125/SZ24h0i1K.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In a previous blog, we have seen the essential introduction to array on how to create and access array elements and in this blog, we are going to explore basic array methods in javascript.</p>
<h1 id="heading-1-length-property">1. Length Property:</h1>
<p>Before moving to methods in the array, we have a property to find the length of the array(i.e., how many elements it consists of).</p>
<p>Let us understand by an example, </p>
<pre><code>let arr <span class="hljs-operator">=</span> [<span class="hljs-string">"Apple"</span>, <span class="hljs-string">"Orange"</span>, <span class="hljs-string">"Banana"</span>];
console.log(arr.<span class="hljs-built_in">length</span>); <span class="hljs-comment">//3</span>
</code></pre><p>In the above example, we are creating an array with 3 elements, and with the help of the length property we can find out how many elements are there in the array. In this example, we have 3 elements inside the array and we got that as an output.</p>
<h1 id="heading-2-tostring">2. tostring():</h1>
<p>tostring() function is used to convert the array into a string with separated by a comma.</p>
<p><strong>Example:</strong></p>
<pre><code>let arr <span class="hljs-operator">=</span> [<span class="hljs-string">"Apple"</span>, <span class="hljs-string">"Orange"</span>, <span class="hljs-string">"Banana"</span>];
console.log(arr.toString()); <span class="hljs-comment">//Apple,Orange,Banana</span>
</code></pre><h1 id="heading-3-join">3. join():</h1>
<p>join() function is also used to convert the array into a string. By default in toString() it will use the comma separator to separate the string elements while converting it. Likewise, in join() the change is, that we will specify the separator as a parameter inside the join() function within double quotes(i.e., which separator we are going to use).</p>
<p>Let us understand by an example,</p>
<pre><code>let arr <span class="hljs-operator">=</span> [<span class="hljs-string">"Apple"</span>, <span class="hljs-string">"Orange"</span>, <span class="hljs-string">"Banana"</span>];
console.log(arr.join(<span class="hljs-string">"|"</span>));
</code></pre><p>In the above example, we are converting an array into a string and then we are joining the string elements using the separator(i.e., | ). We can use any separator as a parameter to join the string elements.</p>
<h1 id="heading-4-how-to-add-and-remove-an-element">4. How to add and remove an element:</h1>
<p>To add and remove elements from the array we will use the push() function and pop() function.</p>
<h2 id="heading-push-method">push() method:</h2>
<p>To add an element to an array, we use the push() function.</p>
<p>Let us understand by an example,</p>
<pre><code>let arr <span class="hljs-operator">=</span> [<span class="hljs-string">"Apple"</span>, <span class="hljs-string">"Orange"</span>, <span class="hljs-string">"Banana"</span>];
arr.<span class="hljs-built_in">push</span>(<span class="hljs-string">"Grapes"</span>);
console.log(arr); <span class="hljs-comment">//[ 'Apple', 'Orange', 'Banana', 'Grapes' ]</span>
</code></pre><p>In the above example, the push() function will add the new element at the end of the array and make the changes in the existing array and display the output.</p>
<h2 id="heading-pop-method">pop() method:</h2>
<p>To remove an element from the array, we use the pop() function.</p>
<p>Let us understand by an example,</p>
<pre><code>let arr <span class="hljs-operator">=</span> [<span class="hljs-string">"Apple"</span>, <span class="hljs-string">"Orange"</span>, <span class="hljs-string">"Banana"</span>];
arr.<span class="hljs-built_in">pop</span>();
console.log(arr); <span class="hljs-comment">//[ 'Apple', 'Orange', 'Banana']</span>
</code></pre><p>In the above example, pop() will remove the last element from the array and make the changes in the existing array and display the output.</p>
<h1 id="heading-5-shift-and-unshift">5. shift() and unshift():</h1>
<p>shift() and unshift() function is used to add and remove array elements from the beginning of the array.</p>
<h2 id="heading-unshift-method">unshift() method:</h2>
<p>To add an element at the beginning of the array, we use the unshift() method.</p>
<p><strong>Example:</strong></p>
<pre><code>let arr <span class="hljs-operator">=</span> [<span class="hljs-string">"Apple"</span>, <span class="hljs-string">"Orange"</span>, <span class="hljs-string">"Banana"</span>];
arr.unshift(<span class="hljs-string">"Grapes"</span>);
console.log(arr); <span class="hljs-comment">//[ 'Grapes', 'Apple', 'Orange', 'Banana' ]</span>
</code></pre><h2 id="heading-shift-method">shift() method:</h2>
<p>To remove an element at the beginning of the array, we use the shift() method.</p>
<p><strong>Example:</strong></p>
<pre><code>let arr <span class="hljs-operator">=</span> [<span class="hljs-string">"Apple"</span>, <span class="hljs-string">"Orange"</span>, <span class="hljs-string">"Banana"</span>];
arr.shift();
console.log(arr); <span class="hljs-comment">//[ 'Orange', 'Banana' ]</span>
</code></pre><h1 id="heading-6-slice">6. slice():</h1>
<p>The Slice() method is used to slice the array of elements. It has two parameters, are</p>
<ul>
<li>The first parameter is the starting index value.</li>
<li>The second parameter is the ending index value.</li>
</ul>
<p><strong>Example:</strong></p>
<pre><code>let arr <span class="hljs-operator">=</span> [<span class="hljs-string">"Apple"</span>, <span class="hljs-string">"Orange"</span>, <span class="hljs-string">"Banana"</span>, <span class="hljs-string">"Grapes"</span>];
output_arr <span class="hljs-operator">=</span> arr.slice(<span class="hljs-number">1</span>,<span class="hljs-number">3</span>);
console.log(output_arr); <span class="hljs-comment">//[ 'Orange', 'Banana' ]</span>
</code></pre><p>In the above example, the slice() method will slice the array of elements. Array elements are sliced by their index value. The first parameter index value is included and the second parameter index value is excluded(i.e., it represents the index value to slice the array).</p>
<h1 id="heading-7-splice">7. splice():</h1>
<p>The splice() method is also used to replace and remove the element from an array and display that array(i.e., it will not create a separate array for output).</p>
<p>The splice() method has three parameters are</p>
<ul>
<li><p>The First parameter is the starting index value.</p>
</li>
<li><p>The second parameter is the count of the element from the start of the index value.</p>
</li>
<li><p>The third parameter is the value we need to replace it with.</p>
</li>
</ul>
<p>Example:</p>
<pre><code>let arr <span class="hljs-operator">=</span> [<span class="hljs-string">"Apple"</span>, <span class="hljs-string">"Orange"</span>, <span class="hljs-string">"Banana"</span>, <span class="hljs-string">"Grapes"</span>];
arr.splice(<span class="hljs-number">1</span>,<span class="hljs-number">2</span>,<span class="hljs-string">"Watermelon"</span>);
console.log(arr); <span class="hljs-comment">//[ 'Apple', 'Watermelon', 'Grapes' ]</span>
</code></pre><p>In the above example, we are starting with the index value 1 and we are replacing watermelon with the elements that count two elements from the index value 1.</p>
<h1 id="heading-8-concat">8. concat():</h1>
<p>concat() method will concat two arrays.</p>
<p><strong>Example:</strong></p>
<pre><code>let X = ["Apple", "Orange", "Banana", "Grapes"];
let Y = ["Watermelon", "pineapple", "strawberry"];
console.log(X.concat(Y)); //[ <span class="hljs-string">'Apple'</span>,  <span class="hljs-string">'Orange'</span>, <span class="hljs-string">'Banana'</span>, <span class="hljs-string">'Grapes'</span>,  <span class="hljs-string">'Watermelon'</span> <span class="hljs-string">'pineapple'</span>,  <span class="hljs-string">'strawberry'</span> ]
</code></pre><p>In the above example, we are concatenating two arrays named X and Y. </p>
<p>In the next blog, we will explore sorting and searching methods in the array.</p>
]]></content:encoded></item><item><title><![CDATA[Reinforcement Learning]]></title><description><![CDATA[Recap
Previous blog, We learned about KNN(K-Nearest Neighbor). KNN is a classification algorithm based on classifying data points by determining similarity among existing data points. Now we are going to learn about self-learning algorithms. 
Reinfor...]]></description><link>https://blog.quasarcommunity.org/reinforcement-learning</link><guid isPermaLink="true">https://blog.quasarcommunity.org/reinforcement-learning</guid><category><![CDATA[Reinforcement Learning]]></category><category><![CDATA[Machine Learning]]></category><category><![CDATA[algorithms]]></category><category><![CDATA[Learning Journey]]></category><category><![CDATA[Python]]></category><dc:creator><![CDATA[Indirakumar S]]></dc:creator><pubDate>Wed, 17 Aug 2022 14:53:08 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1660743537396/1fmc8EfN5.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-recap">Recap</h1>
<p><a target="_blank" href="https://blog.quasarcommunity.org/k-nearest-neighborknn-algorithm">Previous blog</a>, We learned about KNN(K-Nearest Neighbor). KNN is a classification algorithm based on classifying data points by determining similarity among existing data points. Now we are going to learn about self-learning algorithms. </p>
<h1 id="heading-reinforcement-learning">Reinforcement Learning</h1>
<p>As a machine learning technique, reinforcement learning concerns the appropriate actions that software agents should do in a given environment. The deep learning method includes reinforcement learning, which enables you to maximise a percentage of the cumulative reward.</p>
<h1 id="heading-algorithm">Algorithm</h1>
<p>Three approaches to implementing a Reinforcement Learning algorithm:</p>
<ol>
<li>Value-Based</li>
<li>Policy-Based</li>
<li>Model Based</li>
</ol>
<p><strong>1. Value-Based:</strong></p>
<p>   Developers should aim to maximize the value function V in a value-based reinforcement learning strategy (s). With this approach, the agency anticipates that the current policy-covered states will eventually return.</p>
<p><strong>2. Policy-Based:</strong></p>
<p>  In a policy-based RL technique, developers work to create a policy where every action you do now helps you reap the most rewards tomorrow.</p>
<p>Two policy-Based methods:-</p>
<p>Deterministic=&gt; The policy π results in the same action for any state.</p>
<p>Stochastic=&gt; The probability of any action is defined.</p>
<p><strong>3. Model-Based:</strong></p>
<p>  For each environment in this Reinforcement Learning technique, a virtual model must be built. The agent gains the necessary skills to function in that environment.</p>
<h1 id="heading-types-of-reinforcement-learning">Types of Reinforcement Learning</h1>
<p><strong>Positive Reinforcement: </strong></p>
<p>  It is described as an occurrence that results from a particular action. It strengthens and repeats the behaviour more frequently, which has a favourable effect on the agent's action.</p>
<p>This kind of reinforcement enables you to achieve your full potential and maintain change over a longer time frame. However, excessive reinforcement may result in state over-optimization, which might have an impact on the outcomes.</p>
<p><strong>Negative Reinforcement:</strong></p>
<p>   A negative condition that should have been halted or avoided might reinforce a behaviour. This is known as "negative reinforcement." You can use it to specify the minimum performance standard. The disadvantage of this approach is that it just offers enough to satisfy the minimum behaviour.</p>
<h1 id="heading-markov-decision-process">Markov Decision Process</h1>
<p>The reinforcement learning issues are formalised using the Markov Decision Process, or MDP. If the environment is entirely observable, a Markov Process can be used to model the environment's dynamic. In MDP, the agent continuously engages with the environment and takes action. The environment reacts to each action and creates a new state.</p>
<p>The RL environment is described using MDP, and practically all RL problems may be formalised using MDP.</p>
<p>MDP has 4 parameters:</p>
<ul>
<li>set of finite States S</li>
<li>set of finite Actions A</li>
<li>Rewards are obtained following the change from state S to state S' as a result of action a.</li>
<li>Probability Pa</li>
</ul>
<h1 id="heading-q-learning">Q-Learning</h1>
<p>A well-liked model-free reinforcement learning algorithm built on the Bellman equation is Q-learning.
Learning the policy that can tell the agent what actions to perform to maximize the reward under what conditions is the basic goal of Q-learning. It is an off-policy RL that looks for the best course of action given the circumstances. In Q-learning, the agent's objective is to maximize Q's value. The Bellman equation can be used to determine the worth of Q-learning. Consider the following Bellman equation:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1660743177265/ls_-7iF5m.png" alt="reinforcement-learning-q-learning-explanation.png" /></p>
<p><strong>Process:</strong></p>
<p>  Temporal difference learning is accomplished using the Off policy RL algorithm Q-learning. Comparing temporally successive predictions are done using temporal difference learning methods. It learns the value function Q (S, a), which denotes the optimal course of action for a given state "s."</p>
<h1 id="heading-applications-of-reinforcement-learning">Applications of Reinforcement Learning</h1>
<ul>
<li>Robotics</li>
<li>Business strategy planning</li>
<li>Aircraft control and robot motion control, etc..</li>
</ul>
<h1 id="heading-conclusion">Conclusion</h1>
<p>I anticipate that this article will clearly explain the reinforcement learning algorithm. To ascertain more about machine learning and to do working machine learning models, check out my machine learning series. If you have any questions or doubts, mention them in this article's comments section, and connect with me to learn more about machine learning.</p>
<p>Learning is an interesting habit..!</p>
]]></content:encoded></item><item><title><![CDATA[Introduction to Array in Javascript]]></title><description><![CDATA[What is Array?
An array is a special object in Javascript, that stores multiple values inside a single variable.
Why is Array needed?
Let’s take a scenario where we need to store multiple variables ranging up to 100(i.e., we need to keep 100 variable...]]></description><link>https://blog.quasarcommunity.org/introduction-to-array-in-javascript</link><guid isPermaLink="true">https://blog.quasarcommunity.org/introduction-to-array-in-javascript</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[webdev]]></category><category><![CDATA[webdesign]]></category><dc:creator><![CDATA[Anusha V]]></dc:creator><pubDate>Sun, 14 Aug 2022 11:44:23 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1660465230914/BbTc-lT2Sz.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-what-is-array">What is Array?</h2>
<p>An array is a special object in Javascript, that stores multiple values inside a single variable.</p>
<h2 id="heading-why-is-array-needed">Why is Array needed?</h2>
<p>Let’s take a scenario where we need to store multiple variables ranging up to 100(i.e., we need to keep 100 variables). Usually, what we will</p>
<pre><code>Var a <span class="hljs-operator">=</span> <span class="hljs-number">10</span>;
Var b <span class="hljs-operator">=</span><span class="hljs-number">30</span>;
Var c <span class="hljs-operator">=</span> <span class="hljs-number">40</span>;
.
.
.
.
.
.
.
.
.
.
.
It goes on
</code></pre><p>In the above case, there is a lot of memory space is wasted and it’s not possible to store 100 variables in the above manner it creates issues in dynamic data storage also. So, the Array concept gives a solution to this problem. Because with the array we can store multiple values inside a single variable.</p>
<h2 id="heading-how-to-create-an-array">How to create an Array?</h2>
<p>We use Square brackets(i.e., []) to enclose the array of elements inside a single variable.</p>
<p>Example:-</p>
<pre><code><span class="hljs-string">let</span> <span class="hljs-string">arr</span> <span class="hljs-string">=</span> [ <span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">6</span>,<span class="hljs-number">7</span> ]<span class="hljs-string">;</span>
</code></pre><h2 id="heading-how-to-access-array-elements">How to access array elements?</h2>
<p>We can access an array of elements by using its index value.</p>
<p>Let’s take an example, </p>
<pre><code><span class="hljs-string">let</span> <span class="hljs-string">arr</span> <span class="hljs-string">=</span> [<span class="hljs-number">1</span>,<span class="hljs-number">2</span>,<span class="hljs-number">3</span>,<span class="hljs-number">4</span>,<span class="hljs-number">5</span>]<span class="hljs-string">;</span>
</code></pre><p>In the above example, if we need to access the fourth element of the array. We will access it by its index value.</p>
<p>The Index value starts with 0 and it goes on.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1660465355851/U16efhUHd.png" alt="HTML (4).png" /></p>
<p>The above picture shows the array of elements with its index value.</p>
<p>So, if we need to access fourth element of the array. We will do it by</p>
<pre><code>console.log(arr[<span class="hljs-number">3</span>]); <span class="hljs-comment">// 4</span>
</code></pre><h2 id="heading-methods-for-defining-array">Methods for defining array:</h2>
<p>We can define an array in two methods, are</p>
<p>The first method is the regular method to define an array,</p>
<pre><code><span class="hljs-string">let</span> <span class="hljs-string">arr</span> <span class="hljs-string">=</span> [ <span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span> ]<span class="hljs-string">;</span>
</code></pre><p>The Second method is,</p>
<p>Step-1: First declare an empty array.</p>
<pre><code><span class="hljs-built_in">let</span> arr = [];
</code></pre><p>Step-2: Next, using its index value - insert elements one after another.</p>
<pre><code>arr[<span class="hljs-number">0</span>] <span class="hljs-operator">=</span> “Banana”;
arr[<span class="hljs-number">1</span>] <span class="hljs-operator">=</span> “Apple”;
arr[<span class="hljs-number">2</span>] <span class="hljs-operator">=</span> “orange”;
console.log(arr); <span class="hljs-comment">// [ “Banana”, “Apple”, “orange”];</span>
</code></pre><p>In the next blog, we will explore array properties and methods.</p>
]]></content:encoded></item><item><title><![CDATA[R programming - Packages]]></title><description><![CDATA[This blog will look at various packages and how they are used in R programming to get the expected results. 
What is a Package...?
A package is an appropriate way to organize the work and share it with others. Typically, a package will include code, ...]]></description><link>https://blog.quasarcommunity.org/r-programming-packages</link><guid isPermaLink="true">https://blog.quasarcommunity.org/r-programming-packages</guid><category><![CDATA[R Language]]></category><category><![CDATA[Data Science]]></category><dc:creator><![CDATA[Hitendra K]]></dc:creator><pubDate>Thu, 11 Aug 2022 15:09:16 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1660223668841/uIutaQ8Ma.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>This blog will look at various packages and how they are used in R programming to get the expected results. </p>
<h3 id="heading-what-is-a-package">What is a Package...?</h3>
<p>A package is an appropriate way to organize the work and share it with others. Typically, a package will include code, documentation for the package and the functions inside, some tests to check everything works as it should, and data sets. </p>
<p>R packages are a collection of R functions, complied code and sample data. They are stored under a directory called "library" in the R environment. By default, R installs a set of packages during installation. More packages are added later when they are needed for some specific purpose. When we start the R console, only the default packages are available by default. Other packages which are already installed have to be loaded explicitly to be used by the R program that is going to use them.</p>
<p>All the packages available in the R language are listed at R Packages.</p>
<h3 id="heading-what-are-repositaries">What are Repositaries...?</h3>
<p>A repository is a place where packages are located and stored so you can install packages from it. Organizations and Developers have a local repository, typically they are online and accessible to everyone.</p>
<h3 id="heading-installation-of-r-packages">Installation of R Packages...?</h3>
<p>There are two ways to add new R packages. One is installing directly from the CRAN directory and another is downloading the package to your local system and installing it manually.</p>
<p><strong>Install Packages directly from CRAN</strong></p>
<p>The commands used to install the packages directly from CRAN are given below</p>
<p>Syntax:</p>
<p>install.packages("package name")</p>
<pre><code>Example

install.packages(<span class="hljs-string">"XML"</span>)
</code></pre><p><strong>Install Packages manually</strong></p>
<p>Search for particular R packages on the web and download the required packages as .zip files in the required location in the local system.</p>
<pre><code>install.packages(file_name_with_path, repos <span class="hljs-operator">=</span> NULL, <span class="hljs-keyword">type</span> <span class="hljs-operator">=</span> <span class="hljs-string">"source"</span>)


install.packages(<span class="hljs-string">"E:/XML_3.98-1.3.zip"</span>, repos <span class="hljs-operator">=</span> NULL, <span class="hljs-keyword">type</span> <span class="hljs-operator">=</span> <span class="hljs-string">"source"</span>)
</code></pre><p><strong>How to Load Packages in R Programming Language</strong></p>
<p>Before a package can be used in the code, it must be loaded to the current R environment. You also need to load a package that is already installed previously but not available in the current environment.</p>
<p>A package is loaded using the following command −</p>
<pre><code><span class="hljs-class"><span class="hljs-keyword">library</span>(<span class="hljs-params"><span class="hljs-string">"package Name"</span>, lib.loc = <span class="hljs-string">"path to library"</span></span>)


<span class="hljs-title">install</span>.<span class="hljs-title">packages</span>(<span class="hljs-params"><span class="hljs-string">"E:/XML_3.98-1.3.zip"</span>, repos = NULL, <span class="hljs-keyword">type</span> = <span class="hljs-string">"source"</span></span>)</span>
</code></pre><p><strong>Difference Between a Package and a Library</strong></p>
<p><em>library():</em></p>
<p>It is the command used to load a package, and it refers to the place where the package is contained, usually a folder on our computer.</p>
<p><em>Package:</em></p>
<p>It is a collection of functions bundled conveniently. The package is an appropriate way to organize our own work and share it with others.</p>
<p><strong> How to Load More Than One Package at a Time</strong></p>
<p>We can just input a vector of names to the install.packages() function to install a package, in the case of the library() function, this is not possible. We can load a set of packages one at a time, or if you prefer, use one of the many workarounds developed by R users. </p>
<p>To unload a given package, use the detach() function. The use will be: </p>
<p><em>detach("package:babynames", unload = TRUE)</em></p>
<p><strong>A Short note on how to select the right packages</strong></p>
<p>The most basic way to determine which package we need is by learning the R programming language. The first alternative can be to browse categories of CRAN packages. CRAN is the official repository, and also gives us the option to browse through packages. </p>
<p>Another alternative to finding packages can be R Documentation, a help documentation aggregator for R packages from CRAN, BioConductor, and GitHub, which offers you a search box ready for your requests directly on the main page.</p>
<h3 id="heading-data-handling-and-data-interfaces">Data Handling and Data Interfaces</h3>
<p>In R, we can read data from files stored outside the R environment. We can also write data into files which will be stored and accessed by the operating system. R can read and write into various file formats like csv, excel, xml etc.
R allows its users to work smoothly with the systems directories with the help of some pre-defined functions that take the path of the directory as the argument or return the path of the current directory that the user is working on. Below are some directory functions in R:</p>
<ol>
<li><p><em>getwd()</em>: 
This function is used to get the current working directory used by R.</p>
</li>
<li><p><em>setwd()</em>: 
This function in R is used to change the path of the current working directory and the path of the directory is passed as an argument in the function.</p>
</li>
<li><p><em>list.files()</em>: 
This function lists all files and folders present in the current working directory.</p>
</li>
</ol>
<p>In the next blog, we will know about various data interfaces in R. Follow Quasar Community blogs for more interesting technical blogs.</p>
]]></content:encoded></item><item><title><![CDATA[K-Nearest Neighbor(KNN) Algorithm]]></title><description><![CDATA[K-Nearest Neighbor Algorithm
The k-nearest neighbours (KNN) technique calculates the likelihood that a data point will belong to one group or another based on which group the data points closest to it do.
The k-nearest neighbour algorithm is an examp...]]></description><link>https://blog.quasarcommunity.org/k-nearest-neighborknn-algorithm</link><guid isPermaLink="true">https://blog.quasarcommunity.org/k-nearest-neighborknn-algorithm</guid><category><![CDATA[k nearest neighbors]]></category><category><![CDATA[knn]]></category><category><![CDATA[Machine Learning]]></category><category><![CDATA[algorithms]]></category><category><![CDATA[image classification]]></category><dc:creator><![CDATA[Indirakumar S]]></dc:creator><pubDate>Wed, 10 Aug 2022 14:47:47 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1660135855318/PhV--LwpM.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-k-nearest-neighbor-algorithm">K-Nearest Neighbor Algorithm</h1>
<p>The k-nearest neighbours (KNN) technique calculates the likelihood that a data point will belong to one group or another based on which group the data points closest to it do.</p>
<p>The k-nearest neighbour algorithm is an example of a <a target="_blank" href="https://blog.quasarcommunity.org/supervised-learning">supervised machine learning</a> technique used to solve <a target="_blank" href="https://blog.quasarcommunity.org/classification">classification</a> and <a target="_blank" href="https://blog.quasarcommunity.org/linear-regression-1">regression</a> problems. Its primary application, however, is in classification issues.</p>
<p>KNN is a slow, non-parametric learning method. It is known as a lazy learning algorithm or lazy learner because it does not perform any training when you provide the training data. During the training period, it does not perform any calculations and simply stores the data. A model is not created before a query is run on the dataset.</p>
<p>As a result, KNN is ideal for data mining. It is classified as a non-parametric method because it makes no assumptions about the underlying data distribution. KNN, in short, seeks to identify the group to which a data point belongs by examining the data points around it.</p>
<p>Think about the two groups, A and B. The algorithm examines the nearby data points' states to determine if a data point belongs to group A or group B. It is quite likely that the data point in question is in group A if the bulk of the data points is in group A, and vice versa. KNN also called the closest neighbour, is a technique for categorizing data points by comparing them to their nearest annotated data point.</p>
<p>K-NN classification should not be confused with K-means clustering. A supervised classification system called KNN sorts new data points according to the nearby ones. K-means clustering, on the other hand, divides data into a K number of clusters and is an unsupervised clustering algorithm.</p>
<h1 id="heading-algorithm">Algorithm</h1>
<p>The KNN algorithm is implemented using programming languages like Python and R. The KNN pseudocode is as follows:</p>
<p>1.Fill the data up</p>
<p>2.Select K value</p>
<p>3.For every informational point in the data:</p>
<p>3.1.All training data samples' Euclidean distance should be determined.</p>
<p>3.2.Place the distances on a list that is ordered, then sort it.</p>
<p>3.3.Pick the first K items in the sorted list.</p>
<p>3.4.Based on the vast majority of classes contained in the chosen points, label the test point.</p>
<p>4.End</p>
<h1 id="heading-why-knn">Why KNN?</h1>
<p>A crucial issue in data science and machine learning is classification. One of the earliest and most precise algorithms for pattern categorization and regression models is the KNN.</p>
<p>The following are some applications for the k-nearest neighbour algorithm:</p>
<ul>
<li><p>Credit rating</p>
</li>
<li><p>Loan approval</p>
</li>
<li><p>Data preprocessing</p>
</li>
<li><p>Pattern recognition</p>
</li>
</ul>
<p>KNN can be also used in recommendation systems because it can help find users with similar characteristics. It can, for example, be used in an online video streaming platform to recommend content that a user is more likely to watch based on what similar users watch.</p>
<p>For image classification, the KNN algorithm is used in computer vision. It's helpful in a variety of computer vision applications because it can group similar data points, such as grouping cats together and dogs in a different class.</p>
<h1 id="heading-advantage">Advantage</h1>
<ul>
<li>It is simple to understand and implement.</li>
<li>It applies to both classification and regression problems.</li>
<li>It is ideal for non-linear data because it makes no assumptions about the underlying data.</li>
<li>It is naturally capable of handling multi-class cases.</li>
<li>With enough representative data, it can perform well.</li>
</ul>
<h1 id="heading-disadvantage">Disadvantage</h1>
<ul>
<li>Because it stores all of the training data, the associated computation cost is high.</li>
<li>High memory storage is required.</li>
<li>K's value must be determined.</li>
<li>If N is large, prediction takes a long time.</li>
<li>Sensitive to irrelevant characteristics</li>
</ul>
<h1 id="heading-example">Example</h1>
<h2 id="heading-image-classification">Image classification</h2>
<pre><code><span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np <span class="hljs-comment">// linear algebra</span>
<span class="hljs-keyword">import</span> pandas <span class="hljs-keyword">as</span> pd <span class="hljs-comment">// data processing</span>
<span class="hljs-keyword">import</span> matplotlib.pyplot <span class="hljs-keyword">as</span> plt  <span class="hljs-comment">// to plot image, graph</span>
<span class="hljs-keyword">import</span> time
%matplotlib <span class="hljs-keyword">inline</span>
</code></pre><pre><code><span class="hljs-comment">// dataset for digit (0-9)</span>
<span class="hljs-keyword">from</span> sklearn.datasets <span class="hljs-keyword">import</span> <span class="hljs-title">load_digits</span>
</code></pre><p>Load dataset</p>
<pre><code><span class="hljs-attr">digits</span> = load_digits()
</code></pre><pre><code><span class="hljs-selector-tag">digits</span><span class="hljs-selector-class">.keys</span>()
<span class="hljs-selector-id">#dict_keys</span>([<span class="hljs-string">'data'</span>, <span class="hljs-string">'target'</span>, <span class="hljs-string">'target_names'</span>, <span class="hljs-string">'images'</span>, <span class="hljs-string">'DESCR'</span>])
</code></pre><pre><code><span class="hljs-comment">// dataset description</span>
<span class="hljs-selector-tag">digits</span><span class="hljs-selector-class">.DESCR</span>
</code></pre><p>Already processed images</p>
<pre><code>
digits.images[<span class="hljs-number">0</span>]

<span class="hljs-string">'''array([[ 0.,  0.,  5., 13.,  9.,  1.,  0.,  0.],
       [ 0.,  0., 13., 15., 10., 15.,  5.,  0.],
       [ 0.,  3., 15.,  2.,  0., 11.,  8.,  0.],
       [ 0.,  4., 12.,  0.,  0.,  8.,  8.,  0.],
       [ 0.,  5.,  8.,  0.,  0.,  9.,  8.,  0.],
       [ 0.,  4., 11.,  0.,  1., 12.,  7.,  0.],
       [ 0.,  2., 14.,  5., 10., 12.,  0.,  0.],
       [ 0.,  0.,  6., 13., 10.,  0.,  0.,  0.]])'''</span>
</code></pre><p>Predictors, independent variables, features</p>
<pre><code>digits.data

<span class="hljs-string">'''array([[ 0.,  0.,  5., ...,  0.,  0.,  0.],
       [ 0.,  0.,  0., ..., 10.,  0.,  0.],
       [ 0.,  0.,  0., ..., 16.,  9.,  0.],
       ...,
       [ 0.,  0.,  1., ...,  6.,  0.,  0.],
       [ 0.,  0.,  2., ..., 12.,  0.,  0.],
       [ 0.,  0., 10., ..., 12.,  1.,  0.]])'''</span>
</code></pre><p>Target variable, class, dependent variable</p>
<pre><code><span class="hljs-selector-tag">digits</span><span class="hljs-selector-class">.target</span>

<span class="hljs-selector-id">#array</span>(<span class="hljs-selector-attr">[0, 1, 2, ..., 8, 9, 8]</span>)
</code></pre><p>These 1797 images (8 by 8 for a dimension of 64)</p>
<pre><code>print(<span class="hljs-string">'Image Data Shape'</span>, digits.images.shape)
<span class="hljs-comment"># Image Data Shape (1797, 8, 8)</span>


<span class="hljs-comment"># 1797 labels</span>
print(<span class="hljs-string">'Label Data Shape'</span>, digits.target.shape)
<span class="hljs-comment">#Label Data Shape (1797,)</span>
</code></pre><pre><code>X <span class="hljs-operator">=</span> digits.images
plt.figure(figsize<span class="hljs-operator">=</span>(<span class="hljs-number">20</span>,<span class="hljs-number">10</span>))
columns <span class="hljs-operator">=</span> <span class="hljs-number">5</span>
<span class="hljs-keyword">for</span> i in range(<span class="hljs-number">5</span>):
    plt.subplot(<span class="hljs-number">5</span> <span class="hljs-operator">/</span> columns <span class="hljs-operator">+</span> <span class="hljs-number">1</span>, columns, i <span class="hljs-operator">+</span> <span class="hljs-number">1</span>)
    plt.imshow(X[i],cmap<span class="hljs-operator">=</span>plt.cm.gray_r,interpolation<span class="hljs-operator">=</span><span class="hljs-string">'nearest'</span>)

<span class="hljs-keyword">from</span> sklearn.metrics <span class="hljs-keyword">import</span> <span class="hljs-title">accuracy_score</span>,<span class="hljs-title">confusion_matrix</span> # <span class="hljs-title">metrics</span> <span class="hljs-title"><span class="hljs-keyword">error</span></span>
<span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-title">sklearn</span>.<span class="hljs-title">model_selection</span> <span class="hljs-title"><span class="hljs-keyword">import</span></span> <span class="hljs-title">train_test_split</span> # <span class="hljs-title">resampling</span> <span class="hljs-title">method</span>
<span class="hljs-title">X</span> <span class="hljs-operator">=</span> <span class="hljs-title">digits</span>.<span class="hljs-title">data</span>
<span class="hljs-title">y</span> <span class="hljs-operator">=</span> <span class="hljs-title">digits</span>.<span class="hljs-title">target</span>
</code></pre><p>Since its a multi-class prediction, to prevent error, we need some library</p>
<pre><code><span class="hljs-keyword">from</span> sklearn.multiclass <span class="hljs-keyword">import</span> <span class="hljs-title">OneVsRestClassifier</span>
<span class="hljs-title">X_train</span>, <span class="hljs-title">X_test</span>, <span class="hljs-title">y_train</span>, <span class="hljs-title">y_test</span> <span class="hljs-operator">=</span> <span class="hljs-title">train_test_split</span>(<span class="hljs-title">X</span>, <span class="hljs-title">y</span>, <span class="hljs-title">test_size</span><span class="hljs-operator">=</span>0.25, <span class="hljs-title">random_state</span><span class="hljs-operator">=</span>0)
<span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-title">sklearn</span>.<span class="hljs-title">neighbors</span> <span class="hljs-title"><span class="hljs-keyword">import</span></span> <span class="hljs-title">KNeighborsClassifier</span>
<span class="hljs-title">knn</span> <span class="hljs-operator">=</span> <span class="hljs-title">OneVsRestClassifier</span>(<span class="hljs-title">KNeighborsClassifier</span>())
<span class="hljs-title">knn</span>.<span class="hljs-title">fit</span>(<span class="hljs-title">X_train</span>,<span class="hljs-title">y_train</span>)
<span class="hljs-comment">//OneVsRestClassifier(estimator=KNeighborsClassifier(algorithm='auto', leaf_size=30, metric='minkowski',</span>
 <span class="hljs-comment">//          metric_params=None, n_jobs=None, n_neighbors=5, p=2,</span>
  <span class="hljs-comment">//         weights='uniform'),</span>
      <span class="hljs-comment">//    n_jobs=None)</span>
</code></pre><p>Predict for one observation</p>
<pre><code>knn.predict(X_test[<span class="hljs-number">0</span>].reshape(<span class="hljs-number">1</span>,<span class="hljs-number">-1</span>))
<span class="hljs-comment">//array([2])</span>
</code></pre><p>Predict for multiple observations (images) at once</p>
<pre><code><span class="hljs-string">knn.predict(X_test[0:10])</span>
<span class="hljs-string">//array([2,</span> <span class="hljs-number">8</span><span class="hljs-string">,</span> <span class="hljs-number">2</span><span class="hljs-string">,</span> <span class="hljs-number">6</span><span class="hljs-string">,</span> <span class="hljs-number">6</span><span class="hljs-string">,</span> <span class="hljs-number">7</span><span class="hljs-string">,</span> <span class="hljs-number">1</span><span class="hljs-string">,</span> <span class="hljs-number">9</span><span class="hljs-string">,</span> <span class="hljs-number">8</span><span class="hljs-string">,</span> <span class="hljs-number">5</span><span class="hljs-string">])</span>
</code></pre><p>Make predictions on the entire test data</p>
<pre><code><span class="hljs-string">predictions</span> <span class="hljs-string">=</span> <span class="hljs-string">knn.predict(X_test)</span>
<span class="hljs-string">%time</span>
<span class="hljs-comment"># 98%</span>
<span class="hljs-string">print('KNN</span> <span class="hljs-attr">Accuracy:</span> <span class="hljs-string">%.3f'</span> <span class="hljs-string">%</span> <span class="hljs-string">accuracy_score(y_test,predictions))</span>
<span class="hljs-string">//CPU</span> <span class="hljs-attr">times:</span> <span class="hljs-string">user</span> <span class="hljs-number">0</span> <span class="hljs-string">ns,</span> <span class="hljs-attr">sys:</span> <span class="hljs-number">0</span> <span class="hljs-string">ns,</span> <span class="hljs-attr">total:</span> <span class="hljs-number">0</span> <span class="hljs-string">ns</span>
<span class="hljs-string">//Wall</span> <span class="hljs-attr">time:</span> <span class="hljs-number">10</span> <span class="hljs-string">µs</span>
<span class="hljs-string">//KNN</span> <span class="hljs-attr">Accuracy:</span> <span class="hljs-number">0.980</span>
</code></pre><p>To create nice confusion metrics</p>
<pre><code><span class="hljs-keyword">import</span> <span class="hljs-title">seaborn</span> <span class="hljs-title"><span class="hljs-keyword">as</span></span> <span class="hljs-title">sns</span>
<span class="hljs-title">cm</span> <span class="hljs-operator">=</span> <span class="hljs-title">confusion_matrix</span>(<span class="hljs-title">y_test</span>,<span class="hljs-title">predictions</span>)
<span class="hljs-title">plt</span>.<span class="hljs-title">figure</span>(<span class="hljs-title">figsize</span><span class="hljs-operator">=</span>(9,9))
<span class="hljs-title">sns</span>.<span class="hljs-title">heatmap</span>(<span class="hljs-title">cm</span>,<span class="hljs-title">annot</span><span class="hljs-operator">=</span><span class="hljs-title">True</span>, <span class="hljs-title">fmt</span><span class="hljs-operator">=</span><span class="hljs-string">'.3f'</span>, <span class="hljs-title">linewidths</span><span class="hljs-operator">=</span>.5, <span class="hljs-title">square</span><span class="hljs-operator">=</span><span class="hljs-title">True</span>,<span class="hljs-title">cmap</span><span class="hljs-operator">=</span><span class="hljs-string">'Blues_r'</span>)
<span class="hljs-title">plt</span>.<span class="hljs-title">ylabel</span>(<span class="hljs-string">'Actual label'</span>)
<span class="hljs-title">plt</span>.<span class="hljs-title">xlabel</span>(<span class="hljs-string">'Predicted label'</span>)
<span class="hljs-title">all_sample_title</span> <span class="hljs-operator">=</span> <span class="hljs-string">'Accuracy Score: {0}'</span>.<span class="hljs-title">format</span>(<span class="hljs-title">accuracy_score</span>(<span class="hljs-title">y_test</span>,<span class="hljs-title">predictions</span>))
<span class="hljs-title">plt</span>.<span class="hljs-title">title</span>(<span class="hljs-title">all_sample_title</span>,<span class="hljs-title">size</span><span class="hljs-operator">=</span>15)
#<span class="hljs-title">Text</span>(0.5, 1.0, <span class="hljs-string">'Accuracy Score: 0.98'</span>)
</code></pre><h1 id="heading-conclusion">Conclusion</h1>
<p>This article clearly explains the process of image classification using KNN in the machine learning model. To learn more about machine learning and how to make machine learning models, check out my machine learning series. If you have any questions or doubts, mention them in this article's comments section, and connect with me to learn more about machine learning.</p>
<p>Learning is an interesting habit..!</p>
]]></content:encoded></item><item><title><![CDATA[10 Chrome extensions 💻 to boost your productivity]]></title><description><![CDATA[Introduction
Chrome is the most used browsing application. Many people love it many people hate it but it can get the job done. But because of its easy-to-use functionalities, it is very easy to get distracted. In this blog, we are going to see 10 ch...]]></description><link>https://blog.quasarcommunity.org/10-chrome-extensions-to-boost-your-productivity</link><guid isPermaLink="true">https://blog.quasarcommunity.org/10-chrome-extensions-to-boost-your-productivity</guid><category><![CDATA[chrome extension]]></category><category><![CDATA[Productivity]]></category><category><![CDATA[Time management]]></category><category><![CDATA[Productivity & Organization]]></category><category><![CDATA[Chrome]]></category><dc:creator><![CDATA[Vasanth kumar k]]></dc:creator><pubDate>Tue, 09 Aug 2022 11:51:31 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1659455540423/VMF2roBQv.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-introduction">Introduction</h1>
<p>Chrome is the most used browsing application. Many people love it many people hate it but it can get the job done. But because of its easy-to-use functionalities, it is very easy to get distracted. In this blog, we are going to see 10 chrome extensions that can boost your productivity and keep you focused on work and less distracted</p>
<h1 id="heading-extensions">Extensions</h1>
<h2 id="heading-1unhook">1,Unhook</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1659456405309/USQoTj_vS.jpg" alt="unnamed.jpg" /></p>
<p>link:- <a target="_blank">unhook</a></p>
<p>Many people prefer to learn on youtube because of how convenient it is to learn for free also you wide variety of choices to choose from But it has its disadvantages. Youtube knows what you like and what kind of videos you click on the most. So the recommendation system is based on what you like not what you want. It is very easy to get distracted, whether a video from your favorite content creator or a cat video. So if you want to learn it is very difficult to ignore distractions. Unhook helps you to stop getting distracted by the recommended videos by simply hiding the recommended videos. You can even choose to hide comments from the videos. By using unhook you can save 5 to 50 minutes of short bust minutes that are wasted due to recommended videos and other distractions</p>
<h2 id="heading-2idenati">2,Idenati</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1659456904239/Bv5Ir8yhd.webp" alt="unnamed.webp" /></p>
<p>link:- <a target="_blank">Idenati</a></p>
<p>While writing this blog I had a lot of issues in the opening hash node itself cause I don't even remember the password for my account cause I have a ton of different accounts in different domains so it is very frustrating to remember every password for every account.  That's where Idenati comes in handy. In Identity, you can have every account in one dashboard where you have to enter your password and email or username and you can save it right. Next time when you want to open a website then it will be right there just a click no hassle at all.</p>
<h2 id="heading-3forest">3,Forest</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1659463519213/6UzDHUBF5.jpg" alt="unnamed (1).jpg" /></p>
<p>link:- <a target="_blank" href="https://chrome.google.com/webstore/detail/forest-stay-focused-be-pr/kjacjjdnoddnpbbcjilcajfhhbdhkpgk?hl=en-US">Forest</a></p>
<p>Pomodoros are helpful to get into a flow state where you will do most of the deep work for starters forest is a great Pomodoro app where you can select how much you need each Pomodoro session to be. I use Pomodoro just to get started and then I will be in the flow state and start to work deeply you can use whichever way you like and for every session, you complete in the forest it will grow trees in the imaginary forest after completing a day you can see how many trees have grown in the forest it will give you a visual representation of how productive you are</p>
<h2 id="heading-4loom">4,loom</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1659462288105/rkgVZoIrk.jpg" alt="unnamed (3).jpg" /></p>
<p>link:- <a target="_blank" href="https://chrome.google.com/webstore/detail/loom-%E2%80%93-free-screen-record/liecbddmkiiihnedobmlmillhodjkdmb?hl=en-US">loom</a></p>
<p>Loom is a screen recorder that is very convenient to use and You don't have to install a separate app to get small videos about a website or application. Loom allows you to take up to 5 mins of screen recording for free. You can also give a voice-over to recording with the camera. You can also share the direction with a link you don't need to download the recorded video which is very useful in sending videos about applications or websites to the team.</p>
<h2 id="heading-5calendly">5,Calendly</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1659463426261/f1uxqcYgD.jpg" alt="unnamed (4).jpg" /></p>
<p>link:- <a target="_blank" href="https://chrome.google.com/webstore/detail/calendly-meeting-scheduli/cbhilkcodigmigfbnphipnnmamjfkipp?hl=en-US">Calendly</a></p>
<p>Schedule meetings without the hassle. Never get double booked. Calendly works with your calendar to automate appointment scheduling.
Once you have a Calendly account (free and paid plans), use the Calendly for Chrome extension to:</p>
<ul>
<li>Access all of your event types from anywhere on the web</li>
<li>Leverage Calendly from the Gmail compose toolbar and add times to your email</li>
<li>Leverage Calendly in LinkedIn Messaging, Recruiter, and Sales Navigator</li>
<li>Select and share your availability in a few clicks</li>
<li>Create one-off meetings to handpick times for VIPs</li>
<li>Create meeting polls to find and book the best time for everyone to meet</li>
<li>Mark and save event types as your favorites for even quicker access</li>
<li>Add notes to your event types that only you and your teammates can see</li>
</ul>
<p>Calendly connects with your personal and business calendars to save you time and simplify the tasks involved in meeting with people outside your company. Now you can connect and agree with your invitees on the best time to meet and schedule your meetings without the back-and-forth emails.</p>
<h2 id="heading-6-angry-study-helper">6, Angry study helper</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1659463649129/63rPX-bQ9.jpg" alt="unnamed (2).jpg" /></p>
<p>link:- <a target="_blank" href="https://chrome.google.com/webstore/detail/angry-study-helper/bpbdbiickajcfeoilijnjlgchjjlfakj?hl=en-US">Angry study helper</a></p>
<p>An extension that gets grumpy when you open a new tab while studying.
An extension that will get mad at you when you open a new tab while studying/working. Will give you the passion, vision, and aggression to grind through all your tasks.</p>
<p>How to use:</p>
<ul>
<li>Make sure to open all the tabs you need for your work before you turn on the extension.</li>
<li>Turn on the extension and enjoy :)</li>
</ul>
<h2 id="heading-7-todolist">7, Todolist</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1659463759423/2bp7fbtBX.jpg" alt="unnamed (5).jpg" /></p>
<p>link:- <a target="_blank" href="https://chrome.google.com/webstore/detail/focus-to-do-pomodoro-time/ngceodoilcgpmkijopinlkmohnfifjfb?hl=en-US">Todolist</a></p>
<p>Focus To-Do combines Pomodoro Timer with Task Management, it is a science-based app that will motivate you to stay focused and get things done. </p>
<p>It brings Pomodoro Technique and Does List into one place, you can capture and organize tasks into your to-do lists, start a focus timer and focus on work &amp; study, set reminders for important tasks and errands, and check the time spent at work. </p>
<p>It's the ultimate app for managing Tasks, Reminders, Lists, Calendar events, Grocery lists, and checklists, helping you focus on work &amp; study and tracking your working hours.</p>
<p>Focus To-Do syncs between your phone and computer, so you can access your lists from anywhere.</p>
<h2 id="heading-8-readwise">8, Readwise</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1659463879189/6S3XvAACk.jpg" alt="unnamed (6).jpg" /></p>
<p>link:- <a target="_blank" href="https://chrome.google.com/webstore/detail/readwise-highlighter-comm/elfkeclcbihceogopmbjdhpfjipkmkfi?hl=en-US">Readwise</a></p>
<p>Create highlights from any webpage and sync directly to your Readwise account.
Readwise Highlighter (Community) is a simple highlight creator extension for your Readwise account. Now you are not restricted by highlight sources Readwise supports syncing, and can create highlights from any online webpage text you want.</p>
<p>Simply do the following to create a new highlight and send it automatically to your Readwise account:</p>
<ol>
<li>Install the extension.</li>
<li>Click on the extension in the browser bar, enter your Readwise access token (use the link on the extension to get your token), and click save.</li>
<li>Highlight any text on any webpage and right-click the highlighted area.</li>
<li>Select one of the menu options to automatically send the highlighted text to your Readwise account as a highlight.</li>
</ol>
<h2 id="heading-9-working">9, Working</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1659464254144/D2VRlEy6o.jpg" alt="unnamed (8).jpg" /></p>
<p>Link:- <a target="_blank" href="https://chrome.google.com/webstore/detail/workona-tab-manager/ailcmbgekjpnablpdkmaaccecekgdhlh?hl=en-US">workona</a></p>
<p>Organize your work in the browser.
Working helps you get your work under control and finally feel organized. Use it to manage tabs, organize projects, and bring together all of your work in the browser.</p>
<p>FEATURES</p>
<p>Workspaces
Workspaces organize your work by project, so staying focused is easy. Within a workspace, you can keep your current work open as tabs, or save everything for a project as resources.</p>
<p>Tab manager
Keep your tabs under control with tab management that’s built for working in the cloud. Suspend tabs, rearrange tabs with drag and drop, and rest easy knowing that every tab is automatically saved.</p>
<p>Secure backups
You never have to worry about losing work, because Workona auto-saves all of your tabs. In case of a browser crash or other emergency, you can easily restore your tabs to get you back on track.</p>
<p>Access apps
Use your favorite cloud apps within Working. Access your recent Google Docs, Asana Projects, Zoom Meetings, and hundreds of other cloud resources, right from Working. You can even create new cloud resources from the search bar.</p>
<p>Suspend tabs
Dramatically reduce memory usage and keep your computer running faster. Our tab suspension helps you open workspaces and switch between them almost instantly.</p>
<p>Bookmark tabs
Bookmark tabs in workspaces by adding them as resources. You can also choose to save an entire window as a workspace.</p>
<p>Search tabs
Our powerful search helps you find your tabs and docs faster. Search all open tabs—or previously open tabs—at a moment’s notice.</p>
<p>Sync tabs
Sync your tabs between computers to keep your work organized, no matter how many devices you use or where they are.</p>
<h2 id="heading-10-audiblogs">10, Audiblogs</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1659464101771/z5Q_ckctG.jpg" alt="unnamed (7).jpg" /></p>
<p>Link:- <a target="_blank" href="https://chrome.google.com/webstore/detail/audioread-formerly-audibl/fblchjbbkkaoobkhhbloehgkpdlomido?hl=en-US">Audiblogs</a></p>
<p>Instantly listen to any web page in the web browser or use a podcast player.
Send As Podcast turns any web article, PDF, or email into a podcast using the latest AI narrator. You can listen in your podcast player, in the web browser, in the Chrome extension, or using our iOS/Android app. </p>
<ul>
<li>It sounds "scarily good." (demo at https://audioread.com)</li>
<li>Your own, private podcast channel.</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[R programming - Object Oriented Programming]]></title><description><![CDATA[Object-Oriented Programming (OOP) is the most popular programming language. With the help of oops concepts, we can construct the modular pieces of code used to build blocks for large systems. Oops is a great tool to manage the complexity of more exte...]]></description><link>https://blog.quasarcommunity.org/r-programming-object-oriented-programming</link><guid isPermaLink="true">https://blog.quasarcommunity.org/r-programming-object-oriented-programming</guid><category><![CDATA[R Language]]></category><dc:creator><![CDATA[Hitendra K]]></dc:creator><pubDate>Thu, 04 Aug 2022 17:17:33 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1659632682670/of-7StR9Z.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Object-Oriented Programming (OOP) is the most popular programming language. With the help of oops concepts, we can construct the modular pieces of code used to build blocks for large systems. Oops is a great tool to manage the complexity of more extensive programs in the R language. In Object- Oriented Programming, S3 and S4 are the two important systems. </p>
<p>We will discuss the S3 and S4 classes, inheritance in these classes, and the methods provided by these classes.</p>
<p><strong>S3</strong></p>
<p>In oops, the S3 is used to overload any function. So that we can call the functions with different names and it depends on the type of input parameter or the number of parameters.</p>
<p><strong>S4</strong></p>
<p>S4 is the most important characteristic of oops. However, this is a limitation, as it is quite difficult to debug. There is an optional reference class for S4.</p>
<h3 id="heading-class-and-object">Class and Object</h3>
<p>In R, everything is an object. Therefore, programmers perform the OOPS concept when they write code in R. An object is a data structure that has some methods that can act upon its attributes. An object is a data structure that contains some methods that act upon its attributes. </p>
<p>In R, classes are the outline or design for the object. Classes encapsulate the data members, along with the functions. In R, there are two most important classes, i.e., S3 and S4, which play an important role in performing OOPs concepts.</p>
<p><strong>1. S3 Class : </strong>
With S3 class, we can take advantage of the ability to implement the generic function. Furthermore, using only the first argument, S3 is capable of dispatching. S3 differs from traditional programming languages such as Java, C ++, and C #, which implement OO passing messages. This makes S3 easy to implement. In the S3 class, the generic function calls the method. S3 is very casual and has no formal definition of classes.</p>
<p>To create an object for this class we will create a list that will contain all the class members. Then this list is passed to the class() method as an argument.</p>
<p><strong>Syntax:</strong></p>
<p><em>var_name &lt;- list(member1, member2, member3.........memberN)  </em></p>
<p>Example:</p>
<pre><code><span class="hljs-keyword">var</span> <span class="hljs-operator">&lt;</span> <span class="hljs-operator">-</span> list(name<span class="hljs-operator">=</span><span class="hljs-string">"Hari"</span>, Reg_No<span class="hljs-operator">=</span><span class="hljs-number">20</span>)

<span class="hljs-comment">// Defining Class</span>

class(<span class="hljs-keyword">var</span>) <span class="hljs-operator">&lt;</span> <span class="hljs-operator">-</span> <span class="hljs-string">"Student"</span> 

<span class="hljs-comment">// Object creation</span>

<span class="hljs-keyword">var</span> 

Output
<span class="hljs-comment">//$name</span>
<span class="hljs-comment">//[1] "Hari"</span>

<span class="hljs-comment">//$Reg_No</span>
<span class="hljs-comment">//[1] 20</span>

<span class="hljs-comment">//attr(, "class")</span>
<span class="hljs-comment">//[1] "Student"</span>
</code></pre><p><strong>Inheritance in S3 Class</strong>
Inheritance is an important concept in OOP(object-oriented programming) which allows one class to derive the features and functionalities of another class. This feature facilitates code-reusability.
Inheritance means extracting the features of one class into another class. In the S3 class of R, inheritance is achieved by applying the class attribute in a vector. S3 class objects inherit only methods from their base class.</p>
<p>Example:</p>
<pre><code>student <span class="hljs-operator">&lt;</span> <span class="hljs-operator">-</span> <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">k, l</span>) </span>{
    value <span class="hljs-operator">&lt;</span> <span class="hljs-operator">-</span> list(name<span class="hljs-operator">=</span>k, Roll<span class="hljs-operator">=</span>l)
    attr(value, <span class="hljs-string">"class"</span>) <span class="hljs-operator">&lt;</span> <span class="hljs-operator">-</span> <span class="hljs-string">"student"</span>
    value
}

print.student <span class="hljs-operator">&lt;</span> <span class="hljs-operator">-</span> <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">obj</span>) </span>{


    cat(<span class="hljs-string">"Name:"</span>, obj$name, <span class="hljs-string">"\n"</span>)
    cat(<span class="hljs-string">"Roll"</span>, obj$roll, <span class="hljs-string">"\n"</span>)}

s <span class="hljs-operator">&lt;</span> <span class="hljs-operator">-</span> list(name<span class="hljs-operator">=</span><span class="hljs-string">"Hari"</span>, Roll<span class="hljs-operator">=</span><span class="hljs-number">21</span>, country<span class="hljs-operator">=</span><span class="hljs-string">"India"</span>)


class(s) <span class="hljs-operator">&lt;</span> <span class="hljs-operator">-</span> c(<span class="hljs-string">"Student"</span>, <span class="hljs-string">"student"</span>)
s

Output
<span class="hljs-comment">//Name: Hari</span>
<span class="hljs-comment">//Roll: 21</span>
</code></pre><p><strong>2. S4 Class</strong>
The S4 class is similar to the S3 but more formal than the latter. It differs from S3 in two different ways. S4 class has a predefined definition. It contains functions for defining methods and generics. It makes multiple dispatches easy. This class contains auxiliary functions for defining methods and generics.</p>
<p>In R, we use setClass() command for creating S4 class. In S4 class, we will specify a function for verifying the data consistency and also specify the default value. In R, member variables are called slots.</p>
<p><strong>Syntax</strong>
<em>setClass(“myclass”, slots=list(name=”character”, Roll_No=”numeric”))  </em></p>
<p>Example</p>
<pre><code>setClass(<span class="hljs-string">"Student"</span>, slots<span class="hljs-operator">=</span>list(name<span class="hljs-operator">=</span><span class="hljs-string">"character"</span>,
                               Roll_No<span class="hljs-operator">=</span><span class="hljs-string">"numeric"</span>))

a <span class="hljs-operator">&lt;</span><span class="hljs-operator">-</span> <span class="hljs-keyword">new</span>(<span class="hljs-string">"Student"</span>, name<span class="hljs-operator">=</span><span class="hljs-string">"Hari"</span>, Roll_No<span class="hljs-operator">=</span><span class="hljs-number">20</span>)

a

Output
<span class="hljs-comment">//Slot "name":</span>
<span class="hljs-comment">// "Hari"</span>

<span class="hljs-comment">//Slot "Roll_No":</span>
<span class="hljs-comment">//20</span>
</code></pre><p><strong>Inheritance in S4 Class</strong></p>
<p>Like S3 class, we can perform inheritance in the S4 class also. The derived class will inherit both attributes and methods of the parent class. Let's start understanding how we can perform inheritance in the S4 class. There are the following ways to perform inheritance in the S4 class:</p>
<p>Example:</p>
<pre><code>setClass(<span class="hljs-string">"student"</span>,
         slots<span class="hljs-operator">=</span>list(name<span class="hljs-operator">=</span><span class="hljs-string">"character"</span>,
                    age<span class="hljs-operator">=</span><span class="hljs-string">"numeric"</span>, rno<span class="hljs-operator">=</span><span class="hljs-string">"numeric"</span>)
         )


setMethod(<span class="hljs-string">"show"</span>, <span class="hljs-string">"student"</span>,
          <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">obj</span>)</span>{
              cat(obj@name, <span class="hljs-string">"\n"</span>)
              cat(obj@age, <span class="hljs-string">"\n"</span>)
              cat(obj@rno, <span class="hljs-string">"\n"</span>)
          }
          )


setClass(<span class="hljs-string">"InternationalStudent"</span>,
         slots<span class="hljs-operator">=</span>list(country<span class="hljs-operator">=</span><span class="hljs-string">"character"</span>),
         contains<span class="hljs-operator">=</span><span class="hljs-string">"student"</span>
         )


s <span class="hljs-operator">&lt;</span> <span class="hljs-operator">-</span> <span class="hljs-keyword">new</span>(<span class="hljs-string">"InternationalStudent"</span>, name<span class="hljs-operator">=</span><span class="hljs-string">"Hari"</span>,
          age<span class="hljs-operator">=</span><span class="hljs-number">22</span>, rno<span class="hljs-operator">=</span><span class="hljs-number">15</span>, country<span class="hljs-operator">=</span><span class="hljs-string">"India"</span>)
show(s)

Output
<span class="hljs-comment">//Hari</span>
<span class="hljs-comment">//22 </span>
<span class="hljs-comment">//15</span>
</code></pre><p>That is it for today, we can look into libraries in R in the next blog. Subscribe to our newsletter for more interesting blogs.</p>
]]></content:encoded></item><item><title><![CDATA[Machine Learning Model]]></title><description><![CDATA[What is a Machine Learning Model?
The machine learning model is a sector which can be trained and tested with specific data to recognise the pattern. we can prepare a model with selected datasets to perform a particular task. Our developer datasets w...]]></description><link>https://blog.quasarcommunity.org/machine-learning-model</link><guid isPermaLink="true">https://blog.quasarcommunity.org/machine-learning-model</guid><category><![CDATA[Learn Code Online]]></category><category><![CDATA[Programming Blogs]]></category><category><![CDATA[Python]]></category><category><![CDATA[Machine Learning]]></category><category><![CDATA[Tutorial]]></category><dc:creator><![CDATA[Indirakumar S]]></dc:creator><pubDate>Wed, 03 Aug 2022 14:24:56 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1659362213865/JtBgk0uDA.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-what-is-a-machine-learning-model">What is a Machine Learning Model?</h1>
<p>The machine learning model is a sector which can be trained and tested with specific data to recognise the pattern. we can prepare a model with selected datasets to perform a particular task. Our developer datasets well practise the model in the development stage. Then the model is evaluated by the client's dataset. The quality of the model will be based on the result's accuracy. In other words, the result explains the functionality and how deeply the model works on the datasets.</p>
<h1 id="heading-why-do-we-need-machine-learning-models">Why do we need Machine Learning Models?</h1>
<p> Machine Learning Models are like a brain part of Machine learning. Without brains we can't do anything like that so without models machine learning cannot be implemented.</p>
<h2 id="heading-example">Example</h2>
<p>A baby doesn't know how a cat and dog look. While growing up, the child will recognise the animal and say it is a cow and it is a dog by its characteristics. Here, Cat and Dog are the object and its characteristics are the input data. Whether, the object much similarly behave like cat's characteristics then the model confirms the object is cat. This kind of analysing and evaluating process is done on Machine Learning model.</p>
<h1 id="heading-classification-of-models">Classification of Models</h1>
<p>There are three learning models for algorithms that are based on various business objectives and data sources. Every machine learning algorithm gravitates toward one of the following three models:</p>
<ul>
<li><p>Supervised Learning</p>
</li>
<li><p>Unsupervised Learning</p>
</li>
<li><p>Reinforcement Learning</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1659355629113/Rr0tnRddC.png" alt="Supervised Learning.png" /></p>
<h1 id="heading-workflow-of-model">Workflow of Model</h1>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1659359618718/r1ybDxZg5.png" alt="0_ni1MrmdmPb3OiZm6.png" /></p>
<p><strong>1-Explore &amp; Process Data:</strong></p>
<p>You are aware that machines initially learn from the information you provide them with. It is crucial to gather trustworthy data so that your machine learning model can identify the proper patterns. How accurate your model is will depend on the quality of the data you provide the computer. Inaccurate or out-of-date data will result in inaccurate results or predictions that are irrelevant.</p>
<p>As it will directly impact the result of your model, be sure to obtain data from a reputable source. Good data is pertinent, has few duplicated and missing information, and accurately represents all of the classifications and subcategories that are there. You must arrange your data after you receive it. This is possible by</p>
<p>Combining and randomising all of the data you have. This makes sure that the distribution of the data is fair and that the learning process is unaffected by the ordering. Cleaning the data to get rid of unnecessary information, missing values, duplicate values, rows, and columns, data type conversion, etc. The dataset's rows, columns, and index of rows and columns may even need to be changed. Visualize the data to comprehend its organisation and the connections between the many variables and classes it contains. Dividing the cleaned data into two sets, one for training and the other for testing. The set that your model learns from is called the training set. After training, your model's accuracy is tested using a testing set.</p>
<p><strong>2-Modelling:</strong></p>
<p>The most crucial phase of machine learning is training. To detect patterns and generate predictions, you feed your machine learning model the prepared data during training. As a result, the model gains knowledge from the data to complete the given task. The model improves in prediction over time with training.</p>
<p>You must evaluate your model's performance after training it. To do this, the model's performance is evaluated using data that has never been seen before. The testing set into which you previously divided our data is the unseen data used. The model is already accustomed to the data and detects the same patterns in it as it did during training, therefore using the same data for testing will result in an inaccurate measurement. You will receive excessively high accuracy as a result. You can accurately gauge the performance and speed of your model by using testing data.</p>
<p><strong>3-Deployment:</strong></p>
<p>Trained and Evaluated models outcome is deployed to production. Deployed production is monitored and altered and re-do the steps again.</p>
<h1 id="heading-conclusion">Conclusion</h1>
<p>I hope this article clearly explained the process of creating a machine learning model. To learn more about machine learning and how to make machine learning models, check out my machine learning series. If you have any questions or doubts, mention them in this article's comments section, and connect with me to learn more about machine learning.</p>
<p>Learning is an interesting habit..!</p>
]]></content:encoded></item><item><title><![CDATA[Javascript Problem Solving(Part 2)]]></title><description><![CDATA[In Part - 1 we have solved five fundamental problems using Javascript. If you missed the Javascript  Problem Solving Part - 1 blog, check it out here
In today’s blog, we will solve another three fundamental problems using Javascript.
Problem - 1: Fil...]]></description><link>https://blog.quasarcommunity.org/javascript-problem-solvingpart-2</link><guid isPermaLink="true">https://blog.quasarcommunity.org/javascript-problem-solvingpart-2</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[webdev]]></category><category><![CDATA[webdesign]]></category><dc:creator><![CDATA[Anusha V]]></dc:creator><pubDate>Sun, 31 Jul 2022 16:39:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1659273133596/egdw0QqdS.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In Part - 1 we have solved five fundamental problems using Javascript. If you missed the Javascript  Problem Solving Part - 1 blog, check it out <a target="_blank" href="https://blog.quasarcommunity.org/javascript-problem-solving">here</a></p>
<p>In today’s blog, we will solve another three fundamental problems using Javascript.</p>
<h1 id="heading-problem-1-filter-the-negative-numbers-in-an-array">Problem - 1: Filter the negative numbers in an array</h1>
<h2 id="heading-program-algorithm">Program Algorithm:</h2>
<p><strong>Step-1:</strong> Start the Program.</p>
<p><strong>Step-2:</strong> Declare the array inside the variable name i.e., arr.</p>
<p><strong>Step-3:</strong> we will use a Javascript in-built filter() function used to filter the array elements, which will filter the array of elements that satisfy the particular condition(i.e., it should display only the array elements which are greater than -1.).</p>
<p><strong>Step-4:</strong> Inside the filter() function, we will give the condition as the call-back function and it will filter out the array elements.</p>
<p><strong>Step-5:</strong> The resultant will also be in an array and it is stored in the res_arr variable.</p>
<p><strong>Step-6:</strong> End the Program.</p>
<h2 id="heading-program-code">Program Code:</h2>
<pre><code><span class="hljs-string">let</span> <span class="hljs-string">arr</span> <span class="hljs-string">=</span> [<span class="hljs-number">1</span>,<span class="hljs-number">-8</span>,<span class="hljs-number">5</span>,<span class="hljs-number">6</span>,<span class="hljs-number">-4</span>,<span class="hljs-number">-2</span>,<span class="hljs-number">-1</span>,<span class="hljs-number">0</span>,<span class="hljs-number">7</span>,<span class="hljs-number">9</span>,<span class="hljs-number">3</span>]<span class="hljs-string">;</span>
<span class="hljs-string">let</span> <span class="hljs-string">res_arr</span> <span class="hljs-string">=</span> <span class="hljs-string">arr.filter(</span>
    <span class="hljs-string">function</span> <span class="hljs-string">result(a){</span>
        <span class="hljs-string">return</span> <span class="hljs-string">a</span> <span class="hljs-string">&gt;-1</span>
    <span class="hljs-string">}</span>
    <span class="hljs-string">)</span>
<span class="hljs-string">console.log(res_arr);</span> <span class="hljs-string">//[</span> <span class="hljs-number">1</span><span class="hljs-string">,</span> <span class="hljs-number">5</span><span class="hljs-string">,</span> <span class="hljs-number">6</span><span class="hljs-string">,</span> <span class="hljs-number">0</span><span class="hljs-string">,</span> <span class="hljs-number">7</span><span class="hljs-string">,</span> <span class="hljs-number">9</span><span class="hljs-string">,</span> <span class="hljs-number">3</span> <span class="hljs-string">]</span>
</code></pre><h1 id="heading-problem-2-remove-the-spaces-found-in-a-string">Problem - 2: Remove the spaces found in a string</h1>
<h2 id="heading-program-algorithm">Program Algorithm:</h2>
<p><strong>Step-1:</strong> Start the program.</p>
<p><strong>Step-2:</strong> Declare the str variable with blank spaces in front and back of the string characters.</p>
<p><strong>Step-3:</strong> we will use the inbuilt trim() function in Javascript to trim the empty blank spaces in a string.</p>
<p><strong>Step-4:</strong> at last, we will store the output in the res_str variable.</p>
<p><strong>Step-5:</strong> End the Program.</p>
<h2 id="heading-program-code">Program Code:</h2>
<pre><code>let str <span class="hljs-operator">=</span> <span class="hljs-string">"     I love Programming      "</span>;
let res_str <span class="hljs-operator">=</span> str.trim(<span class="hljs-string">" "</span>);
console.log(res_str);
</code></pre><h2 id="heading-note">Note:-</h2>
<p>We will use the trim() while sending input data from the server to the database. For example, when a user needs to give his name in his/her input field named Name, if he/she fills it with spaces in front or back of the name. It will create an issue while storing the data in the database. So, if we use trim() - it automatically trims the empty space and sends the data to the database.</p>
<h1 id="heading-problem-3-celsius-to-fahrenheit-and-fahrenheit-to-celsius">Problem - 3: Celsius to Fahrenheit and Fahrenheit to Celsius</h1>
<h2 id="heading-program-algorithm">Program Algorithm:</h2>
<p><strong>Step-1:</strong> Start the Program.</p>
<p><strong>Step-2:</strong> To convert celsius to Fahrenheit we will use the formula(i.e., divide the celsius value by 1.8 and add 32 to it.</p>
<p><strong>Step-3:</strong> Here, we will use the basic function concept to get the result and at last we will console the result.</p>
<p><strong>Step-4:</strong> Procedure to convert Fahrenheit To Celsius and only the formula to convert varies. The formula is we will subtract the Fahrenheit value by 32 and divide it by 1.8.</p>
<p><strong>Step-5:</strong> End the Program.</p>
<h2 id="heading-program-code">Program Code:</h2>
<pre><code><span class="hljs-comment">// celsiusToFahrenheit</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">celsiusToFahrenheit</span>(<span class="hljs-params">d</span>)
</span>{
    <span class="hljs-keyword">return</span> d <span class="hljs-operator">*</span> <span class="hljs-number">1.8</span> <span class="hljs-operator">+</span> <span class="hljs-number">32</span>;
}
let ctf_result <span class="hljs-operator">=</span> celsiusToFahrenheit(<span class="hljs-number">20</span>);
console.log(ctf_result); <span class="hljs-comment">//68</span>

<span class="hljs-comment">// fahrenheitToCelsius</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">fahrenheitToCelsius</span>(<span class="hljs-params">n</span>)
</span>{
    <span class="hljs-keyword">return</span> (n <span class="hljs-operator">-</span> <span class="hljs-number">32</span>) <span class="hljs-operator">/</span> <span class="hljs-number">1.8</span>;
}
let ftc_result <span class="hljs-operator">=</span> fahrenheitToCelsius(<span class="hljs-number">68</span>);
console.log(ftc_result); <span class="hljs-comment">//20</span>
</code></pre><p>In the next blog, we will explore arrays and their methods in Javascript.</p>
]]></content:encoded></item><item><title><![CDATA[K-means Clustering]]></title><description><![CDATA[Clustering
Clustering is the process of dividing the dataset into groups, or clusters. The objective is to divide the data into clusters where points are very similar to one another and distinct from one another. Clustering algorithms assign (or pred...]]></description><link>https://blog.quasarcommunity.org/k-means-clustering</link><guid isPermaLink="true">https://blog.quasarcommunity.org/k-means-clustering</guid><category><![CDATA[Machine Learning]]></category><category><![CDATA[algorithm]]></category><category><![CDATA[K means Clustering ]]></category><category><![CDATA[Elbow method]]></category><category><![CDATA[Silhouette method]]></category><dc:creator><![CDATA[Indirakumar S]]></dc:creator><pubDate>Wed, 27 Jul 2022 15:48:16 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1658925115758/HYagTDUQh.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-clustering">Clustering</h1>
<p>Clustering is the process of dividing the dataset into groups, or clusters. The objective is to divide the data into clusters where points are very similar to one another and distinct from one another. Clustering algorithms assign (or predict) a number to each data point, indicating which cluster that specific point belongs to, similarly to classification algorithms.</p>
<h1 id="heading-k-means-clustering">K-Means Clustering</h1>
<p>One of the simplest and most popular clustering techniques is k-means clustering. It looks for cluster centres that are typical of particular data regions. Two steps are alternated in the algorithm:
Each cluster centre is established as the mean of the given data points after each data point is assigned to the closest cluster centre.
When instances are assigned to clusters consistently, the method is complete.</p>
<p>Initially, define a target number K, which refers to the number of centroids you need in the dataset. A centroid is an imaginary or actual location representing the centre of the cluster. The K-means algorithm identifies the K number of centroids, then allocates every data point to the nearest cluster while keeping the centroids as small as possible. To process the learning data, the K-means algorithm in data mining starts with the first group of randomly selected centroids, which are used as the beginning points for every cluster, and then performs iterative (repetitive) calculations to optimize the positions of the centroids. It halts after creating and optimizing clusters when either the centroids have stabilized i.e. there is no change in their values because the clustering has been successful or the defined number of iterations has been achieved.</p>
<h1 id="heading-algorithmic-steps-for-k-means-clustering">Algorithmic Steps for K-Means Clustering</h1>
<p>Step 1 : Let X = {X1,X2,…,Xn} be the set of data points. </p>
<p>Step 2: Arbitrarily select ‘K’ cluster centres denoted as C1, C2,..., Ck. </p>
<p>Step 3: Calculate the distance between each data point with the cluster centres by 
using any distance measurers. </p>
<p>Step 4: Assign the data points to the cluster centre whose distance from the cluster 
the centre is minimum with respect to other cluster centres. </p>
<p>Step 5: Recalculate the distance between each data point and its centres to get new 
cluster centres using mean. </p>
<p>Step 6: Repeat from step 3 till there is no change in the cluster centre </p>
<h1 id="heading-methods">Methods</h1>
<p> Let's discuss the methods used to find the optimal number of k clusters</p>
<h2 id="heading-elbow-method">Elbow Method</h2>
<p>The Elbow method looks at the total within-cluster sum of squares (WSS) as a function 
of the number of clusters. One should choose a number of clusters so that adding another 
cluster doesn’t improve much better the total WSS. The total WSS measures the 
compactness of the clustering and we want it to be as small as possible. WSS is the sum of 
squares used to determine the optimal value of K. The formula to find WSS is given as </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1658922927551/wRP2G0lTe.png" alt="image.png" class="image--center mx-auto" /></p>
<p>Where pi represents the data point and q(i) represents the cluster centre.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1658925227860/lAxvk61bc.jpg" alt="Optimal-number-of-clusters-with-the-elbow-method-for-Scenario-1_Q640.jpg" /></p>
<h2 id="heading-average-silhouette-method">Average Silhouette Method</h2>
<p>The Silhouette method is used for the interpretation and validation of consistency within clusters of data. It provides a graphical representation of how well each object has been classified. It measures the quality of a clustering. That is, it determines how well each object lies within its cluster. A high average silhouette width indicates a good clustering. The average silhouette method computes the average silhouette of observations for different values of K. The optimal number of clusters K is the one that maximizes the average silhouette over a range of possible values for K.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1658925337957/CYHNLxvMQ.jpeg" alt="images (7).jpeg" /></p>
<h2 id="heading-gap-statistic-method">Gap Statistic Method</h2>
<p>The gap statistic approach can be applied to any clustering method. The gap statistic compares the total within intra-cluster variation for different values of K with their expected values under the null reference distribution of the data. The estimate of the optimal clusters will be the value that maximizes the gap statistic. This means that the clustering structure is far away from the random uniform distribution of points. </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1658925451144/wrLide8xq.png" alt="images.png" /></p>
<p>We will learn new things in the upcoming blog, until connect with me and share this blog with your friends and colleagues!....💖.</p>
]]></content:encoded></item><item><title><![CDATA[Create your own 🤖jarvis using python]]></title><description><![CDATA[Introduction
As we know Python is a suitable language for scriptwriters and developers. Let’s write a script for Voice Assistant using Python. The query for the assistant can be manipulated as per the user’s need. Speech recognition is the process of...]]></description><link>https://blog.quasarcommunity.org/create-your-own-jarvis-using-python</link><guid isPermaLink="true">https://blog.quasarcommunity.org/create-your-own-jarvis-using-python</guid><category><![CDATA[Python]]></category><category><![CDATA[virtual assistant]]></category><category><![CDATA[Tutorial]]></category><category><![CDATA[Python 3]]></category><category><![CDATA[python projects]]></category><dc:creator><![CDATA[Vasanth kumar k]]></dc:creator><pubDate>Tue, 26 Jul 2022 14:36:10 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1658841052263/vb8CG57HT.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-introduction">Introduction</h1>
<p>As we know Python is a suitable language for scriptwriters and developers. Let’s write a script for Voice Assistant using Python. The query for the assistant can be manipulated as per the user’s need. Speech recognition is the process of converting audio into text. This is commonly used in voice assistants like Alexa, Siri, etc. Python provides an API called SpeechRecognition to allow us to convert audio into text for further processing. In this article, we will look at converting large or long audio files into text using the SpeechRecognition API in python. </p>
<h1 id="heading-modules-required">Modules Required</h1>
<p>Subprocess:- This module is used to get system subprocess details used in various commands i.e Shutdown, Sleep, etc. This module comes built-in with Python. </p>
<p>WolframAlpha:- It is used to compute expert-level answers using Wolfram’s algorithms, knowledgebase, and AI technology. To install this module type the below command in the terminal.</p>
<p>Pyttsx3:- This module is used for the conversion of text to speech in a program it works offline. To install this module type the below command in the terminal.</p>
<p>Tkinter:- This module is used for building GUI and comes inbuilt with Python. This module comes built-in with Python. </p>
<p>Wikipedia:- As we all know Wikipedia is a great source of knowledge just like GeeksforGeeks we have used the Wikipedia module to get information from Wikipedia or to perform a Wikipedia search. To install this module type the below command in the terminal.</p>
<p>Speech Recognition:- Since we’re building an Application of voice assistant, one of the most important things in this is that your assistant recognizes your voice (means what you want to say/ ask). To install this module type the below command in the terminal.</p>
<p>Web browser:- To perform Web Search. This module comes built-in with Python. </p>
<p>Ecapture:- To capture images from your Camera. To install this module type the below command in the terminal.</p>
<p>Pyjokes:- Pyjokes is used for the collection of Python Jokes over the Internet. To install this module type the below command in the terminal.</p>
<p>Datetime:- Date and Time are used to showing Date and Time. This module comes built-in with Python. </p>
<p>Twilio:- Twilio is used for making calls and messages. To install this module type the below command in the terminal.</p>
<p>Requests: Requests are used for making GET and POST requests. To install this module type the below command in the terminal.</p>
<p>BeautifulSoup: Beautiful Soup is a library that makes it easy to scrape information from web pages. To install this module type the below command in the terminal.</p>
<h1 id="heading-implementation">Implementation</h1>
<p><strong>Import the below libraries
</strong></p>
<pre><code><span class="hljs-keyword">import</span> subprocess
<span class="hljs-keyword">import</span> wolframalpha
<span class="hljs-keyword">import</span> pyttsx3
<span class="hljs-keyword">import</span> tkinter
<span class="hljs-keyword">import</span> json
<span class="hljs-keyword">import</span> random
<span class="hljs-keyword">import</span> operator
<span class="hljs-keyword">import</span> speech_recognition <span class="hljs-keyword">as</span> sr
<span class="hljs-keyword">import</span> datetime
<span class="hljs-keyword">import</span> wikipedia
<span class="hljs-keyword">import</span> webbrowser
<span class="hljs-keyword">import</span> os
<span class="hljs-keyword">import</span> winshell
<span class="hljs-keyword">import</span> pyjokes
<span class="hljs-keyword">import</span> feedparser
<span class="hljs-keyword">import</span> smtplib
<span class="hljs-keyword">import</span> ctypes
<span class="hljs-keyword">import</span> time
<span class="hljs-keyword">import</span> requests
<span class="hljs-keyword">import</span> shutil
<span class="hljs-title">from</span> twilio.rest <span class="hljs-keyword">import</span> Client
<span class="hljs-title">from</span> clint.textui <span class="hljs-keyword">import</span> progress
<span class="hljs-title">from</span> ecapture <span class="hljs-keyword">import</span> ecapture <span class="hljs-keyword">as</span> ec
<span class="hljs-title">from</span> bs4 <span class="hljs-keyword">import</span> BeautifulSoup
<span class="hljs-keyword">import</span> win32com.client <span class="hljs-keyword">as</span> wincl
<span class="hljs-title">from</span> urllib.request <span class="hljs-keyword">import</span> urlopen
</code></pre><p><strong>Now we will set our engine to Pyttsx3 which is used for text to speech in Python and sapi5 is a Microsoft speech application platform interface we will be using this for text to speech function.</strong></p>
<pre><code>engine <span class="hljs-operator">=</span> pyttsx3.init(<span class="hljs-string">'sapi5'</span>)
voices <span class="hljs-operator">=</span> engine.getProperty(<span class="hljs-string">'voices'</span>)
engine.setProperty(<span class="hljs-string">'voice'</span>, voices[<span class="hljs-number">1</span>].id)
</code></pre><p><strong>You can change the voice Id to “0” for the Male voice while using assistant here we are using a Female voice for all text to speech</strong></p>
<pre><code><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">speak</span>(<span class="hljs-params">audio</span>):</span>
    engine.say(audio)
    engine.runAndWait()

<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">wishMe</span>():</span>
    hour = int(datetime.datetime.now().hour)
    <span class="hljs-keyword">if</span> hour&gt;= <span class="hljs-number">0</span> <span class="hljs-keyword">and</span> hour&lt;<span class="hljs-number">12</span>:
        speak(<span class="hljs-string">"Good Morning Sir !"</span>)

    <span class="hljs-keyword">elif</span> hour&gt;= <span class="hljs-number">12</span> <span class="hljs-keyword">and</span> hour&lt;<span class="hljs-number">18</span>:
        speak(<span class="hljs-string">"Good Afternoon Sir !"</span>)

    <span class="hljs-keyword">else</span>:
        speak(<span class="hljs-string">"Good Evening Sir !"</span>)

    assname =(<span class="hljs-string">"Jarvis 1 point o"</span>)
    speak(<span class="hljs-string">"I am your Assistant"</span>)
    speak(assname)


<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">username</span>():</span>
    speak(<span class="hljs-string">"What should i call you sir"</span>)
    uname = takeCommand()
    speak(<span class="hljs-string">"Welcome Mister"</span>)
    speak(uname)
    columns = shutil.get_terminal_size().columns

    print(<span class="hljs-string">"#####################"</span>.center(columns))
    print(<span class="hljs-string">"Welcome Mr."</span>, uname.center(columns))
    print(<span class="hljs-string">"#####################"</span>.center(columns))

    speak(<span class="hljs-string">"How can i Help you, Sir"</span>)

<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">takeCommand</span>():</span>

    r = sr.Recognizer()

    <span class="hljs-keyword">with</span> sr.Microphone() <span class="hljs-keyword">as</span> source:

        print(<span class="hljs-string">"Listening..."</span>)
        r.pause_threshold = <span class="hljs-number">1</span>
        audio = r.listen(source)

    <span class="hljs-keyword">try</span>:
        print(<span class="hljs-string">"Recognizing..."</span>)
        query = r.recognize_google(audio, language =<span class="hljs-string">'en-in'</span>)
        print(<span class="hljs-string">f"User said: <span class="hljs-subst">{query}</span>\n"</span>)

    <span class="hljs-keyword">except</span> Exception <span class="hljs-keyword">as</span> e:
        print(e)
        print(<span class="hljs-string">"Unable to Recognize your voice."</span>)
        <span class="hljs-keyword">return</span> <span class="hljs-string">"None"</span>

    <span class="hljs-keyword">return</span> query

<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">sendEmail</span>(<span class="hljs-params">to, content</span>):</span>
    server = smtplib.SMTP(<span class="hljs-string">'smtp.gmail.com'</span>, <span class="hljs-number">587</span>)
    server.ehlo()
    server.starttls()

    <span class="hljs-comment"># Enable low security in gmail</span>
    server.login(<span class="hljs-string">'your email id'</span>, <span class="hljs-string">'your email password'</span>)
    server.sendmail(<span class="hljs-string">'your email id'</span>, to, content)
    server.close()
</code></pre><p><strong>Main Function starts here, we will now call all these functions in the main function.</strong></p>
<pre><code><span class="hljs-keyword">if</span> __name__ == <span class="hljs-string">'__main__'</span>:
    clear = <span class="hljs-keyword">lambda</span>: os.system(<span class="hljs-string">'cls'</span>)

    <span class="hljs-comment"># This Function will clean any</span>
    <span class="hljs-comment"># command before execution of this python file</span>
    clear()
    wishMe()
    username()

    <span class="hljs-keyword">while</span> <span class="hljs-literal">True</span>:

        query = takeCommand().lower()

        <span class="hljs-comment"># All the commands said by user will be</span>
        <span class="hljs-comment"># stored here in 'query' and will be</span>
        <span class="hljs-comment"># converted to lower case for easily</span>
        <span class="hljs-comment"># recognition of command</span>
        <span class="hljs-keyword">if</span> <span class="hljs-string">'wikipedia'</span> <span class="hljs-keyword">in</span> query:
            speak(<span class="hljs-string">'Searching Wikipedia...'</span>)
            query = query.replace(<span class="hljs-string">"wikipedia"</span>, <span class="hljs-string">""</span>)
            results = wikipedia.summary(query, sentences = <span class="hljs-number">3</span>)
            speak(<span class="hljs-string">"According to Wikipedia"</span>)
            print(results)
            speak(results)

        <span class="hljs-keyword">elif</span> <span class="hljs-string">'open youtube'</span> <span class="hljs-keyword">in</span> query:
            speak(<span class="hljs-string">"Here you go to Youtube\n"</span>)
            webbrowser.open(<span class="hljs-string">"youtube.com"</span>)

        <span class="hljs-keyword">elif</span> <span class="hljs-string">'open google'</span> <span class="hljs-keyword">in</span> query:
            speak(<span class="hljs-string">"Here you go to Google\n"</span>)
            webbrowser.open(<span class="hljs-string">"google.com"</span>)

        <span class="hljs-keyword">elif</span> <span class="hljs-string">'open stackoverflow'</span> <span class="hljs-keyword">in</span> query:
            speak(<span class="hljs-string">"Here you go to Stack Over flow.Happy coding"</span>)
            webbrowser.open(<span class="hljs-string">"stackoverflow.com"</span>)

        <span class="hljs-keyword">elif</span> <span class="hljs-string">'play music'</span> <span class="hljs-keyword">in</span> query <span class="hljs-keyword">or</span> <span class="hljs-string">"play song"</span> <span class="hljs-keyword">in</span> query:
            speak(<span class="hljs-string">"Here you go with music"</span>)
            <span class="hljs-comment"># music_dir = "G:\\Song"</span>
            music_dir = <span class="hljs-string">"C:\\Users\\GAURAV\\Music"</span>
            songs = os.listdir(music_dir)
            print(songs)
            random = os.startfile(os.path.join(music_dir, songs[<span class="hljs-number">1</span>]))

        <span class="hljs-keyword">elif</span> <span class="hljs-string">'the time'</span> <span class="hljs-keyword">in</span> query:
            strTime = datetime.datetime.now().strftime(<span class="hljs-string">"% H:% M:% S"</span>)
            speak(<span class="hljs-string">f"Sir, the time is <span class="hljs-subst">{strTime}</span>"</span>)

        <span class="hljs-keyword">elif</span> <span class="hljs-string">'open opera'</span> <span class="hljs-keyword">in</span> query:
            codePath = <span class="hljs-string">r"C:\\Users\\GAURAV\\AppData\\Local\\Programs\\Opera\\launcher.exe"</span>
            os.startfile(codePath)

        <span class="hljs-keyword">elif</span> <span class="hljs-string">'email to gaurav'</span> <span class="hljs-keyword">in</span> query:
            <span class="hljs-keyword">try</span>:
                speak(<span class="hljs-string">"What should I say?"</span>)
                content = takeCommand()
                to = <span class="hljs-string">"Receiver email address"</span>
                sendEmail(to, content)
                speak(<span class="hljs-string">"Email has been sent !"</span>)
            <span class="hljs-keyword">except</span> Exception <span class="hljs-keyword">as</span> e:
                print(e)
                speak(<span class="hljs-string">"I am not able to send this email"</span>)

        <span class="hljs-keyword">elif</span> <span class="hljs-string">'send a mail'</span> <span class="hljs-keyword">in</span> query:
            <span class="hljs-keyword">try</span>:
                speak(<span class="hljs-string">"What should I say?"</span>)
                content = takeCommand()
                speak(<span class="hljs-string">"whome should i send"</span>)
                to = input()
                sendEmail(to, content)
                speak(<span class="hljs-string">"Email has been sent !"</span>)
            <span class="hljs-keyword">except</span> Exception <span class="hljs-keyword">as</span> e:
                print(e)
                speak(<span class="hljs-string">"I am not able to send this email"</span>)

        <span class="hljs-keyword">elif</span> <span class="hljs-string">'how are you'</span> <span class="hljs-keyword">in</span> query:
            speak(<span class="hljs-string">"I am fine, Thank you"</span>)
            speak(<span class="hljs-string">"How are you, Sir"</span>)

        <span class="hljs-keyword">elif</span> <span class="hljs-string">'fine'</span> <span class="hljs-keyword">in</span> query <span class="hljs-keyword">or</span> <span class="hljs-string">"good"</span> <span class="hljs-keyword">in</span> query:
            speak(<span class="hljs-string">"It's good to know that your fine"</span>)

        <span class="hljs-keyword">elif</span> <span class="hljs-string">"change my name to"</span> <span class="hljs-keyword">in</span> query:
            query = query.replace(<span class="hljs-string">"change my name to"</span>, <span class="hljs-string">""</span>)
            assname = query

        <span class="hljs-keyword">elif</span> <span class="hljs-string">"change name"</span> <span class="hljs-keyword">in</span> query:
            speak(<span class="hljs-string">"What would you like to call me, Sir "</span>)
            assname = takeCommand()
            speak(<span class="hljs-string">"Thanks for naming me"</span>)

        <span class="hljs-keyword">elif</span> <span class="hljs-string">"what's your name"</span> <span class="hljs-keyword">in</span> query <span class="hljs-keyword">or</span> <span class="hljs-string">"What is your name"</span> <span class="hljs-keyword">in</span> query:
            speak(<span class="hljs-string">"My friends call me"</span>)
            speak(assname)
            print(<span class="hljs-string">"My friends call me"</span>, assname)

        <span class="hljs-keyword">elif</span> <span class="hljs-string">'exit'</span> <span class="hljs-keyword">in</span> query:
            speak(<span class="hljs-string">"Thanks for giving me your time"</span>)
            exit()

        <span class="hljs-keyword">elif</span> <span class="hljs-string">"who made you"</span> <span class="hljs-keyword">in</span> query <span class="hljs-keyword">or</span> <span class="hljs-string">"who created you"</span> <span class="hljs-keyword">in</span> query:
            speak(<span class="hljs-string">"I have been created by Gaurav."</span>)

        <span class="hljs-keyword">elif</span> <span class="hljs-string">'joke'</span> <span class="hljs-keyword">in</span> query:
            speak(pyjokes.get_joke())

        <span class="hljs-keyword">elif</span> <span class="hljs-string">"calculate"</span> <span class="hljs-keyword">in</span> query:

            app_id = <span class="hljs-string">"Wolframalpha api id"</span>
            client = wolframalpha.Client(app_id)
            indx = query.lower().split().index(<span class="hljs-string">'calculate'</span>)
            query = query.split()[indx + <span class="hljs-number">1</span>:]
            res = client.query(<span class="hljs-string">' '</span>.join(query))
            answer = next(res.results).text
            print(<span class="hljs-string">"The answer is "</span> + answer)
            speak(<span class="hljs-string">"The answer is "</span> + answer)

        <span class="hljs-keyword">elif</span> <span class="hljs-string">'search'</span> <span class="hljs-keyword">in</span> query <span class="hljs-keyword">or</span> <span class="hljs-string">'play'</span> <span class="hljs-keyword">in</span> query:

            query = query.replace(<span class="hljs-string">"search"</span>, <span class="hljs-string">""</span>)
            query = query.replace(<span class="hljs-string">"play"</span>, <span class="hljs-string">""</span>)        
            webbrowser.open(query)

        <span class="hljs-keyword">elif</span> <span class="hljs-string">"who i am"</span> <span class="hljs-keyword">in</span> query:
            speak(<span class="hljs-string">"If you talk then definitely your human."</span>)

        <span class="hljs-keyword">elif</span> <span class="hljs-string">"why you came to world"</span> <span class="hljs-keyword">in</span> query:
            speak(<span class="hljs-string">"Thanks to Gaurav. further It's a secret"</span>)

        <span class="hljs-keyword">elif</span> <span class="hljs-string">'power point presentation'</span> <span class="hljs-keyword">in</span> query:
            speak(<span class="hljs-string">"opening Power Point presentation"</span>)
            power = <span class="hljs-string">r"C:\\Users\\GAURAV\\Desktop\\Minor Project\\Presentation\\Voice Assistant.pptx"</span>
            os.startfile(power)

        <span class="hljs-keyword">elif</span> <span class="hljs-string">'is love'</span> <span class="hljs-keyword">in</span> query:
            speak(<span class="hljs-string">"It is 7th sense that destroy all other senses"</span>)

        <span class="hljs-keyword">elif</span> <span class="hljs-string">"who are you"</span> <span class="hljs-keyword">in</span> query:
            speak(<span class="hljs-string">"I am your virtual assistant created by Gaurav"</span>)

        <span class="hljs-keyword">elif</span> <span class="hljs-string">'reason for you'</span> <span class="hljs-keyword">in</span> query:
            speak(<span class="hljs-string">"I was created as a Minor project by Mister Gaurav "</span>)

        <span class="hljs-keyword">elif</span> <span class="hljs-string">'change background'</span> <span class="hljs-keyword">in</span> query:
            ctypes.windll.user32.SystemParametersInfoW(<span class="hljs-number">20</span>,
                                                    <span class="hljs-number">0</span>,
                                                    <span class="hljs-string">"Location of wallpaper"</span>,
                                                    <span class="hljs-number">0</span>)
            speak(<span class="hljs-string">"Background changed successfully"</span>)

        <span class="hljs-keyword">elif</span> <span class="hljs-string">'open bluestack'</span> <span class="hljs-keyword">in</span> query:
            appli = <span class="hljs-string">r"C:\\ProgramData\\BlueStacks\\Client\\Bluestacks.exe"</span>
            os.startfile(appli)

        <span class="hljs-keyword">elif</span> <span class="hljs-string">'news'</span> <span class="hljs-keyword">in</span> query:

            <span class="hljs-keyword">try</span>:
                jsonObj = urlopen(<span class="hljs-string">'''https://newsapi.org / v1 / articles?source = the-times-of-india&amp;sortBy = top&amp;apiKey =\\times of India Api key\\'''</span>)
                data = json.load(jsonObj)
                i = <span class="hljs-number">1</span>

                speak(<span class="hljs-string">'here are some top news from the times of india'</span>)
                print(<span class="hljs-string">'''=============== TIMES OF INDIA ============'''</span>+ <span class="hljs-string">'\n'</span>)

                <span class="hljs-keyword">for</span> item <span class="hljs-keyword">in</span> data[<span class="hljs-string">'articles'</span>]:

                    print(str(i) + <span class="hljs-string">'. '</span> + item[<span class="hljs-string">'title'</span>] + <span class="hljs-string">'\n'</span>)
                    print(item[<span class="hljs-string">'description'</span>] + <span class="hljs-string">'\n'</span>)
                    speak(str(i) + <span class="hljs-string">'. '</span> + item[<span class="hljs-string">'title'</span>] + <span class="hljs-string">'\n'</span>)
                    i += <span class="hljs-number">1</span>
            <span class="hljs-keyword">except</span> Exception <span class="hljs-keyword">as</span> e:

                print(str(e))


        <span class="hljs-keyword">elif</span> <span class="hljs-string">'lock window'</span> <span class="hljs-keyword">in</span> query:
                speak(<span class="hljs-string">"locking the device"</span>)
                ctypes.windll.user32.LockWorkStation()

        <span class="hljs-keyword">elif</span> <span class="hljs-string">'shutdown system'</span> <span class="hljs-keyword">in</span> query:
                speak(<span class="hljs-string">"Hold On a Sec ! Your system is on its way to shut down"</span>)
                subprocess.call(<span class="hljs-string">'shutdown / p /f'</span>)

        <span class="hljs-keyword">elif</span> <span class="hljs-string">'empty recycle bin'</span> <span class="hljs-keyword">in</span> query:
            winshell.recycle_bin().empty(confirm = <span class="hljs-literal">False</span>, show_progress = <span class="hljs-literal">False</span>, sound = <span class="hljs-literal">True</span>)
            speak(<span class="hljs-string">"Recycle Bin Recycled"</span>)

        <span class="hljs-keyword">elif</span> <span class="hljs-string">"don't listen"</span> <span class="hljs-keyword">in</span> query <span class="hljs-keyword">or</span> <span class="hljs-string">"stop listening"</span> <span class="hljs-keyword">in</span> query:
            speak(<span class="hljs-string">"for how much time you want to stop jarvis from listening commands"</span>)
            a = int(takeCommand())
            time.sleep(a)
            print(a)

        <span class="hljs-keyword">elif</span> <span class="hljs-string">"where is"</span> <span class="hljs-keyword">in</span> query:
            query = query.replace(<span class="hljs-string">"where is"</span>, <span class="hljs-string">""</span>)
            location = query
            speak(<span class="hljs-string">"User asked to Locate"</span>)
            speak(location)
            webbrowser.open(<span class="hljs-string">"https://www.google.nl / maps / place/"</span> + location + <span class="hljs-string">""</span>)

        <span class="hljs-keyword">elif</span> <span class="hljs-string">"camera"</span> <span class="hljs-keyword">in</span> query <span class="hljs-keyword">or</span> <span class="hljs-string">"take a photo"</span> <span class="hljs-keyword">in</span> query:
            ec.capture(<span class="hljs-number">0</span>, <span class="hljs-string">"Jarvis Camera "</span>, <span class="hljs-string">"img.jpg"</span>)

        <span class="hljs-keyword">elif</span> <span class="hljs-string">"restart"</span> <span class="hljs-keyword">in</span> query:
            subprocess.call([<span class="hljs-string">"shutdown"</span>, <span class="hljs-string">"/r"</span>])

        <span class="hljs-keyword">elif</span> <span class="hljs-string">"hibernate"</span> <span class="hljs-keyword">in</span> query <span class="hljs-keyword">or</span> <span class="hljs-string">"sleep"</span> <span class="hljs-keyword">in</span> query:
            speak(<span class="hljs-string">"Hibernating"</span>)
            subprocess.call(<span class="hljs-string">"shutdown / h"</span>)

        <span class="hljs-keyword">elif</span> <span class="hljs-string">"log off"</span> <span class="hljs-keyword">in</span> query <span class="hljs-keyword">or</span> <span class="hljs-string">"sign out"</span> <span class="hljs-keyword">in</span> query:
            speak(<span class="hljs-string">"Make sure all the application are closed before sign-out"</span>)
            time.sleep(<span class="hljs-number">5</span>)
            subprocess.call([<span class="hljs-string">"shutdown"</span>, <span class="hljs-string">"/l"</span>])

        <span class="hljs-keyword">elif</span> <span class="hljs-string">"write a note"</span> <span class="hljs-keyword">in</span> query:
            speak(<span class="hljs-string">"What should i write, sir"</span>)
            note = takeCommand()
            file = open(<span class="hljs-string">'jarvis.txt'</span>, <span class="hljs-string">'w'</span>)
            speak(<span class="hljs-string">"Sir, Should i include date and time"</span>)
            snfm = takeCommand()
            <span class="hljs-keyword">if</span> <span class="hljs-string">'yes'</span> <span class="hljs-keyword">in</span> snfm <span class="hljs-keyword">or</span> <span class="hljs-string">'sure'</span> <span class="hljs-keyword">in</span> snfm:
                strTime = datetime.datetime.now().strftime(<span class="hljs-string">"% H:% M:% S"</span>)
                file.write(strTime)
                file.write(<span class="hljs-string">" :- "</span>)
                file.write(note)
            <span class="hljs-keyword">else</span>:
                file.write(note)

        <span class="hljs-keyword">elif</span> <span class="hljs-string">"show note"</span> <span class="hljs-keyword">in</span> query:
            speak(<span class="hljs-string">"Showing Notes"</span>)
            file = open(<span class="hljs-string">"jarvis.txt"</span>, <span class="hljs-string">"r"</span>)
            print(file.read())
            speak(file.read(<span class="hljs-number">6</span>))

        <span class="hljs-keyword">elif</span> <span class="hljs-string">"update assistant"</span> <span class="hljs-keyword">in</span> query:
            speak(<span class="hljs-string">"After downloading file please replace this file with the downloaded one"</span>)
            url = <span class="hljs-string">'# url after uploading file'</span>
            r = requests.get(url, stream = <span class="hljs-literal">True</span>)

            <span class="hljs-keyword">with</span> open(<span class="hljs-string">"Voice.py"</span>, <span class="hljs-string">"wb"</span>) <span class="hljs-keyword">as</span> Pypdf:

                total_length = int(r.headers.get(<span class="hljs-string">'content-length'</span>))

                <span class="hljs-keyword">for</span> ch <span class="hljs-keyword">in</span> progress.bar(r.iter_content(chunk_size = <span class="hljs-number">2391975</span>),
                                    expected_size =(total_length / <span class="hljs-number">1024</span>) + <span class="hljs-number">1</span>):
                    <span class="hljs-keyword">if</span> ch:
                    Pypdf.write(ch)

        <span class="hljs-comment"># NPPR9-FWDCX-D2C8J-H872K-2YT43</span>
        <span class="hljs-keyword">elif</span> <span class="hljs-string">"jarvis"</span> <span class="hljs-keyword">in</span> query:

            wishMe()
            speak(<span class="hljs-string">"Jarvis 1 point o in your service Mister"</span>)
            speak(assname)

        <span class="hljs-keyword">elif</span> <span class="hljs-string">"weather"</span> <span class="hljs-keyword">in</span> query:

            <span class="hljs-comment"># Google Open weather website</span>
            <span class="hljs-comment"># to get API of Open weather</span>
            api_key = <span class="hljs-string">"Api key"</span>
            base_url = <span class="hljs-string">"http://api.openweathermap.org / data / 2.5 / weather?"</span>
            speak(<span class="hljs-string">" City name "</span>)
            print(<span class="hljs-string">"City name : "</span>)
            city_name = takeCommand()
            complete_url = base_url + <span class="hljs-string">"appid ="</span> + api_key + <span class="hljs-string">"&amp;q ="</span> + city_name
            response = requests.get(complete_url)
            x = response.json()

            <span class="hljs-keyword">if</span> x[<span class="hljs-string">"code"</span>] != <span class="hljs-string">"404"</span>:
                y = x[<span class="hljs-string">"main"</span>]
                current_temperature = y[<span class="hljs-string">"temp"</span>]
                current_pressure = y[<span class="hljs-string">"pressure"</span>]
                current_humidiy = y[<span class="hljs-string">"humidity"</span>]
                z = x[<span class="hljs-string">"weather"</span>]
                weather_description = z[<span class="hljs-number">0</span>][<span class="hljs-string">"description"</span>]
                print(<span class="hljs-string">" Temperature (in kelvin unit) = "</span> +str(current_temperature)+<span class="hljs-string">"\n atmospheric pressure (in hPa unit) ="</span>+str(current_pressure) +<span class="hljs-string">"\n humidity (in percentage) = "</span> +str(current_humidiy) +<span class="hljs-string">"\n description = "</span> +str(weather_description))

            <span class="hljs-keyword">else</span>:
                speak(<span class="hljs-string">" City Not Found "</span>)

        <span class="hljs-keyword">elif</span> <span class="hljs-string">"send message "</span> <span class="hljs-keyword">in</span> query:
                <span class="hljs-comment"># You need to create an account on Twilio to use this service</span>
                account_sid = <span class="hljs-string">'Account Sid key'</span>
                auth_token = <span class="hljs-string">'Auth token'</span>
                client = Client(account_sid, auth_token)

                message = client.messages \
                                .create(
                                    body = takeCommand(),
                                    from_=<span class="hljs-string">'Sender No'</span>,
                                    to =<span class="hljs-string">'Receiver No'</span>
                                )

                print(message.sid)

        <span class="hljs-keyword">elif</span> <span class="hljs-string">"wikipedia"</span> <span class="hljs-keyword">in</span> query:
            webbrowser.open(<span class="hljs-string">"wikipedia.com"</span>)

        <span class="hljs-keyword">elif</span> <span class="hljs-string">"Good Morning"</span> <span class="hljs-keyword">in</span> query:
            speak(<span class="hljs-string">"A warm"</span> +query)
            speak(<span class="hljs-string">"How are you Mister"</span>)
            speak(assname)

        <span class="hljs-comment"># most asked question from google Assistant</span>
        <span class="hljs-keyword">elif</span> <span class="hljs-string">"will you be my gf"</span> <span class="hljs-keyword">in</span> query <span class="hljs-keyword">or</span> <span class="hljs-string">"will you be my bf"</span> <span class="hljs-keyword">in</span> query:
            speak(<span class="hljs-string">"I'm not sure about, may be you should give me some time"</span>)

        <span class="hljs-keyword">elif</span> <span class="hljs-string">"how are you"</span> <span class="hljs-keyword">in</span> query:
            speak(<span class="hljs-string">"I'm fine, glad you me that"</span>)

        <span class="hljs-keyword">elif</span> <span class="hljs-string">"i love you"</span> <span class="hljs-keyword">in</span> query:
            speak(<span class="hljs-string">"It's hard to understand"</span>)

        <span class="hljs-keyword">elif</span> <span class="hljs-string">"what is"</span> <span class="hljs-keyword">in</span> query <span class="hljs-keyword">or</span> <span class="hljs-string">"who is"</span> <span class="hljs-keyword">in</span> query:

            <span class="hljs-comment"># Use the same API key</span>
            <span class="hljs-comment"># that we have generated earlier</span>
            client = wolframalpha.Client(<span class="hljs-string">"API_ID"</span>)
            res = client.query(query)

            <span class="hljs-keyword">try</span>:
                <span class="hljs-keyword">print</span> (next(res.results).text)
                speak (next(res.results).text)
            <span class="hljs-keyword">except</span> StopIteration:
                <span class="hljs-keyword">print</span> (<span class="hljs-string">"No results"</span>)

        <span class="hljs-comment"># elif "" in query:</span>
            <span class="hljs-comment"># Command go here</span>
            <span class="hljs-comment"># For adding more commands</span>
</code></pre><h1 id="heading-outro">Outro</h1>
<p>And that's how you create your own personal assistant using python.
You can alter some commands as your wish and make them more personalized as your wish. Subscribe and follow to quasar community blogs for more tech content</p>
]]></content:encoded></item><item><title><![CDATA[R programming - Data Structures]]></title><description><![CDATA[In the previous article, we discussed data structures and their types. In this blog, we will discuss the same elaborately. 
So there are various types of data structures :
1. Vectors
Vectors are the most basic data structures in R. It consists of Bas...]]></description><link>https://blog.quasarcommunity.org/r-programming-data-structures</link><guid isPermaLink="true">https://blog.quasarcommunity.org/r-programming-data-structures</guid><category><![CDATA[Data Science]]></category><category><![CDATA[R Language]]></category><dc:creator><![CDATA[Hitendra K]]></dc:creator><pubDate>Thu, 21 Jul 2022 17:46:33 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1658422679401/fni5GvDeu.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In the previous article, we discussed data structures and their types. In this blog, we will discuss the same elaborately. </p>
<p>So there are various types of data structures :</p>
<h3 id="heading-1-vectors">1. Vectors</h3>
<p>Vectors are the most basic data structures in R. It consists of Basic data types of a given length. These are one-dimensional data structures.
There are various operations we can perform in vectors.</p>
<p><strong>Vector arithmetic:</strong></p>
<p>Arithmetic operations like addition, subtraction, and multiplication can be performed and the result is obtained as a vector datatype.</p>
<pre><code>var1 <span class="hljs-operator">&lt;</span><span class="hljs-operator">-</span> c(<span class="hljs-number">3</span>,<span class="hljs-number">8</span>,<span class="hljs-number">4</span>,<span class="hljs-number">5</span>,<span class="hljs-number">0</span>,<span class="hljs-number">11</span>)
var2 <span class="hljs-operator">&lt;</span><span class="hljs-operator">-</span> c(<span class="hljs-number">4</span>,<span class="hljs-number">11</span>,<span class="hljs-number">0</span>,<span class="hljs-number">8</span>,<span class="hljs-number">1</span>,<span class="hljs-number">2</span>)

<span class="hljs-comment">// Vector addition.</span>
add.result <span class="hljs-operator">&lt;</span><span class="hljs-operator">-</span> var1<span class="hljs-operator">+</span>var2 
print(add.result)

<span class="hljs-comment">// Vector subtraction.</span>
sub.result <span class="hljs-operator">&lt;</span><span class="hljs-operator">-</span> var1<span class="hljs-operator">-</span>var2 
print(sub.result)

<span class="hljs-comment">// Vector multiplication.</span>
multi.result <span class="hljs-operator">&lt;</span><span class="hljs-operator">-</span> var1<span class="hljs-operator">*</span>var2 
print(multi.result)

<span class="hljs-comment">// Vector division.</span>
divi.result <span class="hljs-operator">&lt;</span><span class="hljs-operator">-</span> var1<span class="hljs-operator">/</span>var2 
print(divi.result)

<span class="hljs-comment">//output</span>
<span class="hljs-number">7</span> <span class="hljs-number">19</span> <span class="hljs-number">4</span> <span class="hljs-number">13</span> <span class="hljs-number">1</span> <span class="hljs-number">13</span>

<span class="hljs-number">-1</span> <span class="hljs-number">-3</span> <span class="hljs-number">4</span> <span class="hljs-number">-3</span> <span class="hljs-number">-1</span> <span class="hljs-number">9</span>
<span class="hljs-number">12</span> <span class="hljs-number">88</span> <span class="hljs-number">0</span> <span class="hljs-number">40</span> <span class="hljs-number">0</span> <span class="hljs-number">22</span>
<span class="hljs-number">0</span><span class="hljs-number">.7500000</span> <span class="hljs-number">0</span><span class="hljs-number">.7272727</span>  <span class="hljs-number">0</span><span class="hljs-number">.6250000</span> <span class="hljs-number">0</span><span class="hljs-number">.0000000</span> <span class="hljs-number">5.5000000</span>
</code></pre><p><strong>Vector Element Recycling</strong></p>
<p>vectors with an unequal number of elements can be solved using arithmetic operations. The elements of the smaller vector are recycled to complete the operations.</p>
<pre><code>var1 <span class="hljs-operator">&lt;</span><span class="hljs-operator">-</span> c(<span class="hljs-number">3</span>,<span class="hljs-number">8</span>,<span class="hljs-number">4</span>,<span class="hljs-number">5</span>,<span class="hljs-number">0</span>,<span class="hljs-number">11</span>)
var2 <span class="hljs-operator">&lt;</span><span class="hljs-operator">-</span> c(<span class="hljs-number">4</span>,<span class="hljs-number">11</span>)

add.result <span class="hljs-operator">&lt;</span><span class="hljs-operator">-</span> var1<span class="hljs-operator">+</span>var2
print(add.result)

sub.result <span class="hljs-operator">&lt;</span><span class="hljs-operator">-</span> var1<span class="hljs-operator">-</span>var2
print(sub.result)

<span class="hljs-comment">//output</span>
<span class="hljs-number">7</span> <span class="hljs-number">19</span> <span class="hljs-number">8</span> <span class="hljs-number">16</span> <span class="hljs-number">4</span> <span class="hljs-number">22</span>
<span class="hljs-number">-1</span> <span class="hljs-number">-3</span> <span class="hljs-number">0</span> <span class="hljs-number">-6</span> <span class="hljs-number">-4</span> <span class="hljs-number">0</span>
</code></pre><h3 id="heading-2-lists">2. Lists</h3>
<p>A list is an ordered collection of objects. It consists of a mixture of various data types. Therefore, A list can be defined as a special type of vector in which each element can be a different type. </p>
<p><strong>Manipulating List elements</strong></p>
<p>We can add, delete and update list elements. But we can update any element. </p>
<pre><code>list2 <span class="hljs-operator">&lt;</span><span class="hljs-operator">-</span> list(matrix(c(<span class="hljs-number">3</span>,<span class="hljs-number">9</span>,<span class="hljs-number">5</span>,<span class="hljs-number">1</span>,<span class="hljs-number">-2</span>,<span class="hljs-number">8</span>), nrow <span class="hljs-operator">=</span> <span class="hljs-number">2</span>), c(<span class="hljs-string">"Jan"</span>,<span class="hljs-string">"Feb"</span>,<span class="hljs-string">"Mar"</span>), list(<span class="hljs-number">3</span>,<span class="hljs-number">4</span>,<span class="hljs-number">5</span>))
list2[<span class="hljs-number">4</span>] <span class="hljs-operator">&lt;</span><span class="hljs-operator">-</span> “HELLO”
print(list2[<span class="hljs-number">4</span>])

<span class="hljs-comment">//output</span>
<span class="hljs-string">"Hello"</span>
</code></pre><h3 id="heading-3-dataframes">3. Dataframes</h3>
<p>A dataframe is a table or a two-dimensional array-like structure in which each column contains the value of one variable and each row contains one set of values from each column.</p>
<p>Example of Dataframe:</p>
<pre><code>Name <span class="hljs-operator">=</span> c(<span class="hljs-string">"Amiya"</span>, <span class="hljs-string">"Raj"</span>, <span class="hljs-string">"Asish"</span>)
Language <span class="hljs-operator">=</span> c(<span class="hljs-string">"R"</span>, <span class="hljs-string">"Python"</span>, <span class="hljs-string">"Java"</span>)
Age <span class="hljs-operator">=</span> c(<span class="hljs-number">22</span>, <span class="hljs-number">25</span>, <span class="hljs-number">45</span>)
df <span class="hljs-operator">=</span> data.frame(Name, Language, Age)
print(df)

<span class="hljs-comment">//Output</span>
   Name  Language  Age
<span class="hljs-number">1</span>  Amiya        R          <span class="hljs-number">22</span>
<span class="hljs-number">2</span>  Raj         Python    <span class="hljs-number">25</span>
<span class="hljs-number">3</span>  Asish     Java        <span class="hljs-number">45</span>
</code></pre><h3 id="heading-4-matrices">4. Matrices</h3>
<p>A matrix is an arrangement of numbers in rows and columns. Rows are the horizontally aligned values and vertically aligned values are called columns.</p>
<p>To create a matrix in R you need to use the function called matrix. </p>
<pre><code><span class="hljs-string">A</span> <span class="hljs-string">=</span> <span class="hljs-string">matrix(</span>

    <span class="hljs-string">c(1,</span> <span class="hljs-number">2</span><span class="hljs-string">,</span> <span class="hljs-number">3</span><span class="hljs-string">,</span> <span class="hljs-number">4</span><span class="hljs-string">,</span> <span class="hljs-number">5</span><span class="hljs-string">,</span> <span class="hljs-number">6</span><span class="hljs-string">,</span> <span class="hljs-number">7</span><span class="hljs-string">,</span> <span class="hljs-number">8</span><span class="hljs-string">,</span> <span class="hljs-number">9</span><span class="hljs-string">),</span>


    <span class="hljs-string">nrow</span> <span class="hljs-string">=</span> <span class="hljs-number">3</span><span class="hljs-string">,</span> <span class="hljs-string">ncol</span> <span class="hljs-string">=</span> <span class="hljs-number">3</span><span class="hljs-string">,</span> 

    <span class="hljs-string">byrow</span> <span class="hljs-string">=</span> <span class="hljs-literal">TRUE</span>                            
<span class="hljs-string">)</span>

<span class="hljs-string">print(A)</span>

<span class="hljs-string">//output</span>
<span class="hljs-number">1</span> <span class="hljs-number">2</span> <span class="hljs-number">3</span>
<span class="hljs-number">4</span> <span class="hljs-number">5</span> <span class="hljs-number">6</span> 
<span class="hljs-number">7</span> <span class="hljs-number">8</span> <span class="hljs-number">9</span>
</code></pre><h3 id="heading-5-arrays">5. Arrays</h3>
<p>Arrays are data structures which store data of more than two dimensions. An array is a collection of a similar data type with contiguous memory allocation. In R, an array is created with the help of array() function. This function takes a vector as an input and uses the value in the dim parameter to create an array.</p>
<pre><code><span class="hljs-string">A</span> <span class="hljs-string">=</span> <span class="hljs-string">array(</span>

    <span class="hljs-string">c(1,</span> <span class="hljs-number">2</span><span class="hljs-string">,</span> <span class="hljs-number">3</span><span class="hljs-string">,</span> <span class="hljs-number">4</span><span class="hljs-string">,</span> <span class="hljs-number">5</span><span class="hljs-string">,</span> <span class="hljs-number">6</span><span class="hljs-string">,</span> <span class="hljs-number">7</span><span class="hljs-string">,</span> <span class="hljs-number">8</span><span class="hljs-string">),</span>


    <span class="hljs-string">dim</span> <span class="hljs-string">=</span> <span class="hljs-string">c(2,</span> <span class="hljs-number">2</span><span class="hljs-string">,</span> <span class="hljs-number">2</span><span class="hljs-string">)</span>                       
<span class="hljs-string">)</span>

<span class="hljs-string">print(A)</span>

<span class="hljs-string">//output</span>
<span class="hljs-string">,</span> <span class="hljs-string">,</span> <span class="hljs-number">1</span>

   <span class="hljs-number">1</span>     <span class="hljs-number">3</span>
   <span class="hljs-number">2</span>    <span class="hljs-number">4</span>

<span class="hljs-string">,</span> <span class="hljs-string">,</span> <span class="hljs-number">2</span>

    <span class="hljs-number">5</span>    <span class="hljs-number">7</span>
    <span class="hljs-number">6</span>    <span class="hljs-number">8</span>
</code></pre><h3 id="heading-6-factors">6. Factors</h3>
<p>Factors are also data objects that are used to categorize the data and store it as levels. Factors can store both strings and integers. Columns have a limited number of unique values so factors are very useful in columns. They can store both strings and integers. They are useful to categorize unique values in columns like “TRUE” or “FALSE”, or “MALE” or “FEMALE”, etc. It is very useful in data analysis for statistical modelling.</p>
<p>Factors are created with the help of factor() function by taking a vector as an input parameter.</p>
<pre><code>fac = factor(<span class="hljs-built_in">c</span>(<span class="hljs-string">"Male"</span>, <span class="hljs-string">"Female"</span>, <span class="hljs-string">"Male"</span>,
               <span class="hljs-string">"Male"</span>, <span class="hljs-string">"Female"</span>, <span class="hljs-string">"Male"</span>, <span class="hljs-string">"Female"</span>))

<span class="hljs-built_in">print</span>(fac)

<span class="hljs-comment">//output</span>

<span class="hljs-type">Male</span>   <span class="hljs-type">Female</span> <span class="hljs-type">Male</span>   <span class="hljs-type">Male</span>   <span class="hljs-type">Female</span> <span class="hljs-type">Male</span>   <span class="hljs-type">Female</span>
<span class="hljs-type">Levels</span>: <span class="hljs-type">Female</span> <span class="hljs-type">Male</span>
</code></pre><p>That is up for this blog. we can discuss oop's concept libraries in R in the upcoming blogs. Follow Quasar community for more and also do subscribe for our newsletter.</p>
]]></content:encoded></item><item><title><![CDATA[Support Vector Machine(SVM)]]></title><description><![CDATA[RECAP
Previous blog, we learned how to predict the weather and if the weather is fit to play or not. Likely we discuss another interesting machine learning algorithm here.
SVM
Here we are going to introduce another approach to classification using a ...]]></description><link>https://blog.quasarcommunity.org/support-vector-machinesvm</link><guid isPermaLink="true">https://blog.quasarcommunity.org/support-vector-machinesvm</guid><category><![CDATA[Machine Learning]]></category><category><![CDATA[algorithm]]></category><category><![CDATA[Data Science]]></category><category><![CDATA[learn coding]]></category><category><![CDATA[interesting]]></category><dc:creator><![CDATA[Indirakumar S]]></dc:creator><pubDate>Wed, 20 Jul 2022 14:23:45 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1658295083933/Zp051JM4d.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-recap">RECAP</h1>
<p>Previous <a target="_blank" href="https://blog.quasarcommunity.org/naive-bayes">blog</a>, we learned how to predict the weather and if the weather is fit to play or not. Likely we discuss another interesting machine learning algorithm here.</p>
<h1 id="heading-svm">SVM</h1>
<p>Here we are going to introduce another approach to classification using a family of
algorithms called support vector machines. They can work with both linear and non-linear
scenarios, allowing high performance in many different contexts. Together with neural
networks, SVMs probably represent the best choice for many tasks where it's not easy to
find out a good separating hyperplane. 
For example, 
It takes the past data as an input and outputs a line or a hyper-plane which separates the mixed data into classes. If Past data contains both strawberry and apple information to recognize what apples and strawberries look like. That’s SVM in play. It analyses the data and classifies it into one of the two categories based on the labeled data it already has. It will sort the apples under the apple category and the strawberries under the strawberry category. </p>
<h1 id="heading-linear-support-vector-machines">Linear support vector machines</h1>
<p>The fundamental idea behind SVMs is best explained with some pictures.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1654781463993/yeyU1SOy1.png" alt="image.png" /></p>
<p>The two classes can clearly be separated easily with a straight line (they are linearly separable).
The left plot shows the decision boundaries of three possible linear classifiers. The model whose decision boundary is represented by the dashed line is so bad that it does not even separate the classes properly. The other two models work perfectly on this training set, but their decision boundaries come so close to the instances that these models will probably not perform as well on new instances. In contrast, the solid line in the plot on the right represents the decision boundary of an SVM classifier; this line not only separates the two classes but also stays as far away from the closest training instances as possible. You can think of an SVM classifier as fitting the widest possible street (represented by the parallel dashed lines) between the classes. This is called <strong>large margin classification</strong>.</p>
<h1 id="heading-what-is-gamma">What is Gamma?</h1>
<p><strong>Gamma</strong> parameter defines how far the influence of a single training example reaches, with low values meaning ‘far’ and high values meaning ‘close’. The gamma parameters can be seen as the inverse of the radius of influence of samples selected by the model as support vectors.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1658301867432/yD-tckNpn.png" alt="Screenshot_20220720-123705_YouTube (1).png" /></p>
<h1 id="heading-what-is-regularization">What is Regularization?</h1>
<p>The <strong>Regularization parameter</strong> (often termed as C parameter in python’s sklearn library) tells the SVM optimization how much you want to avoid misclassifying each training example. For large values of C, the optimization will choose a smaller-margin hyperplane if that hyperplane does a better job of getting all the training points classified correctly. Conversely, a very small value of C will cause the optimizer to look for a larger-margin separating hyperplane, even if that hyperplane misclassifies more points.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1658306498532/RqlrmvLlm.png" alt="Screenshot_20220720-123744_YouTube.png" /></p>
<h1 id="heading-kernel">Kernel</h1>
<p>SVM algorithms use a set of mathematical functions that are defined as the kernel. The function of kernel is to take data as input and transform it into the required form.</p>
<h1 id="heading-example">Example</h1>
<h2 id="heading-text-classification">Text Classification</h2>
<p>Tool Used: Python IDE</p>
<p>Modules used: <a target="_blank" href="https://pandas.pydata.org/docs/getting_started/index.html">pandas</a>,<a target="_blank" href="https://scikit-learn.org/stable/tutorial/basic/tutorial.html">sklearn</a> </p>
<pre><code><span class="hljs-keyword">import</span> pandas <span class="hljs-keyword">as</span> pd
<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np
<span class="hljs-keyword">from</span> nltk.tokenize <span class="hljs-keyword">import</span> word_tokenize
<span class="hljs-keyword">from</span> nltk <span class="hljs-keyword">import</span> pos_tag
<span class="hljs-keyword">from</span> nltk.corpus <span class="hljs-keyword">import</span> stopwords
<span class="hljs-keyword">from</span> nltk.stem <span class="hljs-keyword">import</span> WordNetLemmatizer
<span class="hljs-keyword">from</span> sklearn.preprocessing <span class="hljs-keyword">import</span> LabelEncoder
<span class="hljs-keyword">from</span> collections <span class="hljs-keyword">import</span> defaultdict
<span class="hljs-keyword">from</span> nltk.corpus <span class="hljs-keyword">import</span> wordnet <span class="hljs-keyword">as</span> wn
<span class="hljs-keyword">from</span> sklearn.feature_extraction.text <span class="hljs-keyword">import</span> TfidfVectorizer
<span class="hljs-keyword">from</span> sklearn <span class="hljs-keyword">import</span> model_selection, naive_bayes, svm
<span class="hljs-keyword">from</span> sklearn.metrics <span class="hljs-keyword">import</span> accuracy_score

<span class="hljs-meta">#Set Random seed</span>
np.random.seed(<span class="hljs-number">500</span>)

# <span class="hljs-keyword">Add</span> the Data <span class="hljs-keyword">using</span> pandas
Corpus = pd.read_csv(r"C:\Users\gunjit.bedi\Desktop\NLP Project\corpus_small.csv",encoding=<span class="hljs-string">'latin-1'</span>)

# Step - <span class="hljs-number">1</span>: Data Pre-processing - This will help <span class="hljs-keyword">in</span> getting better results through the classification algorithms

# Step - <span class="hljs-number">1</span>a : Remove blank <span class="hljs-keyword">rows</span> <span class="hljs-keyword">if</span> <span class="hljs-keyword">any</span>.
Corpus[<span class="hljs-string">'text'</span>].dropna(inplace=<span class="hljs-keyword">True</span>)

# Step - <span class="hljs-number">1</span>b : Change <span class="hljs-keyword">all</span> the <span class="hljs-type">text</span> <span class="hljs-keyword">to</span> lower <span class="hljs-keyword">case</span>. This <span class="hljs-keyword">is</span> required <span class="hljs-keyword">as</span> python interprets <span class="hljs-string">'dog'</span> <span class="hljs-keyword">and</span> <span class="hljs-string">'DOG'</span> differently
Corpus[<span class="hljs-string">'text'</span>] = [entry.lower() <span class="hljs-keyword">for</span> entry <span class="hljs-keyword">in</span> Corpus[<span class="hljs-string">'text'</span>]]

# Step - <span class="hljs-number">1</span>c : Tokenization : <span class="hljs-keyword">In</span> this, <span class="hljs-keyword">each</span> entry <span class="hljs-keyword">in</span> the corpus will be broken <span class="hljs-keyword">into</span> a <span class="hljs-keyword">set</span> <span class="hljs-keyword">of</span> words
Corpus[<span class="hljs-string">'text'</span>]= [word_tokenize(entry) <span class="hljs-keyword">for</span> entry <span class="hljs-keyword">in</span> Corpus[<span class="hljs-string">'text'</span>]]

# Step - <span class="hljs-number">1</span>d : Remove Stop words, Non-<span class="hljs-type">Numeric</span> <span class="hljs-keyword">and</span> <span class="hljs-keyword">perform</span> Word Stemming/Lemmenting.

# WordNetLemmatizer requires Pos tags <span class="hljs-keyword">to</span> understand <span class="hljs-keyword">if</span> the word <span class="hljs-keyword">is</span> noun <span class="hljs-keyword">or</span> verb <span class="hljs-keyword">or</span> adjective etc. <span class="hljs-keyword">By</span> <span class="hljs-keyword">default</span> it <span class="hljs-keyword">is</span> <span class="hljs-keyword">set</span> <span class="hljs-keyword">to</span> Noun
tag_map = defaultdict(lambda : wn.NOUN)
tag_map[<span class="hljs-string">'J'</span>] = wn.ADJ
tag_map[<span class="hljs-string">'V'</span>] = wn.VERB
tag_map[<span class="hljs-string">'R'</span>] = wn.ADV


<span class="hljs-keyword">for</span> <span class="hljs-keyword">index</span>,entry <span class="hljs-keyword">in</span> enumerate(Corpus[<span class="hljs-string">'text'</span>]):
    # Declaring Empty List <span class="hljs-keyword">to</span> store the words that follow the rules <span class="hljs-keyword">for</span> this step
    Final_words = []
    # Initializing WordNetLemmatizer()
    word_Lemmatized = WordNetLemmatizer()
    # pos_tag <span class="hljs-keyword">function</span> below will provide the <span class="hljs-string">'tag'</span> i.e <span class="hljs-keyword">if</span> the word <span class="hljs-keyword">is</span> Noun(N) <span class="hljs-keyword">or</span> Verb(V) <span class="hljs-keyword">or</span> something <span class="hljs-keyword">else</span>.
    <span class="hljs-keyword">for</span> word, tag <span class="hljs-keyword">in</span> pos_tag(entry):
        # Below condition <span class="hljs-keyword">is</span> <span class="hljs-keyword">to</span> <span class="hljs-keyword">check</span> <span class="hljs-keyword">for</span> Stop words <span class="hljs-keyword">and</span> consider <span class="hljs-keyword">only</span> alphabets
        <span class="hljs-keyword">if</span> word <span class="hljs-keyword">not</span> <span class="hljs-keyword">in</span> stopwords.words(<span class="hljs-string">'english'</span>) <span class="hljs-keyword">and</span> word.isalpha():
            word_Final = word_Lemmatized.lemmatize(word,tag_map[tag[<span class="hljs-number">0</span>]])
            Final_words.append(word_Final)
    # The final processed <span class="hljs-keyword">set</span> <span class="hljs-keyword">of</span> words <span class="hljs-keyword">for</span> <span class="hljs-keyword">each</span> iteration will be stored <span class="hljs-keyword">in</span> <span class="hljs-string">'text_final'</span>
    Corpus.loc[<span class="hljs-keyword">index</span>,<span class="hljs-string">'text_final'</span>] = str(Final_words)

<span class="hljs-meta">#print(Corpus['text_final'].head())</span>

# Step - <span class="hljs-number">2</span>: Split the model <span class="hljs-keyword">into</span> Train <span class="hljs-keyword">and</span> Test Data <span class="hljs-keyword">set</span>
Train_X, Test_X, Train_Y, Test_Y = model_selection.train_test_split(Corpus[<span class="hljs-string">'text_final'</span>],Corpus[<span class="hljs-string">'label'</span>],test_size=<span class="hljs-number">0.3</span>)

# Step - <span class="hljs-number">3</span>: Label encode the target variable  - This <span class="hljs-keyword">is</span> done <span class="hljs-keyword">to</span> <span class="hljs-keyword">transform</span> Categorical data <span class="hljs-keyword">of</span> string <span class="hljs-keyword">type</span> <span class="hljs-keyword">in</span> the data <span class="hljs-keyword">set</span> <span class="hljs-keyword">into</span> numerical <span class="hljs-keyword">values</span>
Encoder = LabelEncoder()
Train_Y = Encoder.fit_transform(Train_Y)
Test_Y = Encoder.fit_transform(Test_Y)

# Step - <span class="hljs-number">4</span>: Vectorize the words <span class="hljs-keyword">by</span> <span class="hljs-keyword">using</span> TF-IDF Vectorizer - This <span class="hljs-keyword">is</span> done <span class="hljs-keyword">to</span> find how important a word <span class="hljs-keyword">in</span> the document <span class="hljs-keyword">is</span> <span class="hljs-keyword">in</span> comparison <span class="hljs-keyword">to</span> the corpus
Tfidf_vect = TfidfVectorizer(max_features=<span class="hljs-number">5000</span>)
Tfidf_vect.fit(Corpus[<span class="hljs-string">'text_final'</span>])

Train_X_Tfidf = Tfidf_vect.<span class="hljs-keyword">transform</span>(Train_X)
Test_X_Tfidf = Tfidf_vect.<span class="hljs-keyword">transform</span>(Test_X)


# Step - <span class="hljs-number">5</span>: Now we can run different algorithms <span class="hljs-keyword">to</span> classify <span class="hljs-keyword">out</span> data <span class="hljs-keyword">and</span> <span class="hljs-keyword">check</span> <span class="hljs-keyword">for</span> accuracy

# Classifier - Algorithm - Naive Bayes
# fit the training dataset <span class="hljs-keyword">on</span> the classifier
Naive = naive_bayes.MultinomialNB()
Naive.fit(Train_X_Tfidf,Train_Y)

# predict the labels <span class="hljs-keyword">on</span> validation dataset
predictions_NB = Naive.predict(Test_X_Tfidf)

# Use accuracy_score <span class="hljs-keyword">function</span> <span class="hljs-keyword">to</span> <span class="hljs-keyword">get</span> the accuracy
print("Naive Bayes Accuracy Score -&gt; ",accuracy_score(predictions_NB, Test_Y)*<span class="hljs-number">100</span>)


# Classifier - Algorithm - SVM
# fit the training dataset <span class="hljs-keyword">on</span> the classifier
SVM = svm.SVC(C=<span class="hljs-number">1.0</span>, kernel=<span class="hljs-string">'linear'</span>, degree=<span class="hljs-number">3</span>, gamma=<span class="hljs-string">'auto'</span>)
SVM.fit(Train_X_Tfidf,Train_Y)

# predict the labels <span class="hljs-keyword">on</span> validation dataset
predictions_SVM = SVM.predict(Test_X_Tfidf)

# Use accuracy_score <span class="hljs-keyword">function</span> <span class="hljs-keyword">to</span> <span class="hljs-keyword">get</span> the accuracy
print("SVM Accuracy Score -&gt; ",accuracy_score(predictions_SVM, Test_Y)*<span class="hljs-number">100</span>)
</code></pre><p>From the code we learned how to classify the text and find the accurracy using the dataset.</p>
<p>We will learn new things in the upcoming blog, until connect with me and share this blog with your friends and colleagues!....💖.</p>
]]></content:encoded></item></channel></rss>