<?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 Parishad BehnamGhader on Medium]]></title>
        <description><![CDATA[Stories by Parishad BehnamGhader on Medium]]></description>
        <link>https://medium.com/@parishadbehnam?source=rss-8d11e4a2c1ae------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*gwfj0PHmjM5l3goedTwvug.png</url>
            <title>Stories by Parishad BehnamGhader on Medium</title>
            <link>https://medium.com/@parishadbehnam?source=rss-8d11e4a2c1ae------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 09:47:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@parishadbehnam/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[Knowledge Graph Representation and Applications in Artificial Intelligence]]></title>
            <link>https://medium.com/analytics-vidhya/knowledge-graph-representation-and-applications-in-artificial-intelligence-333099d7f1dd?source=rss-8d11e4a2c1ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/333099d7f1dd</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[graph-representation]]></category>
            <category><![CDATA[knowledge-graph]]></category>
            <dc:creator><![CDATA[Parishad BehnamGhader]]></dc:creator>
            <pubDate>Mon, 07 Sep 2020 20:41:01 GMT</pubDate>
            <atom:updated>2021-05-25T17:52:38.023Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is a Knowledge Graph?</h3><p>A <strong>Knowledge Graph (KG) </strong>is a knowledge base that is represented as a graph structure. Knowledge graphs are often used to store world knowledge and the relations between entities, which can be real-world objects, events, or concepts. KGs are usually formalized as a set of triplets “<em>(h, r, t)</em>” where “<em>h</em>” and “<em>t</em>” are head and tail entities and “<em>r</em>” demonstrates the relationship between. A lot of popular KGs have been introduced by researchers, such as <a href="https://wordnet.princeton.edu/"><em>WordNet</em></a>, <a href="http://dbpedia.org/"><em>DBpedia</em></a>, and <a href="http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.538.7139&amp;rep=rep1&amp;type=pdf"><em>Freebase</em></a><em>. WordNet </em>provides information about semantic relations between words (synonyms, hyponyms, etc.), <em>DBpedia </em>includes factual information from Wikipedia pages, and <em>Freebase </em>is a large-scale KG constructed from various public datasets, containing general knowledge facts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/709/1*kKY-sPREEBT_SSY1Tt7jRA.png" /><figcaption>Popular KGs. Taken from <a href="https://www.glass.ai/glass-news/2020/4/13/building-the-business-knowledge-graph-machine-reading-comprehension-at-web-scale">glass.ai</a>.</figcaption></figure><p>Researchers have also proposed other variations of KGs. For instance, <em>Knowledge Hypergraphs</em> are the ones in which relations take place among any number of entities, and <em>Uncertain Knowledge Graphs</em> provide a confidence score along with every relation fact, usually constructed by crowd-sourcing.</p><h3>What are the applications of KGs in AI?</h3><p>KGs have various applications in several fields of AI, including question answering, natural language processing, recommender systems, etc. We refer to some of the popular ones in this story.</p><p>Knowledge Graphs may be incomplete because storing and qualifying all the facts in the world is difficult. To this end, there have been some research studies on <strong>Knowledge Graph Completion</strong>, which aim at finding new facts based on the given [incomplete] KG. <strong>Link/Relation Prediction</strong> is also another popular task, which predicts the probability of an input triplet being a valid link in the KG. <strong>Entity Alignment</strong> is another task that associates entities in different KGs (probably in different languages) if they are semantically the same. This task is one of the most important tasks since KGs provide rich information in some languages (like English) and don’t in other less common languages. Researchers sometimes use this alignment approach to construct the transition from one language to another.</p><p>KGs can be used in different NLP tasks as well. Sometimes, humans can easily outperform trained models (even the most complicated neural networks) and this is due to the fact that humans retain a huge knowledge about the world as prior knowledge. Researchers believe that KGs can be a perfect substitute for this external knowledge that can be injected into our models. <strong>Question Answering</strong> is a common task performed with the use of KGs. This research can be conducted as one-hop or multi-hop reasoning in the graphs. <strong>Text Classification</strong> and <strong>[Masked] Language Modeling</strong> are other NLP tasks that can be improved with the help of KGs. The task of associating a well-defined concept or piece of knowledge (KG entities) to a natural language text (known as <strong>Text-to-Entity Mapping</strong>)is another common problem in NLP.</p><p>Moreover, Knowledge Graphs play a significant role in Computer Vision tasks. For instance, they can be used in <strong>Zero/Few-Shot Recognition</strong> where there are some categories with zero (or a few) training examples and KGs can provide rich information about the category names, their word embeddings, and their relationship with other categories.</p><h3>How can we represent KGs?</h3><p>The goal of learning KG embeddings is to learn vector representations for each entity (and possibly also relation embeddings for each relation) in the KG. Almost all of the KG embedding models consist of two main modules: the Embedding module and the Scoring module. The former is a model that maps each entity (and maybe each relation) to its corresponding vector representation and the latter is a function that defines the score of any given triplet. Then the whole model is trained with a specific loss function that typically encourages the score of a valid triplet to be higher than that of an invalid triplet (usually generated by negative-sampling). The scoring functions of some of the most popular KG embedding approaches are provided below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nMvJNihpRqsrHoiWavkm6Q.png" /><figcaption>Scoring functions of some popular KG embedding approaches. Taken from [1].</figcaption></figure><h3>References</h3><p>[1] Mrinmaya Sachan. “Knowledge Graph Embedding Compression.” <em>ACL</em>, 2020.<br>[2] Rishab Goel, Seyed Mehran Kazemi, Marcus Brubaker, and Pascal Poupart. “Diachronic Embedding for Temporal Knowledge Graph Completion”.<em>CoRR</em>, 2019.<br>[3] Seyed Mehran Kazemi, and David Poole. “SimplE Embedding for Link Prediction in Knowledge Graphs.” <em>NeurIPS</em>, 2018.<br>[4] Qingheng Zhang, Zequn Sun, Wei Hu, Muhao Chen, Lingbing Guo, and Yuzhong Qu. “Multi-view Knowledge Graph Embedding for Entity Alignment”. <em>IJCAI</em>, 2019.<br>[5] Junwei Bao, Nan Duan, Zhao Yan, Ming Zhou, and Tiejun Zhao. “Constraint-Based Question Answering with Knowledge Graph”. <em>COLING</em>, 2016.<br>[6] Dimitri Kartsaklis, Mohammad Taher Pilehvar, and Nigel Collier. “Mapping Text to Knowledge Graph Entities using Multi-Sense LSTMs”. <em>ACL</em>, 2018.<br>[7] Riquan Chen, Tianshui Chen, Xiaolu Hui, Hefeng Wu, Guanbin Li, and Liang Lin. “Knowledge Graph Transfer Network for Few-Shot Recognition”. <em>AAAI Press</em>, 2020.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=333099d7f1dd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/knowledge-graph-representation-and-applications-in-artificial-intelligence-333099d7f1dd">Knowledge Graph Representation and Applications in Artificial Intelligence</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Classification using linear SVM for beginners]]></title>
            <link>https://medium.com/@parishadbehnam/classification-using-linear-svm-for-beginners-2ea260823e0b?source=rss-8d11e4a2c1ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ea260823e0b</guid>
            <category><![CDATA[linear]]></category>
            <category><![CDATA[classification]]></category>
            <category><![CDATA[support-vector-machine]]></category>
            <category><![CDATA[svm]]></category>
            <dc:creator><![CDATA[Parishad BehnamGhader]]></dc:creator>
            <pubDate>Thu, 03 Sep 2020 11:33:55 GMT</pubDate>
            <atom:updated>2020-09-03T11:33:55.669Z</atom:updated>
            <content:encoded><![CDATA[<p>We will first briefly review what Support Vector Machines are and then, we will classify some data samples using linear SVM by Scikit-Learn in Python.</p><h4>What are <em>Support Vector Machines</em>?</h4><p>With the help of Support Vector Machines (SVMs), we can find a hyperplane that linearly separates data points into two classes. In fact, this hyperplane maximizes the margin between the two classes. The main data points in a dataset, are the support vectors. These data points are the ones that are nearest to the separating hyperplane and changing (or removing) each of them may lead to a change in the decision boundary.</p><h4>Let’s classify some generated data samples!</h4><p>How to generate 2D data samples?</p><pre>import numpy as np<br>import matplotlib.pyplot as plt<br>from sklearn.datasets.samples_generator import make_blobs</pre><pre># Generatint samples<br>X, y = make_blobs(n_samples=100, centers=2, random_state=0, cluster_std=1)</pre><pre># Splitting dataset to a train set and test set<br>from sklearn.model_selection import train_test_split</pre><pre>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)</pre><pre>plt.scatter(X_train[:, 0], X_train[:, 1], s=20, cmap=&#39;winter&#39;, c=y_train)<br>plt.scatter(X_test[:, 0], X_test[:, 1], s=20, cmap=&#39;winter&#39;, c=y_test, marker=&#39;x&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/370/1*q247njuCpleQZ6SZrehhPw.png" /><figcaption>Data samples. Testing data samples are marked with “x”.</figcaption></figure><p>Now, we can readily fit an SVM classifier to classify the data samples. We then plot the decision boundary. We use a “<em>linear</em>” kernel since our data samples can be perfectly separated by a linear classifier. The “<em>C</em>” parameter is also a regularization parameter. A larger <em>C</em> leads to classification with hard-margin approach and thus, smaller margins with fewer misclassified training data samples, while a smaller <em>C</em> leads to soft-margin classification and larger margins even if more training data samples are misclassified.</p><pre># Fitting an SVM classifier to generated samples with linear kernel<br>model = SVC(kernel=&#39;linear&#39;, C=1e2)<br>model.fit(X_train, y_train)</pre><pre># Plotting the SVM decision boundary<br>ax = plt.gca()<br>xlim = ax.get_xlim()</pre><pre># w0.x0 + w1.x1 + b = 0 -&gt; x1 = (- w0.x0 - b) / w1<br>xx = np.linspace(xlim[0], xlim[1])<br>w = model.coef_[0]<br>b = model.intercept_[0]<br>yy = -w[0] / w[1] * xx - b / w[1]<br>plt.plot(xx, yy)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/370/1*uOTUBYKdkQJpRRp54HuoeA.png" /><figcaption>Separating hyperplane (SVM decision boundary)</figcaption></figure><p>Now, suppose we want to plot the margins and support vectors as well as the decision boundary. Note that the margins are the lines with the following characteristic and hence, we can draw margin contour lines at the levels of -1 and 1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F1sKb2W3cifZsqvFGtta3w.png" /></figure><pre># Plotting the SVM decision boundary with margins<br>plt.scatter(X_train[:, 0], X_train[:, 1], c=y_train, s=20, cmap=&#39;winter&#39;)</pre><pre>ax = plt.gca()<br>xlim = ax.get_xlim()<br>ylim = ax.get_ylim()<br>xx = np.linspace(xlim[0], xlim[1])<br>yy = np.linspace(ylim[0], ylim[1])<br>X, Y = np.meshgrid(xx, yy)<br>xy = np.vstack([X.ravel(), Y.ravel()]).T</pre><pre>D = model.decision_function(xy).reshape(X.shape)<br>ax.contour(X, Y, D, levels=[-1, 0, 1], linestyles=[&#39;--&#39;, &#39;-&#39;, &#39;--&#39;])<br>ax.scatter(model.support_vectors_[:, 0], model.support_vectors_[:, 1], s=50)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/370/1*dHaMsGcjbXsfIg6BOlMJ-w.png" /><figcaption>Margins are marked with dashed lines and Support Vectors with large blobs.</figcaption></figure><p>There are also various ways that you can compute the accuracy of your trained SVM classifier. Here, we use the <em>accuracy_score </em>function from <em>scikit-learn</em>.</p><pre>from sklearn.metrics import accuracy_score<br># Printing the accuracy on testing and training data<br>print(accuracy_score(y_test, model.predict(X_test)))<br>print(accuracy_score(y_train, model.predict(X_train)))</pre><p>We get accuracies <em>1.0 </em>for this classifications since clearly the separating hyperplane perfectly classifies both training and testing data. In this example, we used a large<em> C=1e2</em>. Therefore, we almost trained our SVM in a hard-margin manner. You can play with the parameters (especially the clusters’ standard deviations) to generate different samples and see what happens when you change the regularization parameter <em>“C”</em>.</p><h3>References</h3><ol><li>A. Sharifi-Zarchi and M.H. Rohban, <a href="http://ce.sharif.edu/courses/98-99/2/ce550-1/index.php">Machine Learning for Bioinformatics</a><strong>, </strong>Spring 2020</li><li>M. Soleymani, <a href="http://ce.sharif.edu/courses/97-98/1/ce717-2/">Machine Learning</a>, Fall 2018</li><li><a href="https://scikit-learn.org/stable/auto_examples/">Scikit-learn Auto-Examples</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ea260823e0b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>