<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Numpy on Alok Regmi</title>
		<link>https://alokregmi.com/tags/numpy/</link>
		<description>Recent content in Numpy on Alok Regmi</description>
		<generator>Hugo</generator>
		<language>en-us</language>
		
		
		
		
			<lastBuildDate>Sat, 02 May 2020 03:40:18 +0545</lastBuildDate>
		
			<atom:link href="https://alokregmi.com/tags/numpy/index.xml" rel="self" type="application/rss+xml" />
			<item>
				<title>Numpy</title>
				<link>https://alokregmi.com/braindump/2020/04/numpy/</link>
				<pubDate>Sun, 19 Apr 2020 16:00:50 +0545</pubDate>
				<guid>https://alokregmi.com/braindump/2020/04/numpy/</guid>
				<description>&lt;h2 id=&#34;working-with-numpy&#34;&gt;Working with numpy:&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;import numpy as np&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;a = np.array([0,1,2])&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;a.ndim - gives dimension of array&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;a.shape : gives the shape of the array&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;a.reshape((3,2)) new order of matrix to be formed&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;changing a element of an array we reshaped is also going to change from the original since numpy package avoids copies&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;so if copy needed: c= a.reshape((3,2)).copy()&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Contrast to general array operations:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;a*2 multiplies each element by 2&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;alok &amp;gt;4&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;alok[alok&amp;gt;4] trim out using a condition for the array&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;alok.clip(0,4) clipping the data between the range with both ends taken into consideration&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Handle non existing values:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;c= np.array([1,2,np.NAN,3])&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;np.isnan(c) return true false on the basis of the data element in array is number or not&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;c[~np.isnan(c)] remove nan&amp;rsquo;s from the array&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;np.mean(c[~np.isnan(c)]) calculate the mean of the data feed that are only numbers&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;use of dot functions for numpy speeds by almost 25 times the average naive numpy rate&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;by taking list items, numpy auto makes the best possible common datatype for those members&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;</description>
			</item>
			<item>
				<title>Numpy</title>
				<link>https://alokregmi.com/ai/numpy/</link>
				<pubDate>Mon, 02 Dec 2019 00:00:00 +0000</pubDate>
				<guid>https://alokregmi.com/ai/numpy/</guid>
				<description>&lt;h2 id=&#34;working-with-numpy&#34;&gt;Working with numpy:&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;import numpy as np&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;a = np.array([0,1,2])&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;a.ndim - gives dimension of array&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;a.shape : gives the shape of the array&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;a.reshape((3,2)) new order of matrix to be formed&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;changing a element of an array we reshaped is also going to change from the original since numpy package avoids copies&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;so if copy needed: c= a.reshape((3,2)).copy()&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Contrast to general array operations:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;a*2 multiplies each element by 2&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;alok &amp;gt;4&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;alok[alok&amp;gt;4] trim out using a condition for the array&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;alok.clip(0,4) clipping the data between the range with both ends taken into consideration&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Handle non existing values:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;c= np.array([1,2,np.NAN,3])&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;np.isnan(c) return true false on the basis of the data element in array is number or not&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;c[~np.isnan(c)] remove nan&amp;rsquo;s from the array&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;np.mean(c[~np.isnan(c)]) calculate the mean of the data feed that are only numbers&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;use of dot functions for numpy speeds by almost 25 times the average naive numpy rate&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;by taking list items, numpy auto makes the best possible common datatype for those members&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;</description>
			</item>
	</channel>
</rss>
