<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Rojin Safavi on Medium]]></title>
        <description><![CDATA[Stories by Rojin Safavi on Medium]]></description>
        <link>https://medium.com/@rojinsafavi?source=rss-7d6b799d4dd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*piz5Pf3sUZN5iYHTeXtI-Q.png</url>
            <title>Stories by Rojin Safavi on Medium</title>
            <link>https://medium.com/@rojinsafavi?source=rss-7d6b799d4dd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 20:36:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rojinsafavi/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Graph convolutional variational autoencoders]]></title>
            <link>https://medium.com/@rojinsafavi/graph-convolutional-variational-autoencoders-67313708c4f8?source=rss-7d6b799d4dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/67313708c4f8</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[graph-convolution]]></category>
            <dc:creator><![CDATA[Rojin Safavi]]></dc:creator>
            <pubDate>Wed, 01 Jan 2020 20:40:20 GMT</pubDate>
            <atom:updated>2020-01-01T20:40:20.998Z</atom:updated>
            <content:encoded><![CDATA[<p>In this post, I am going to talk about <strong>graph convolutional variational autoencoders</strong>.</p><p>In Graph convolutional variational autoencoders, one tries to reconstruct the <strong>adjacency</strong> matrix at the output, given the <strong>adjacency</strong> and <strong>node</strong> features as the input.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/647/0*sGoKFiTFAeoV89h0.png" /><figcaption><a href="https://github.com/tkipf/gae">https://github.com/tkipf/gae</a></figcaption></figure><p>Similar to vanilla VAE, graph convolutional VAE also has two parts, an encoder, and a decoder. The encoder has a specific structure that allows the encoder to learn the links between nodes.</p><h4><strong>f(X,A) = Relu(ÂXW)</strong></h4><p>Where A is the modified version of the adjacency matrix (I will explain it in the next section), X is the node feature matrix, and W is the weight.</p><h4><strong>What is Â?</strong></h4><p>Â is calculated as follow :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/170/1*MsqZOrLWBHYgIU2BetgKtQ.png" /><figcaption>Adding the self-connections</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/187/1*9LZGoQZyBbXk7i5Ad0YswQ.png" /><figcaption>degree matrix</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/241/1*KWaWEN-kX5RAo_-J81h6qg.png" /><figcaption>Normalization</figcaption></figure><p>(Adapted from <a href="https://github.com/tkipf/gae/blob/master/gae/preprocessing.py">https://github.com/tkipf/gae/blob/master/gae/preprocessing.py</a>)</p><pre><strong>import scipy.sparse as sp<br>import numpy as np</strong></pre><pre><strong>adj = np.matrix([<br>      [0, 1, 0, 0],<br>      [0, 0, 1, 1], <br>      [0, 1, 0, 0],<br>      [1, 0, 1, 0]],<br>      dtype=float)</strong></pre><pre><strong>def</strong> preprocess_graph(adj):</pre><pre>    adj = sp.coo_matrix(adj)<br>    # adj matrix in sparse format</pre><pre><strong>    [[0. 1. 0. 0.]<br>    [0. 0. 1. 1.]<br>    [0. 1. 0. 0.]<br>    [1. 0. 1. 0.]] </strong> <br>  <br>    adj_ = adj + sp.eye(adj.shape[0])<br>    # creating the adj_ matrix  by adding the identity matrix I to the adj to create self connections</pre><pre><strong>    [[1. 1. 0. 0.]<br>    [0. 1. 1. 1.]<br>    [0. 1. 1. 0.]<br>    [1. 0. 1. 1.]]</strong></pre><pre>    rowsum = np.array(adj_.sum(1))<br>    # row sum of adj_ matrix</pre><pre>    <strong>[[2.]<br>    [3.]<br>    [2.]<br>    [3.]]</strong></pre><pre>    degree_mat_inv_sqrt = sp.diags(np.power(rowsum, -0.5).flatten())<br>    # create a sparse diagonal matrix D ̃ −0.5</pre><pre><strong>    [[0.70710678,0.,0.,0.]<br>    [0.,0.57735027 0.,0.]<br>    [0.,0.,0.70710678 0.]<br>    [0.,0.,0.,0.57735027]]</strong></pre><pre>    adj_normalized = adj_.dot(degree_mat_inv_sqrt).transpose().dot(degree_mat_inv_sqrt).tocoo()</pre><pre>    #normalizing</pre><pre><strong>    [[0.5, 0., 0., 0.40824829],<br>    [0.40824829, 0.33333333, 0.40824829, 0.],<br>    [0., 0.40824829, 0.5, 0.40824829],<br>    [0., 0.33333333, 0., 0.33333333]]</strong></pre><pre>    return adj_normalized</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=67313708c4f8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Principle component analysis (PCA)]]></title>
            <link>https://medium.com/@rojinsafavi/principle-component-analysis-pca-dc77dbd6f9f9?source=rss-7d6b799d4dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/dc77dbd6f9f9</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[apc]]></category>
            <dc:creator><![CDATA[Rojin Safavi]]></dc:creator>
            <pubDate>Fri, 27 Dec 2019 02:46:44 GMT</pubDate>
            <atom:updated>2019-12-27T02:46:44.263Z</atom:updated>
            <content:encoded><![CDATA[<p>Principle component analysis is a statistical method used for visualizing high dimensional data. PCA tries to project the data into a lower dimension in a way to capture most of the variations in the data.</p><h4>What do we mean by variation in the data? let’s look at an example.</h4><p>If you look at the bellow scatter plot, you see that the diagonal direction is the one that is capturing most of the variations in the data. So if we wanted to project the point into a 1D dimension, we would choose the diagonal space since it is capturing most of the variations in the data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3GgR-upI8HH81Wb7.png" /><figcaption><a href="https://en.wikipedia.org/wiki/Principal_component_analysis#/media/File:GaussianScatterPCA.svg">https://en.wikipedia.org/wiki/Principal_component_analysis#/media/File:GaussianScatterPCA.svg</a></figcaption></figure><h3><strong>Mathematical derivation of PCA by solving the Eigendecomposition:</strong></h3><p>Here I am showing how you can derive PCA by <strong>Eigendecomposition. </strong>You can always check this video which explains everything pretty well (<a href="https://www.youtube.com/watch?v=ZqXnPcyIAL8">https://www.youtube.com/watch?v=ZqXnPcyIAL8</a>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_cfLKiEJ2MEZswpbtmkrgw.png" /><figcaption>X feature matrix, n sample m features</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/237/1*mlUbQJv3moJ4hC4FbtmHIw.png" /><figcaption>covariance matrix</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HgR1HtxDC9guUz7fW9K4Kg.png" /><figcaption>eigendecomposition of X’X gives <strong>W</strong> (eigenvector) and <strong>λ</strong>(eigenvalue)</figcaption></figure><p>how to find Eigenvalues and Eigenvectors:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ekH8Gbv8rk75FEeS6rnTkg.png" /><figcaption>Example of how eigenvalues and eigenvectors can be found</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m7pgRxv9RRm8wcusnJVuqw.png" /><figcaption>Each column of S is a principal component. <strong>W</strong> columns are ordered based on the <strong>λ </strong>values</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2cCWoJRMF92LI3u_dE8MPg.png" /><figcaption>The first r PCs are shown above</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8mzEqFM3Gy6t8PIywMEbLg.png" /></figure><h3>Mathematical derivation of PCA by Singular Value Decomposition:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*am0eDwKUdmANQzJp6dyoDw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ushwk-jwPqHHJuTbikBfGw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dc77dbd6f9f9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Binomial Distribution]]></title>
            <link>https://medium.com/@rojinsafavi/binomial-distribution-a65dc8866137?source=rss-7d6b799d4dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/a65dc8866137</guid>
            <category><![CDATA[probability]]></category>
            <category><![CDATA[binomial-distribution]]></category>
            <category><![CDATA[statistics]]></category>
            <dc:creator><![CDATA[Rojin Safavi]]></dc:creator>
            <pubDate>Thu, 05 Dec 2019 18:01:22 GMT</pubDate>
            <atom:updated>2019-12-05T18:01:22.944Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-RGwb_VE--3DY5Q6.png" /><figcaption><a href="https://en.wikipedia.org/wiki/Binomial_distribution">https://en.wikipedia.org/wiki/Binomial_distribution</a></figcaption></figure><p>Random Variable X has a binomial distribution with parameters (n,p)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/372/0*EAf7pxrlogp0FqqI.gif" /><figcaption><a href="https://www.s-cool.co.uk/a-level/maths/probability-distributions/revise-it/the-binomial-distribution">https://www.s-cool.co.uk/a-level/maths/probability-distributions/revise-it/the-binomial-distribution</a></figcaption></figure><p>Binomial distribution is defined as, where q = 1-p :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*bR-J81Q7t5AewLmY7GqvBQ.png" /></figure><ul><li>In summary, a sum of independent Bernoulli random variables is a binomial random variable.</li></ul><p>Binomial Expectation:</p><h4><strong>E[x] = np</strong></h4><ul><li>proof:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hZmkGSNHqGCyXt1fpujXeA.png" /><figcaption>E[x] = np</figcaption></figure><h4><strong>Var[x] = np(1-p)</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SKpCZYcMBdLxrUW3Ew_k9w.png" /><figcaption><strong>Var[x] = np(1-p)</strong></figcaption></figure><p>Moment generating function:</p><h4>M(t) = (pe^t + (1-p))^n</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1ipbMhSbyBz_Eu3wz4bztQ.png" /></figure><h3><strong>Bernoulli distribution properties:</strong></h3><ul><li>If the random variables <strong>X1, X2, …, Xn</strong> are n random variables from a <strong>Bernoulli</strong> trial with parameter p, then <strong>X = X1 + X2 + … + Xn</strong> has a <strong>Binomial</strong> distribution with parameters <strong>(n,p)</strong></li><li>If <strong>X1, X2, …, Xk</strong> are <strong>independent</strong> random variables, and <strong>Xi</strong> has the <strong>binomial</strong> distribution with parameters <strong>ni</strong> and <strong>p</strong> <strong>( for example X1 ~B(n1,p) . . . , ~B(nk,p)),</strong> then <strong>X = X1 + X2 + … + Xk</strong> has <strong>binomial</strong> distribution with <strong>parameters</strong> <strong>n = n1 + · · · + nk </strong>and p, <strong>~B(n1 + · · · + nk,p)</strong>.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a65dc8866137" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bernoulli distribution]]></title>
            <link>https://medium.com/@rojinsafavi/bernoulli-distribution-ee0bb075a9aa?source=rss-7d6b799d4dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/ee0bb075a9aa</guid>
            <category><![CDATA[probability]]></category>
            <category><![CDATA[distribution]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[bernoulli]]></category>
            <dc:creator><![CDATA[Rojin Safavi]]></dc:creator>
            <pubDate>Thu, 05 Dec 2019 06:49:21 GMT</pubDate>
            <atom:updated>2019-12-05T06:49:21.739Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/604/0*N9ll2MIxbVJTGLXr" /><figcaption><a href="https://www.kristakingmath.com/blog/bernoulli-random-variables">https://www.kristakingmath.com/blog/bernoulli-random-variables</a></figcaption></figure><p>A random variable has a Bernoulli distribution (with parameter p) if it can only take 2 values ( binary,0 and1)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/0*zU0Vi2-CC6XqyfjI.png" /><figcaption><a href="https://towardsdatascience.com/understanding-bernoulli-and-binomial-distributions-a1eef4e0da8f">https://towardsdatascience.com/understanding-bernoulli-and-binomial-distributions-a1eef4e0da8f</a></figcaption></figure><p>The <strong>Expectation,</strong> <strong>Variance, </strong>and <strong>m.g.f</strong> of Bernoulli distribution is:</p><h4><em>E</em>(<em>X</em>) = p</h4><h4>Var[x] = p(1-p)</h4><h4>M(t) = pe^t + (1-p)</h4><p>derivation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1/0*TvwamWQLyRif2zg2.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OcUy2DkICL9FjQznfwatCg.png" /></figure><p>m.g.f derivation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qi-pA9_kBckBZWRTvvy68A.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ee0bb075a9aa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learning machine learning techniques together!]]></title>
            <link>https://medium.com/@rojinsafavi/learning-machine-learning-techniques-together-ef984057d2?source=rss-7d6b799d4dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/ef984057d2</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Rojin Safavi]]></dc:creator>
            <pubDate>Thu, 05 Dec 2019 01:34:20 GMT</pubDate>
            <atom:updated>2019-12-05T05:51:12.111Z</atom:updated>
            <content:encoded><![CDATA[<p>I believe the best way to learn something, is to teach it to others and put it into words.</p><p>Today, I decided to do what I always wanted to do :-) writing about machine learning and data science techniques! I will try to write one post per week, talking about different machine learning models and review a paper!</p><p>Stay tuned!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ef984057d2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>