<?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 ohusiev on Medium]]></title>
        <description><![CDATA[Stories by ohusiev on Medium]]></description>
        <link>https://medium.com/@ohusiev?source=rss-6c6b3a96985f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*PG3pTy2eFuz9F0VFvIMEKg.jpeg</url>
            <title>Stories by ohusiev on Medium</title>
            <link>https://medium.com/@ohusiev?source=rss-6c6b3a96985f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 12:44:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ohusiev/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[Open Data and Open Source for Rooftop Solar Community Estimation on the Fly: The Case of Spain]]></title>
            <link>https://medium.com/stinopys/open-data-and-open-source-for-rooftop-solar-community-estimation-on-the-fly-the-case-of-spain-bd9787b422e4?source=rss-6c6b3a96985f------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd9787b422e4</guid>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[lidar]]></category>
            <category><![CDATA[renewable-energy]]></category>
            <category><![CDATA[gis]]></category>
            <category><![CDATA[spain]]></category>
            <dc:creator><![CDATA[ohusiev]]></dc:creator>
            <pubDate>Thu, 29 Jun 2023 06:32:13 GMT</pubDate>
            <atom:updated>2023-06-29T06:32:13.393Z</atom:updated>
            <content:encoded><![CDATA[<h4>How to make a fast estimation of rooftop helio potential using available open data and open software.</h4><p>The emergence of more comprehensive and higher quality data brings a variety of new opportunities for approaching the preliminary research on local community photovoltaic (PV) potential. This post demonstrates simple steps on how to make a fast but empirical estimation of rooftop potential on the fly using available open data (LiDAR files) and open software (QGIS + plugins), resulting in evidence-based results for a prefeasibility study on PV rooftop potential for neighborhood.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*zaXG9oKGnhx903HtRH8TMQ.png" /><figcaption>AI generated image</figcaption></figure><p>It is worth noting that advancements in open-source software and data availability have the potential to bridge the gap between detailed and simplified models, catering to users who are willing to explore the nuances in just a bit more details. While scholars have made significant contributions in this field, this post focuses on specific steps within a framework that can be valuable for evaluating rooftop potential.</p><p>It can be seen as simple step towards more advanced and efficient methods compared to manual analysis or generalized assumptions in terms of estimating the useful area of local community rooftops for solar technology installation and exploring potential trade-off scenarios. However, it should be noted that it falls short of comprehensive LiDAR studies and advanced ML and AI automated approaches.</p><h4>The beginning</h4><p>The example of Spain has a <a href="https://centrodedescargas.cnig.es/CentroDescargas/catalogo.do?Serie=CAANE">digital geographic information repository</a> (Fig. 1), which, among other data, holds LiDAR data in various resolutions, covering a remarkably high percentage of the populated territory. In our case, we conducted a search by municipality and uploaded the available LiDAR cloud file (*.laz) of the selected territory with a specified resolution of 2 points/m².</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n-ahpht0diDCumkwmz6GiA.png" /><figcaption>Fig 1 . Repository of Geoinformation data of Spain (<a href="https://centrodedescargas.cnig.es/">https://centrodedescargas.cnig.es</a>)</figcaption></figure><p>Following that, we will use the following plugins:</p><ol><li>QuickOSM — to export building footprints.</li><li><a href="https://www.whiteboxgeo.com/manual/wbt_book/qgis_plugin.html">WhiteBox Tool </a>— for cloud point processing, DEM (Digital Elevation Model) and DSM (Digital Surface Model) creation, and rooftop analysis.</li><li>Terrain Shading — providing extra features of ambient occlusion.</li></ol><h4>Cloud Point Processing</h4><p>Having the cloud point file, we export it to QGIS through <em>Layer &gt; Add Point Cloud Layer</em>. For the case of Spain, the proper coordinate system in QGIS is IGNF: ETRS89UTM30 — ETRS89 UTM Nord fuseau 30.</p><blockquote>Important: It may happen that QGIS won’t render the *.laz file, even if the coordinate reference system is correctly inserted. A simple solution for that is to open the *.laz file in any other free program for LiDAR cloud points (such as CloudCompare or even in Whitebox Tools &gt; LIDAR Tools &gt; LazToLas) and save it to *.las format. After that, importing the *.las file (which is an uncompressed .laz file) to QGIS should render without a problem.</blockquote><p>Using the Whitebox plugin (here are the <a href="https://github.com/stefaneichert/OpenLidarToolbox#whitebox-tools">steps to install plugin</a> and <a href="https://github.com/jblindsay/whitebox-tools/issues/50">resolution on possible error of dependencies</a>) we will create the DSM selecting <em>Processing Toolbox &gt; WhiteboxTools &gt; LIDAR Tools &gt; LidarDigitalSurfaceModel</em>. The Input file is our *.las file.</p><p>After receiving the output DSM, we can generate a hillshade file in QGIS on the fly by going to <em>Symbology &gt; Render type</em> and selecting the ‘Hillshade’ option.</p><p>Additionally, with the help of the ‘Terrain Shading’ plugin, we can generate a representation of our territory’s DSM file with ambient occlusion mode by selecting <em>Processing Toolbox &gt; Terrain Shading &gt; Ambient occlusion (skyview)</em>. This will give us Step 1 as shown in Figure 2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R9ukbxokCXAu2n-6uEBz4A.png" /><figcaption>Fig 2. Overall steps stages to the rooftop analysis</figcaption></figure><p>And the “cherry on top” is that by following <em>WhiteboxTools &gt; LidarTools &gt; </em><a href="https://www.whiteboxgeo.com/manual/wbt_book/available_tools/lidar_tools.html#LidarRooftopAnalysis"><em>LidarRooftopAnalysis</em></a> with the *.las file and the building footprint layer ( here exported from OSM using the QuickOSM plugin) as inputs, we can identify roof segments in a LiDAR point cloud only for our specific layer of buildings’ footprint.</p><p>It provides basic justified information on local building stock parameters, such as: slope of roofs, orientation ( ASPECT — azimuth angle in degrees), available useful rooftop area in m2, as it’s presented in Fig 3.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AJ1csscaptIK8n7bkFRBmQ.png" /><figcaption>Fig 3. Demonstration example of results on the fly</figcaption></figure><h4>Conclusions and Warnings</h4><ul><li>All the plugins’ algorithms were executed with their respective reference parameters.</li><li>The identification of rooftop constraints, such as ventilation tubes, HVAC (Heating, Ventilation &amp; Air Conditioning) elements, or other rooftop constructions, is often limited and depends on the initial resolution of the cloud point file.</li><li>Rooftop shapes are often identified with fuzzy borders and errors.</li><li>The approach provides a significantly more justified data output for a semi-automatic feasibility trade-off study related to scenarios of different building use-purpose typologies.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd9787b422e4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/stinopys/open-data-and-open-source-for-rooftop-solar-community-estimation-on-the-fly-the-case-of-spain-bd9787b422e4">Open Data and Open Source for Rooftop Solar Community Estimation on the Fly: The Case of Spain</a> was originally published in <a href="https://medium.com/stinopys">Stinopys</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Energy community through the lenses of smart cities and energy independence]]></title>
            <link>https://medium.com/stinopys/energy-community-through-the-lenses-of-smart-cities-and-energy-independence-b917cc4fc00e?source=rss-6c6b3a96985f------2</link>
            <guid isPermaLink="false">https://medium.com/p/b917cc4fc00e</guid>
            <category><![CDATA[energy]]></category>
            <category><![CDATA[open-data]]></category>
            <category><![CDATA[society]]></category>
            <category><![CDATA[community]]></category>
            <dc:creator><![CDATA[ohusiev]]></dc:creator>
            <pubDate>Tue, 06 Sep 2022 18:37:02 GMT</pubDate>
            <atom:updated>2022-09-08T06:52:13.274Z</atom:updated>
            <content:encoded><![CDATA[<h4>An analytical reflection on the state-of-the-art agenda of energy-oriented technologies implementation within the cities and communities, connecting the challenge of the energy crisis due to European dependence on Russian gas.</h4><p>Looking at EU statistics data, focusing on the residential sector, we can see that households hold more than a quarter (28%) of final energy. At the same time, a closer look at residential energy consumption by sector indicates that natural gas prevails in space heating.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*GAx2pXu4DykX55H0b6HR4w.png" /></figure><p>It is essential to outline what is meant by “energy community” as a conception or entity, focusing on the context of the European Union. According to European Commission <a href="https://data.europa.eu/doi/10.2760/180576">Joint Research Centre</a>, it is a “way to organise collective energy actions around open, democratic participation and governance and the provision of benefits for the members or the local community”.</p><p>With its REPowerEU Communication, the European Commission has laid out a plan to diversify away from Russian gas, which currently makes up 32% of Europe’s residential sector gas consumption. The study analyses the activities addressed throughout technologies to society on the road towards decarbonising cities and communities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F7YjYzwbA7kAGSCffao04w.png" /></figure><p>At the same time, the EU <a href="https://energy.ec.europa.eu/topics/energy-strategy/clean-energy-all-europeans-package_en"><em>Clean Energy for All Europeans</em></a> package brings into the EU legal framework a conception of <em>energy community</em> as a prominent way for citizen as well as community involvement. The goal is to make the energy system more sustainable, with group stakeholders invested in collective energy actions within open, democratic participation towards the decarbonisation of the energy sector. The terms <em>Local Energy Community</em> and <em>Citizen Energy Community</em> are included in legislation referring to common rules for internal electricity markets within the recast of the Energy Directive, while the term <em>Renewable Energy Community</em> is contained in the Renewable energy Directive.</p><p><strong>What is a </strong><a href="https://smart-cities-marketplace.ec.europa.eu/"><strong>Smart Cities Marketplace Platform</strong></a><strong>?</strong> <em>The Smart Cities Marketplace was created by merging the two former Commission projects “Marketplace of the European Innovation Partnership on Smart Cities and Communities” (EIP-SCC) and the “Smart Cities Information System” (SCIS) into one single platform. It is a major market-changing undertaking that aims to bring cities, industries, SMEs, investors, researchers and other smart city actors together</em>.</p><p>By exploring the demonstration sides within the cities an analytical map depicted below allocation demonstration sites and quantitative distribution of this initiatives within the countries around the Europe.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h3IlzYA99-2yNzRQf2f1qQ.png" /><figcaption>Analytical map of smart cities’ and communities’ sites for demonstration activities</figcaption></figure><p>Within the scraping of activity clusters defined within the Platform it is distinguish the share of primary clusters within the number of demonstration sides.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/823/1*XxkuruRUwHcU5KdpvOTfFw.png" /><figcaption>Share of activity clusters within smart cities’ and communities’ sites by number of demonstration initiatives</figcaption></figure><p>To sum up, the “building aspects” activity cluster prevails reinforcing one of the key principles of building renovation, “energy efficiency first” (as well outlined throughout the key documents, such as in the European Green Deal, and the EU strategy on Energy System Integration, Renowation Wave for Europe)with prominent potential to investigate demonstrations sides in the Mediterranean region (e.g. Spain) compared to European Northern countries.</p><p>Plurality of energy activities involves the variety of stakeholders. It poses a need for greater use of sensitivity and trade-off analyses to explore the effects of activities by the design strategies considering the synergies between inclusive and local community-centered approaches and dimensions of sustainability within EU’s REPowerEU Plan.</p><p>In this regard, the vision of frontiers for future study of energy community phenomena as social innovation seen through lenses of spatial-technical feasibility analysis of small residential renewable generation as a solution for the increase in demand problem, the scale of self-sufficiency, socio-economic issues, and social engagement.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b917cc4fc00e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/stinopys/energy-community-through-the-lenses-of-smart-cities-and-energy-independence-b917cc4fc00e">Energy community through the lenses of smart cities and energy independence</a> was originally published in <a href="https://medium.com/stinopys">Stinopys</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Heuristic NLP based pipeline for Horizon 2020 database tematic study. Part 1: Data pre-processing]]></title>
            <link>https://medium.com/stinopys/heuristic-nlp-based-pipeline-for-horizon-2020-database-tematic-study-part-1-data-pre-processing-e245e65e07a9?source=rss-6c6b3a96985f------2</link>
            <guid isPermaLink="false">https://medium.com/p/e245e65e07a9</guid>
            <category><![CDATA[h2020]]></category>
            <category><![CDATA[research]]></category>
            <category><![CDATA[self]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[lifehacks]]></category>
            <dc:creator><![CDATA[ohusiev]]></dc:creator>
            <pubDate>Fri, 17 Jun 2022 23:13:32 GMT</pubDate>
            <atom:updated>2022-06-23T20:18:26.494Z</atom:updated>
            <content:encoded><![CDATA[<h3>Heuristic NLP based pipeline for Horizon 2020 database thematic study. Part 1: Data pre-processing</h3><p>Demonstration of thematic analysis of Horizon 2020 energy projects applies NLP simple tricks, taking your research beyond a simple query search.</p><p>This post is the first out of two parts of publications dedicated to tudy energy practices directed to communities, allocation and generalisation of practices and methods addressed within the projects. The study deals with the H2020 (H2020) database - CORDIS, a primary public repository and portal for disseminating information on all EU-funded research projects and their results in the broadest sense.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/983/1*4wPC17njbtc94EH4SPBTtw.jpeg" /></figure><p>It highlights a path for beginners and Python enthusiasts to explore an open dataset beyond the keywords query.</p><p>In brief, this post is an author’s reflection about heuristic approach as kick-off point to thematic study. The first step described here is a of data-preprocessing procedure that includs stop words removal, tokenization, stemming and n-grams generation. It will be followed by selection n-grams of a certain length as a term (i.e.meaningful semantic expression that can be related to some category) performing manual tagging of generated n-grams within classification categories, projects’ labelling according to tagged terms and ends up with further allocation, visualisation. In the end obtained results will be a interpretatory input for further analysis of Horison 2020 practices understanding energy projects trends itself.</p><p>Our study will be based on the question: <em>how we can look at EU’s highly competitive H2020 energy projects to allocate them within addressed ambitions, activities, and approaches to decarbonisation, for further analysis?</em></p><p>The following steps will be presented here:</p><ol><li><a href="#6e0d">Data export and query filtering</a></li><li><a href="#9337">Tokenization, Lemanization or Stemming</a></li><li><a href="#b447">N-grams Generation</a></li><li><a href="#65b6">Terms Frequency and Next Stage Frontiers</a></li></ol><h4><strong>1. Data export and filtering query</strong></h4><p>At the moment of work performing, the database held 35 326 projects funded under Horizon 2020 programme from 2014 to January 2022. It has a web interface to make a query search, as well as a web application for some exploration and visualisation of Horizon 2020 data. However, our motivation tends to explore open data a little bit “above and beyond”, and that is where an option to use a natural language processing (NLP) as a support tool comes to help.</p><p>The dataset can be easily dowloaded in csv format from <a href="https://data.europa.eu/data/datasets/cordish2020projects?locale=en">Horizon 2020 website</a>. The whole actions done using Python in Jupyter notebook. To begin with, lets upload the open data csv file as pandas DataFrame.</p><pre>cordish2020 = pd.read_csv( &#39;../data/cordis-h2020projects-csv/project.csv&#39;, sep=&#39;;&#39;,error_bad_lines=False)<br>categories = pd.read_excel(&#39;../data/terms_catalogue_query.xls&#39;)<br>categories = categories.fillna(method=&#39;ffill&#39;)<br>categories.columns = [&#39;keywords&#39;]<br>keywords_catalogue = list(categories[&#39;keywords&#39;])</pre><p>We have a resulting dataset in the form tablewith 19 columns of parameters, where each line means the project. Among those the primary specified to: <em>status, title, objective, start date, end date, and budget (“</em>ecMaxContribution”).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*0ZtCK3EXBlGPwpt120sC_w.png" /></figure><p>In addition, as an input file, we have our <a href="https://github.com/ohusiev/enercomm_h2020_categorisation/blob/843a3fafd5b8e84fa525504810059aed3a800644/data/terms_catalogue_query.xls">keywords_catalogue</a> list specified for a filtering query. Following that, simple data preparation was performed such as the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BoLSlGvGyfLlp05mo1M0HA.png" /></figure><p>Now it is time to realise our keywords filtering and for that we will use flashtext Python library, thus addfrom flashtext import KeywordProcessor. Firstly, we write a short function that will produce as output a list(aka column vector) of mathed items from terms catalogue.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/926/1*8fcn417VwOTZSm_dqG-QDw.png" /></figure><p>This block below aimed to take a specified catalogue of terms as a dictionary, and with a help of flashtext KeywordProcessor() iterate the project objective and title columns, pass the arguments to our specified function extract()where each cell in respective column iterated and particular match with the dictionary it returns as array of matched terms.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*Or1_OzfSbc3j-ciTqKVXZQ.png" /></figure><p>In the end we can save resulting DataFrame with interested columns and go ahead with tokenization and stemming. a N-grams generation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_OLT6L3l8k6bsgKdOHioXg.png" /></figure><p><strong>2. Tokenization, Lemanization or Stemming</strong></p><p>Primary we import the libraries, where the main one is nlkt .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k-xfEpDGhQC-Y4t3JJ9rXw.png" /></figure><p>The tokenization procedure is described in various details and is basic within any corpus processing. As a rule, it includes such steps as text cleaning and stop words removal so the code block below provides a function where it was realised together with the stemming procedure, applying PorterStemmer, the most common and pretty often considered effective enough. At this point, stemming (producing morphological variants of a root/base word) chosen over lemmatization (considering a language’s full vocabulary to apply a morphological analysis to words) desided to to be enough within heuristic approach to the problem that we are working on.</p><pre>from nltk.tokenize import word_tokenize<br>from nltk.stem import PorterStemmer<br>porter_stemmer=PorterStemmer()</pre><pre>def only_tokenizer(series, stemmer=True, stop_words=[]):<br>    tokenized_list=[]<br>    if isinstance(series, pd.Series):<br>        text=series.str.cat(sep=&#39; &#39;)<br>    else:<br>        text=series</pre><pre>text = re.sub(r&quot;http\S+&quot;, &quot;&quot;, text) #remove urls<br>    text=re.sub(r&#39;\S+\.com\S+&#39;,&#39;&#39;,text) #remove urls<br>    text=re.sub(r&#39;\@\w+&#39;,&#39;&#39;,text) #remove mentions<br>    text =re.sub(r&#39;\#\w+&#39;,&#39;&#39;,text) #remove hashtags</pre><pre>text=re.sub(r&quot;&quot;&quot;[&#39;’&quot;`«»]&quot;&quot;&quot;, &#39;&#39;, text)<br>    text=re.sub(r&quot;&quot;&quot;([0-9])([\u0400-\u04FF]|[A-z])&quot;&quot;&quot;, r&quot;\1 \2&quot;, text)<br>    text=re.sub(r&quot;&quot;&quot;([\u0400-\u04FF]|[A-z])([0-9])&quot;&quot;&quot;, r&quot;\1 \2&quot;, text)<br>    text=re.sub(r&quot;&quot;&quot;[\-–.,!:+*/_]&quot;&quot;&quot;, &#39; &#39;, text)</pre><pre>for word in word_tokenize(text):<br>        if word.isalpha():<br>            word=word.lower()<br>        else:<br>            continue<br>        if stemmer is True:<br>            word=porter_stemmer.stem(word)<br>        if word not in stop_words and len(word)&gt;1:     <br>            tokenized_list.append(word)<br>    return tokenized_list</pre><p><strong>3. N-grams Generation</strong></p><p>So, we have only_tokenizer function that take for input 3 parameters, corpus (in format of string or pandas Series), stemmer and stop words list. We can create an objective_words list which will hold the whole corpus of our dataset <em>objective </em>field in one list.</p><pre>objective_words <strong>=</strong> only_tokenizer(results_keywordSearch[&#39;objective&#39;], <strong>True</strong>, sw) <br>print(&#39;Length of the objective_words list: {}&#39;<strong>.</strong> format(len (objective_words))) objective_words_unique<strong>=</strong>[]</pre><pre>&gt;&gt;&gt; Length of the objective_words list: 211730<br>&gt;&gt;&gt; Length of the objective_words_unique list: 9626</pre><p>With a few lines of code, we can find out which ngram occurs the most in this particular sample and plot (top 20 ngrams) as bar chat.</p><pre>bigrams_series <strong>=</strong> (pd<strong>.</strong>Series(nltk<strong>.</strong>ngrams(objective_words, 2))<strong>.</strong>value_counts())[:20]<br>bigrams_series<strong>.</strong>sort_values()<strong>.</strong>plot<strong>.</strong>barh (color<strong>=</strong>&#39;blue&#39;, width<strong>=</strong>.9, figsize<strong>=</strong>(12, 8))<br>plt<strong>.</strong>title(&#39;20 Most Frequently Occuring Bigrams&#39;)<br>plt<strong>.</strong>ylabel(&#39;Bigrams&#39;)<br>plt<strong>.</strong>xlabel(&#39;# of Occurances&#39;)</pre><p>As a result in fugures below the bigrams and trigrams graphical output is presented.</p><figure><img alt="Bigrams diagram" src="https://cdn-images-1.medium.com/max/1024/1*ynkGi4tjgZT33eSLYPU4og.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9_mgw6Gu7TziODBvGNEClg.png" /></figure><p>To finalyze, we also check length of corpus and out genereted ngrams. as it seen below the total corpus length is 211 728 elements, with unique unigrams items is equal to 9626 items, bigrams 139133, trigrams 199793.</p><pre>objective_ngrams1<strong>=</strong>pd<strong>.</strong>Series(nltk<strong>.</strong>ngrams(objective_words, 1))<br>print (&#39;\nWhole number of unigram items (terms): &#39;, len(objective_ngrams1))<br>objective_ngrams2<strong>=</strong>objective_ngrams2<strong>.</strong>unique()<em># leave only unique</em><br>print (&#39;Unique  2ngrams terms: &#39;, len(objective_ngrams2))<br>objective_ngrams3<strong>=</strong>objective_ngrams3<strong>.</strong>unique() <em># leave only unique</em><br>print (&#39;Unique 3ngrams terms: &#39;, len(objective_ngrams3))</pre><pre>&gt;&gt;&gt; Whole number of unigram items (terms):  211728<br>&gt;&gt;&gt; Unique  2ngrams terms: 139133<br>&gt;&gt;&gt; Unique 3ngrams terms: 199793</pre><p>The number of ngrams for selected corpus is volumious. After all, the amount of unique unigrams is 9626 which grows in geometric progression for bigrams.</p><p>The <em>bigrams </em>and <em>trigrams </em>terms are considered to be the most adequate for specification of the further manual classification steps, since the unigrams missing the neighbour word to understand the context, while <em>4grams </em>provide the set of terms that are useful to understand but number of combinations increases dramatically to consider them as terms.</p><p>The next bullets points were outlined:</p><ul><li>there is a need to allocate terms by its frequency for further manual categorisation, for that a TF and TF-IDF approach will be applied;</li><li>the bigrams and trigrams will be considered as supplementary for categorization of terms.</li></ul><p><strong>4. Terms Frequency and Next Stage Frontiers</strong></p><p>The general idea of desired output is next: as the whole sample frequency distrition described below doen’t give a picture, the term frequency distribution will be created for word considering it in each projects as following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/334/1*TpVXFoDGuCWJS0nQk5U9hw.png" /></figure><p>After that created DataFrame will be transposed and the frequency sum of each term will be presented as separate column:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/1*bK4dqyOhRDLaRYwGqa54-w.png" /></figure><p>To generate term frequency will use sklearn library with two well known methods being the word’s TF-IDF score or their frequency counts (bag-of-words approach) using CountVectorizer()for term frequency (TF) and TfidfVectorizer() for term frequency — inverse document frequency (TF-IDF).</p><pre><strong>from</strong> sklearn.feature_extraction.text <strong>import</strong> CountVectorizer<br><strong>from</strong> sklearn.feature_extraction.text <strong>import</strong> TfidfVectorizer</pre><p>For creation of abovementioned table of term frequency and TF-IDF, we will put the data into the list, which will hold the token of each of our project, a list of the lists.</p><pre>objective_terms_tokenized <strong>=</strong>[]<br><strong>for</strong> j <strong>in</strong> results_keywordSearch[&#39;objective_tokenized&#39;]:<br>    objective_terms_tokenized<strong>.</strong>append(str(j))</pre><h4>Term Frequency (TF)</h4><pre>BOW_bigram_vectorizer <strong>=</strong> CountVectorizer(analyzer<strong>=</strong>&#39;word&#39;, ngram_range<strong>=</strong>(2, 2))<br>BOW_matrix_bigram <strong>=</strong> BOW_bigram_vectorizer<strong>.</strong>fit_transform(objective_terms_tokenized)<br>BOW_terms_bigram<strong>=</strong>BOW_bigram_vectorizer<strong>.</strong>get_feature_names()<br>terms_bigram_freq <strong>=</strong> BOW_matrix_bigram<strong>.</strong>toarray()</pre><pre>df_BOW_bigram <strong>=</strong> pd<strong>.</strong>DataFrame(index<strong>=</strong>results_keywordSearch<strong>.</strong>index, data<strong>=</strong>terms_bigram_freq,columns <strong>=</strong> BOW_terms_bigram)<br>df_BOW_bigram_transp <strong>=</strong> df_BOW_bigram<strong>.</strong>T<br><br>df_BOW_bigram_transp[&#39;term_treq&#39;] <strong>=</strong> df_BOW_bigram_transp<strong>.</strong>sum(axis<strong>=</strong>1)<br>term_bigram_freq <strong>=</strong> df_BOW_bigram_transp[[&#39;term_treq&#39;]]<br>term_bigram_freq<strong>=</strong>term_bigram_freq<strong>.</strong>sort_values(by<strong>=</strong>[&#39;term_treq&#39;], ascending<strong>=False</strong>)<br>bigrams <strong>=</strong> pd<strong>.</strong>DataFrame(index<strong>=</strong>term_bigram_freq<strong>.</strong>index, data<strong>=</strong>term_bigram_freq)<br>bigrams<strong>.</strong>to_csv(&#39;../data/ngrams/bigrams.csv&#39;)</pre><p>The TF output for bigrams is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/223/1*SOr_8v6PYXpl-35eApig5w.png" /></figure><h4>Term Frequency — Inverse Document Frequency (TF-IDF)</h4><pre>tfidf_bigram_vectorizer <strong>=</strong> TfidfVectorizer(ngram_range<strong>=</strong>(2,2))<br><br>tfidf_bigram <strong>=</strong> tfidf_bigram_vectorizer<strong>.</strong>fit_transform(objective_terms_tokenized)<br>tfidf_terms_name_bigram <strong>=</strong> tfidf_bigram_vectorizer<strong>.</strong>get_feature_names()<br>tfidf_bigram_matrix <strong>=</strong> tfidf_bigram<strong>.</strong>toarray()<br><br>print (tfidf_terms_name_bigram[:5])<br>tfidf_bigram <strong>=</strong> pd<strong>.</strong>DataFrame(index<strong>=</strong>results_keywordSearch<strong>.</strong>index, data<strong>=</strong>tfidf_bigram_matrix,columns <strong>=</strong> tfidf_terms_name_bigram)</pre><pre>tfidf_bigram_transp <strong>=</strong> tfidf_bigram<strong>.</strong>T<br><br>tfidf_bigram_transp[&#39;tf-idf&#39;] <strong>=</strong> tfidf_bigram_transp<strong>.</strong>sum(axis<strong>=</strong>1)<br><br>tfidf_bigram_term_freq <strong>=</strong> tfidf_bigram_transp[[&#39;tf-idf&#39;]]<br>tfidf_bigram_term_freq<strong>=</strong>tfidf_bigram_term_freq[tfidf_bigram_term_freq[&#39;tf-idf&#39;]<strong>&gt;</strong>0.01]<br>tfidf_bigram_term_freq.sort_values(by<strong>=</strong>[&#39;tf-idf&#39;], ascending<strong>=False</strong>)</pre><p>To sum up, a popular word cloud visualisation can be build for presentation on the example of bigrams:</p><pre>bigrams_cloud <strong>=</strong> pd<strong>.</strong>read_csv(&#39;../data/ngrams/bigrams.csv&#39;)<strong><br>from</strong> wordcloud <strong>import</strong> WordCloud<br>d <strong>=</strong> {}<br><strong>for</strong> a, x <strong>in</strong> bigrams_cloud<strong>.</strong>values:<br>    d[a] <strong>=</strong> x<br>wordcloud <strong>=</strong> WordCloud(background_color<strong>=</strong>&quot;white&quot;, width<strong>=</strong>800, height<strong>=</strong>400)<br>wordcloud<strong>.</strong>generate_from_frequencies(frequencies<strong>=</strong>d)<br>plt<strong>.</strong>figure(figsize<strong>=</strong>(15,10))<br>plt<strong>.</strong>imshow(wordcloud, interpolation<strong>=</strong>&quot;bilinear&quot;)<br>plt<strong>.</strong>axis(&quot;off&quot;)<br>plt<strong>.</strong>show()</pre><p>The ouptut is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*USY5YtfivGf6gnRpl5QDRg.png" /><figcaption>Bigrams word cloud of projects corpus</figcaption></figure><p>As a result, we obtain the table with bigrams, their TF and TF-IDF scores, additional supplementary trigrams and/or uni- and 4 grams with corresponding scores for further manual labelling. This output will be used as input data for the Part 2 publication about the manual heuristic classification.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e245e65e07a9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/stinopys/heuristic-nlp-based-pipeline-for-horizon-2020-database-tematic-study-part-1-data-pre-processing-e245e65e07a9">Heuristic NLP based pipeline for Horizon 2020 database tematic study. Part 1: Data pre-processing</a> was originally published in <a href="https://medium.com/stinopys">Stinopys</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>