<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>data science Archives - Ger Inberg</title>
	<atom:link href="https://gerinberg.com/category/datascience/feed/" rel="self" type="application/rss+xml" />
	<link>https://gerinberg.com/category/datascience/</link>
	<description>data science developer</description>
	<lastBuildDate>Tue, 03 Sep 2024 12:40:01 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.1</generator>

<image>
	<url>https://gerinberg.com/wp-content/uploads/2017/05/favicon-150x150.jpg</url>
	<title>data science Archives - Ger Inberg</title>
	<link>https://gerinberg.com/category/datascience/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>FeatureExtraction on CRAN</title>
		<link>https://gerinberg.com/2024/09/03/featureextraction-on-cran/</link>
		
		<dc:creator><![CDATA[Ger]]></dc:creator>
		<pubDate>Tue, 03 Sep 2024 12:40:01 +0000</pubDate>
				<category><![CDATA[data science]]></category>
		<category><![CDATA[software engineering]]></category>
		<guid isPermaLink="false">https://gerinberg.com/?p=1861</guid>

					<description><![CDATA[<p>Feature engineering is a crucial step in the data science process, often making the difference between a good model and a great one. It involves transforming raw data into meaningful features that can improve the performance of predictive models. For those working in R, the [&#8230;]</p>
<p>The post <a href="https://gerinberg.com/2024/09/03/featureextraction-on-cran/">FeatureExtraction on CRAN</a> appeared first on <a href="https://gerinberg.com">Ger Inberg</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Feature engineering is a crucial step in the data science process, often making the difference between a good model and a great one. It involves transforming raw data into meaningful features that can improve the performance of predictive models. For those working in R, the <strong>FeatureExtraction</strong> package on <a href="https://cran.r-project.org/web/packages/FeatureExtraction/index.html" target="_blank" rel="noopener">CRAN</a> offers a powerful and flexible toolset for automating and streamlining this process.</p>
<p>Originally developed as part of the OHDSI (Observational Health Data Sciences and Informatics) ecosystem, <strong>FeatureExtraction</strong> is particularly well-suited for working with large-scale observational data. In this post, we&#8217;ll explore the package in detail, focusing on its core features, practical applications, and a step-by-step example to help you get started.</p>
<h3>Key Features and Capabilities</h3>
<h4>1. <strong>Automated Feature Generation</strong></h4>
<p><strong>FeatureExtraction</strong> excels at automatically generating a wide range of features from raw data. These features include basic demographic variables like age and gender, as well as more complex attributes derived from longitudinal data, such as the frequency of medical visits or the presence of certain conditions over time.</p>
<h4>2. <strong>Temporal Features</strong></h4>
<p>Temporal data, such as patient histories or time-dependent events, are common in many fields, especially healthcare. <strong>FeatureExtraction</strong> handles temporal data adeptly, allowing users to define time windows relative to key events (e.g., diagnosis dates). This feature is crucial for creating time-sensitive covariates that capture trends and patterns in data over specified periods.</p>
<h4>3. <strong>Custom Feature Extraction</strong></h4>
<p>While the package offers extensive automated capabilities, it also allows for custom feature extraction. Users can define custom covariates and specify how these should be generated from the underlying data, incorporating domain-specific knowledge into the feature engineering process.</p>
<h4>4. <strong>Scalability</strong></h4>
<p>Feature engineering can become computationally intensive, particularly with large datasets. <strong>FeatureExtraction</strong> is designed for scalability, leveraging parallel processing and optimized algorithms to ensure that feature extraction remains efficient even with big data.</p>
<h4>5. <strong>Integration with OHDSI Tools</strong></h4>
<p>As part of the OHDSI ecosystem, <strong>FeatureExtraction</strong> integrates seamlessly with other tools like <strong>PatientLevelPrediction</strong> and <strong>CohortMethod</strong>, enabling a smooth workflow from data extraction to model building and analysis.</p>
<h4>Getting started</h4>
<p>Installing the <strong>FeatureExtraction</strong> package is straightforward. You can install it directly from CRAN using the following command:</p>
<div class="dark bg-gray-950 contain-inline-size rounded-md border-[0.5px] border-token-border-medium">
<div class="flex items-center relative text-token-text-secondary bg-token-main-surface-secondary px-4 py-2 text-xs font-sans justify-between rounded-t-md"><code>install.packages("FeatureExtraction")</code></div>
</div>
<div></div>
<div>Load the package in your R session:</div>
<div></div>
<div><code>library(FeatureExtraction)</code></div>
<div>
<h3>Practical Example: Creating Covariates Based on Other Cohorts</h3>
<p>To illustrate how <strong>FeatureExtraction</strong> can be applied, let&#8217;s walk through an example where we create covariates based on the presence of patients in other cohorts. This is particularly useful in studies where the relationship between different conditions or treatments over time is of interest.</p>
<h4>Step 1: Setting Up the Database Connection</h4>
<p>First, we need to define the connection to our CDM-compliant database:</p>
<p><code>connectionDetails &lt;- createConnectionDetails(dbms = "postgresql",</code><br />
<code>server = "your_server",</code><br />
<code>user = "your_username",</code><br />
<code>password = "your_password")</code><br />
<code>cdmDatabaseSchema &lt;- "your_cdm_schema"</code><br />
<code>cohortDatabaseSchema &lt;- "your_cohort_schema"</code></p>
<h4>Step 2: Define the Cohorts of Interest</h4>
<p>Assume we have a cohort of patients with diabetes and another cohort with a history of cardiovascular disease. We want to create a feature that indicates whether a patient in the diabetes cohort has a prior history of cardiovascular disease.</p>
<p><code># Define cohort IDs (these would be predefined in your database)</code><br />
<code>diabetesCohortId &lt;- 1</code><br />
<code>cvdCohortId &lt;- 2</code></p>
<h4>Step 3: Create the Feature Extraction Settings</h4>
<p>Next, we define the feature extraction settings, specifying that we want to create covariates based on the presence of patients in the cardiovascular disease cohort:</p>
<p><code>covariateSettings &lt;- createCohortBasedCovariateSettings(useDemographicsGender = TRUE,</code><br />
<code>useDemographicsAge = TRUE,</code><br />
<code>cohortId = cvdCohortId,</code><br />
<code>startDay = -365,</code><br />
<code>endDay = 0)</code></p>
<p>In this example, the <code>startDay</code> and <code>endDay</code> parameters define a time window of one year prior to the cohort&#8217;s index date. This means the feature will reflect whether a patient was in the cardiovascular disease cohort within one year before the index date.</p>
<h4>Step 4: Extract the Features</h4>
<p>Now, we extract the features for the diabetes cohort using the settings we defined:</p>
<p><code>covariateData &lt;- getDbCovariateData(connectionDetails = connectionDetails,</code><br />
<code>cdmDatabaseSchema = cdmDatabaseSchema,</code><br />
<code>cohortDatabaseSchema = cohortDatabaseSchema,</code><br />
<code>cohortTable = "cohort",</code><br />
<code>cohortId = diabetesCohortId,</code><br />
<code>covariateSettings = covariateSettings)</code></p>
<p>This function retrieves the covariate data for the specified cohort, based on the feature extraction settings we provided.</p>
<h4>Step 5: Use the Extracted Features</h4>
<p>The extracted features are now available in the <code>covariateData</code> object, which can be used for further analysis, such as model building or cohort characterization.</p>
</div>
<p><code># Explore the covariate data</code><br />
<code>summary(covariateData)</code></p>
<p>This simple example demonstrates how <strong>FeatureExtraction</strong> can be used to create meaningful features based on different cohorts. The package&#8217;s flexibility and scalability make it a powerful tool for a wide range of applications, from small-scale studies to large observational databases.</p>
<p>The post <a href="https://gerinberg.com/2024/09/03/featureextraction-on-cran/">FeatureExtraction on CRAN</a> appeared first on <a href="https://gerinberg.com">Ger Inberg</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>AI Redaction Application</title>
		<link>https://gerinberg.com/2020/12/15/ai-redaction-application/</link>
		
		<dc:creator><![CDATA[Ger]]></dc:creator>
		<pubDate>Tue, 15 Dec 2020 14:32:00 +0000</pubDate>
				<category><![CDATA[data science]]></category>
		<category><![CDATA[AI]]></category>
		<category><![CDATA[redaction]]></category>
		<guid isPermaLink="false">https://gerinberg.com/?p=1548</guid>

					<description><![CDATA[<p>What is redaction? redaction is the blacking out or deletion of text in a document. It is intended to allow the selective disclosure of information in a document while keeping other parts of the document secret. It is common within court documents and in the [&#8230;]</p>
<p>The post <a href="https://gerinberg.com/2020/12/15/ai-redaction-application/">AI Redaction Application</a> appeared first on <a href="https://gerinberg.com">Ger Inberg</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h3>What is redaction?</h3>
<p><span style="color: #202124; font-family: georgia, palatino, serif; font-size: 12pt;">redaction is the blacking out or deletion of text in a document. It is intended to allow the selective disclosure of information in a document while keeping other parts of the document secret. It is common within court documents and in the government. Categories of redacted items are phone numbers, e-mail addresses, bank account numbers, dates and names. It takes quite some time to manually redact documents, but fortunately AI can help to speed up this process. Natural Language Processing (<a href="https://monkeylearn.com/blog/nlp-ai/" target="_blank" rel="noopener">NLP</a>) is a subfield of AI that studies how to analyze and process a piece of natural text. This technology allows us to extract the keywords from the text.</span></p>
<p><span style="color: #202124; font-family: georgia, palatino, serif; font-size: 12pt;"><a href="https://www.slimmer.ai/" target="_blank" rel="noopener">Slimmer AI</a> develops AI software products that support industries, solve real-world challenges and takes professionals into the future. They have developed an API that allows the redaction of PDF files. This API returns the redacted document based on your redaction action (e.g. all phone numbers). I have collaborated with Slimmer AI on building the interface for their new redaction application. </span></p>
<h3>Redaction Application</h3>
<p><span style="color: #202124; font-family: georgia, palatino, serif; font-size: 12pt;">The developed application has the following features:</span></p>
<ul>
<li><span style="color: #202124; font-family: georgia, palatino, serif; font-size: 12pt;">search for keyword(s) in the text, this can be a regular expression</span></li>
<li><span style="color: #202124; font-family: georgia, palatino, serif; font-size: 12pt;">AI search: search for items in a category like phone numbers</span></li>
<li><span style="color: #202124; font-family: georgia, palatino, serif; font-size: 12pt;">select a piece of text in the document </span></li>
<li><span style="color: #202124; font-family: georgia, palatino, serif; font-size: 12pt;">redact the results from the actions above</span></li>
<li><span style="color: #202124; font-family: georgia, palatino, serif; font-size: 12pt;">display the redacted PDF</span></li>
</ul>
<p><span style="color: #202124; font-family: georgia, palatino, serif; font-size: 12pt;">Below you see a screenshot of the application. The left sidebar is the search column where the keyword and AI search can be performed. At the bottom of this sidebar, the results of the search are shown. When a user clicks on a result, it is selected for redaction.</span></p>
<p><span style="color: #202124; font-family: georgia, palatino, serif; font-size: 12pt;">The center of the application contains the document. This is the section where the text selection is performed. Once a piece of text is selected a popup appears that asks if the selected text should be redacted or not. </span></p>
<p><span style="color: #202124; font-family: georgia, palatino, serif; font-size: 12pt;">The right column contains the items that have been selected for redaction. When the user pushes the &#8216;Redact All&#8217; button, the document is processed on the backend and the middle section will show the redacted version of the document.</span></p>
<div class="envira-gallery-feed-output"><img decoding="async" class="envira-gallery-feed-image" src="https://gerinberg.com/wp-content/uploads/2020/12/redacto8-1-1024x486-640x480.png" title="AI Redaction Application" alt="AI Redaction Application" /></div>
<p><span style="color: #202124; font-family: georgia, palatino, serif; font-size: 12pt;">The application uses the <a href="https://mozilla.github.io/pdf.js/" target="_blank" rel="noopener">PDF.JS</a> library for basic functionality like rendering the PDF and selecting some text. It is a free and open source library. There are some commercial libraries that offer more functionality, but they were unrequired. The rest of the technology stack for the application includes Javascript, JQuery, Bootstrap4 and HTML/CSS.</span></p>
<h3>Improvements</h3>
<p><span style="color: #202124; font-family: georgia, palatino, serif; font-size: 12pt;">The application was meant as a Proof of Concept to see if we could create a user-friendly wrapper for the API. Since the current functionality is working well, the application is being further developed. One thing on the improvements list is the option for a rectangle select. So next to redacting a piece of text on a line, like we can do now, this allows the user to redact any rectangular area in the document. </span></p>
<p>The post <a href="https://gerinberg.com/2020/12/15/ai-redaction-application/">AI Redaction Application</a> appeared first on <a href="https://gerinberg.com">Ger Inberg</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Remote data scientists</title>
		<link>https://gerinberg.com/2017/12/18/remote-data-scientists/</link>
					<comments>https://gerinberg.com/2017/12/18/remote-data-scientists/#comments</comments>
		
		<dc:creator><![CDATA[Ger]]></dc:creator>
		<pubDate>Mon, 18 Dec 2017 05:02:25 +0000</pubDate>
				<category><![CDATA[data science]]></category>
		<guid isPermaLink="false">http://gerinberg.com/?p=1038</guid>

					<description><![CDATA[<p>Remote data scientists is a group of people working in the field of data science which do their work (totally) remotely. I recently started this group since it&#8217;s a good way to connect with other data scientists that are in a similar situation. Most of [&#8230;]</p>
<p>The post <a href="https://gerinberg.com/2017/12/18/remote-data-scientists/">Remote data scientists</a> appeared first on <a href="https://gerinberg.com">Ger Inberg</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Remote data scientists is a group of people working in the field of data science which do their work (totally) remotely.</p>
<p>I recently started this group since it&#8217;s a good way to connect with other data scientists that are in a similar situation. Most of us travel quite a bit and face the same challenges like: how to find remote work? Where is a good place to work which has also a data community? But it can also be used to discuss technical challenges and keep up-to-data with cool projects that other people are doing.</p>
<p>Currently, most of the people in the group are staying in Chiang Mai, Thailand. We had our first physical meetup there and we will organize more. I am currently planning to give a workshop about data visualization using R shiny.</p>
<p>If you are also working remotely as a data scientist, please <a href="https://www.facebook.com/groups/1661358100551622/" target="_blank" rel="noopener">join us</a> on facebook!</p>
<p>The post <a href="https://gerinberg.com/2017/12/18/remote-data-scientists/">Remote data scientists</a> appeared first on <a href="https://gerinberg.com">Ger Inberg</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://gerinberg.com/2017/12/18/remote-data-scientists/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>Live collaboration in Shiny apps</title>
		<link>https://gerinberg.com/2017/08/27/live-collaboration-shiny-apps/</link>
		
		<dc:creator><![CDATA[Ger]]></dc:creator>
		<pubDate>Sun, 27 Aug 2017 08:14:48 +0000</pubDate>
				<category><![CDATA[data science]]></category>
		<guid isPermaLink="false">http://gerinberg.com/?p=842</guid>

					<description><![CDATA[<p>Since a couple of years I am using the shiny package in R for interactive data visualization. It started as a tool for exploratory analysis but it&#8217;s getting more popular and it has more use cases now. For example I have helped a client with [&#8230;]</p>
<p>The post <a href="https://gerinberg.com/2017/08/27/live-collaboration-shiny-apps/">Live collaboration in Shiny apps</a> appeared first on <a href="https://gerinberg.com">Ger Inberg</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Since a couple of years I am using the shiny package in R for interactive data visualization. It started as a tool for exploratory analysis but it&#8217;s getting more popular and it has more use cases now. For example I have helped a client with building a production dashboard to monitor industry devices in (near) real time. Also, I notice there is a growing need of editing data and collaboration between multiple users.</p>
<p>So when I watched some videos of the UseR conference, the <a href="https://channel9.msdn.com/events/useR-international-R-User-conferences/useR-International-R-User-2017-Conference/shinycollections-Google-Docs-like-live-collaboration-in-Shiny?term=Collaboration">google docs like collaboration with shiny video</a> draw my attention.</p>
<p>The developers of the shiny collections package make use of a reactive database (RethinkDB). In short, this is a database that you don&#8217;t have to poll for updates but can notify your application in case of changes. This makes this paradigm ideal for realtime apps. Shiny uses the reactive programming model, so using this type of database extends the reactivity from the GUI until your database.</p>
<p>I have build a <a href="https://github.com/ginberg/shiny.collaboration">small application</a> in which you can see the reactivity in action. To make it work on your localhost, please make sure the rethink database is running. Next, run the application in 2 tabs. When you update a row in the datatable, it immediately appears in the other tab as well.</p>
<p><a href="http://gerinberg.com/wp-content/uploads/2017/08/shiny-collaboration.png"><img fetchpriority="high" decoding="async" class="alignnone size-medium wp-image-850" src="http://gerinberg.com/wp-content/uploads/2017/08/shiny-collaboration-300x187.png" alt="" width="300" height="187" srcset="https://gerinberg.com/wp-content/uploads/2017/08/shiny-collaboration-300x187.png 300w, https://gerinberg.com/wp-content/uploads/2017/08/shiny-collaboration-768x479.png 768w, https://gerinberg.com/wp-content/uploads/2017/08/shiny-collaboration-830x517.png 830w, https://gerinberg.com/wp-content/uploads/2017/08/shiny-collaboration-230x143.png 230w, https://gerinberg.com/wp-content/uploads/2017/08/shiny-collaboration-350x218.png 350w, https://gerinberg.com/wp-content/uploads/2017/08/shiny-collaboration-480x299.png 480w, https://gerinberg.com/wp-content/uploads/2017/08/shiny-collaboration.png 964w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>The post <a href="https://gerinberg.com/2017/08/27/live-collaboration-shiny-apps/">Live collaboration in Shiny apps</a> appeared first on <a href="https://gerinberg.com">Ger Inberg</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Deploying shiny apps on aws using docker</title>
		<link>https://gerinberg.com/2017/04/12/deploying-shiny-apps-on-aws-using-docker/</link>
					<comments>https://gerinberg.com/2017/04/12/deploying-shiny-apps-on-aws-using-docker/#comments</comments>
		
		<dc:creator><![CDATA[Ger]]></dc:creator>
		<pubDate>Wed, 12 Apr 2017 02:05:08 +0000</pubDate>
				<category><![CDATA[data science]]></category>
		<guid isPermaLink="false">http://gerinberg.com/?p=781</guid>

					<description><![CDATA[<p>Recently, I decided to migrate my shiny apps to amazon webservices. Most of them were running on the shinyapps.io platform. Why did I decide to migrate my apps? In the free version of shinyapps it is only possible to deploy 5 apps which is not [&#8230;]</p>
<p>The post <a href="https://gerinberg.com/2017/04/12/deploying-shiny-apps-on-aws-using-docker/">Deploying shiny apps on aws using docker</a> appeared first on <a href="https://gerinberg.com">Ger Inberg</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Recently, I decided to migrate my shiny apps to amazon webservices. Most of them were running on the <a href="https://www.shinyapps.io" target="_blank" rel="noopener">shinyapps.io</a> platform. Why did I decide to migrate my apps?</p>
<ul>
<li>In the free version of shinyapps it is only possible to deploy 5 apps which is not enough for me. The cheapest option then is to have the starter subscription which costs 9 dollar per month. It&#8217;s not a lot of money, but I think it can be cheaper to use and AWS instance (though it requires more work)</li>
<li>I would like to be flexible and not having to use the shinyapps configuration. For example I want to be able to change the configuration of the shiny server.</li>
<li>I would like some more experience with <a href="https://www.docker.com/what-docker" target="_blank" rel="noopener">Docker</a>. Docker is an which is a container system, that allows for &#8220;Build, Ship and Run Any App, Anywhere&#8221;.</li>
</ul>
<h3><span style="font-size: 14pt;"><strong>Docker  &#8211; R Shiny container</strong></span></h3>
<p>To get started with docker you will need an image. An image is an immutable blueprint of an operation environment, while a container is an instance of an image. For programmers, you can compare it with classes and objects where images are the classes and containers the objects.</p>
<p>There are a lot of images already available on <a href="https://hub.docker.com/">docker hub</a>, so you might want to check them out first. For R and shiny server there is also quite some choice. I first used the Rocker/Shiny image to try to deploy my apps. I found out that most of my applications were not starting unfortunately. So, let&#8217;s look at the log file..well it&#8217;s not there! It turns out that if the R process exits successfully, the log files will be removed by default (to not waste disk space). I turned this setting off, so I could find out what was going on. The problem why my apps were not starting was that some packages were missing. So I installed them, most of them were related to plotting (plotly, shinyjs, leaflet, etc).</p>
<p>Because of these 2 issues, I decided to create a custom DockerFile. It is based on Rocker/shiny but it will install the packages I need by default and it will save the log files.</p>
<pre>FROM rocker/shiny:latest 

MAINTAINER Ger Inberg "*****@****.com"

# install ssl
RUN sudo apt-get update; exit 0
RUN sudo apt-get install -y libssl-dev

# install additional packages
RUN R -e "install.packages(c('ggplot2', 'plotly', 'shinyjs', 'shinyBS', 'leaflet', 'ggmap', 'webshot', 'DT', 'shinydashboard'), repos='https://cran.rstudio.com/')"

# copy shiny-server config file
COPY shiny-server.conf /etc/shiny-server/shiny-server.conf

CMD ["/usr/bin/shiny-server.sh"]</pre>
<p>On the<a href="https://docs.docker.com/engine/getstarted/step_four/" target="_blank" rel="noopener"> docker site</a>, you can find how to create an image from a DockerFile.</p>
<h3><span style="font-size: 14pt;"><strong>Shiny Server configuration</strong></span></h3>
<p>Shiny server comes with a default configuration, which includes the default port number (3838), location of the log file directory, etc. I have only added the lines in blue.</p>
<pre># Instruct Shiny Server to run applications as the user "shiny"
run_as shiny;
<span style="color: #3366ff;"># preserve logs!
preserve_logs true;</span>

# Define a server that listens on port 3838
server {
 listen 3838;

 # Define a location at the base URL
 location / {

 # Host the directory of Shiny Apps stored in this directory
 site_dir /srv/shiny-server;

 # Log all Shiny output to files in this directory
 log_dir /var/log/shiny-server;

 # When a user visits the base URL rather than a particular application,
 # an index of the applications available in this directory will be shown.
 directory_index on;
 }
}</pre>
<h3><span style="font-size: 14pt;"><strong>Run docker instance on AWS</strong></span></h3>
<p>I assume you have already a running AWS instance Docker is installed. Furthermore I assume your shiny apps are already installed on the AWS instance. From there on it is easy to get up and running.</p>
<p>Below are the commands I have executed to use my own docker image to host my shiny apps.</p>
<pre># Get the image
docker pull ginberg/shiny

# run the docker image such that shiny server is running on port 80
# furthermore use the -v option to map the application directory and log file directory from aws instance fs to docker fs
docker run --rm -p 80:3838 -v /home/ubuntu/shiny/apps:/srv/shiny-server/ -v /home/ubuntu/shiny/apps/logs:/var/log/shiny-server/ ginberg/shiny &amp; 

# view log files directory
ls -al /home/ubuntu/shiny/apps/logs

# to login on the docker image: view running processes and use the id
docker ps
docker exec -it &lt;id&gt; bash</pre>
<h3><span style="font-size: 14pt;">Result</span></h3>
<p>My deployed apps can be found <a href="http://gerinberg.com/shiny">here</a></p>
<p>I am wondering how and on which platform are you hosting your shiny apps? Please let me know if you have any questions about this article.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>The post <a href="https://gerinberg.com/2017/04/12/deploying-shiny-apps-on-aws-using-docker/">Deploying shiny apps on aws using docker</a> appeared first on <a href="https://gerinberg.com">Ger Inberg</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://gerinberg.com/2017/04/12/deploying-shiny-apps-on-aws-using-docker/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>I am a top rated data science freelancer!</title>
		<link>https://gerinberg.com/2017/03/12/top-rated-freelancer/</link>
					<comments>https://gerinberg.com/2017/03/12/top-rated-freelancer/#comments</comments>
		
		<dc:creator><![CDATA[Ger]]></dc:creator>
		<pubDate>Sun, 12 Mar 2017 11:36:35 +0000</pubDate>
				<category><![CDATA[data science]]></category>
		<guid isPermaLink="false">http://gerinberg.com/?p=751</guid>

					<description><![CDATA[<p>Recently, I got the &#8216;top rated&#8217; status on Upwork. Upwork is a global freelancing platform where business and freelancers can meet and work remotely on projects. You might question what is this top rated status is all about? Advantages Well, this status has a couple [&#8230;]</p>
<p>The post <a href="https://gerinberg.com/2017/03/12/top-rated-freelancer/">I am a top rated data science freelancer!</a> appeared first on <a href="https://gerinberg.com">Ger Inberg</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Recently, I got the &#8216;top rated&#8217; status on <a href="https://www.upwork.com/" target="_blank">Upwork</a>. Upwork is a global freelancing platform where business and freelancers can meet and work remotely on projects. You might question what is this top rated status is all about?</p>
<hr>
<h5>Advantages</h5>
<p>Well, this status has a couple of advantages for freelancers, such as</p>
<ul>
<li>A badge on your Upwork freelancer profile</li>
<li>Personalized tips to strengthen your profile</li>
<li>Exclusive invitations to submit proposals</li>
<li>Private access to the Top Rated Community forum</li>
<li>An exclusive job-digest email to make it easier for you to find attractive opportunities</li>
</ul>
<p>The most important requirement&nbsp;to get the status is to keep a job success score of at least 90% for a couple of months. This score is, as you might expect, calculated by the amount of projects that have been successfully finished divided by the total amount of projects.</p>
<p>After, I shared my update I got questions from some people on how I got this done or &#8220;how I got any project at all?&#8221;. Yes, I know there is quite of lot of competition from all over the world and it&#8217;s not easy.</p>
<h5>Tips</h5>
<p>However, I can give you my tips to get started on Upwork:</p>
<ul>
<li>Have a complete profile and set your availability.</li>
<li>Respond to job invitations and it&#8217;s best to do it within 24 h. Upwork keep statistics about these which you can view in &#8220;My Stats&#8221;.</li>
<li>Only do projects, you are (pretty) sure you can do. It might be tempting to submit a proposal to a project that looks really cool, especially if you are low on budget. But how sure are you that you can really do it? Even if you can do it, but the project will take at lot longer than the client requested (i.e. because you have to update your knowledge) it might be better not to do it, since the client will not be totally satisfied and the review won&#8217;t be great.</li>
<li>Be modest in your salary requirements for your first projects. For me it was not so easy to get my first projects, since I didn&#8217;t have any reviews that they could use as a reference. I realized I needed some good reviews, so I applied to a lot of projects with a lower rate than my ideal rate, to increase the chance that a client would offer the project to me. It think it worked, since I got my first projects and after that I became easier to get other projects as well.</li>
<li>Communicate with your client regularly. Some clients wants to communicate daily, others weekly, so this depends. The same applies for the type of communication, some via Upwork and others via email or Skype. You can just ask him/her about this so both of you are sure about this.</li>
</ul>
<p>Hope, you will find this useful. Please let me know your experiences or questions!</p>
<p>The post <a href="https://gerinberg.com/2017/03/12/top-rated-freelancer/">I am a top rated data science freelancer!</a> appeared first on <a href="https://gerinberg.com">Ger Inberg</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://gerinberg.com/2017/03/12/top-rated-freelancer/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Reinforcement learning in smartcabs</title>
		<link>https://gerinberg.com/2016/12/22/reinforcement-learning-in-self-driving-cars/</link>
		
		<dc:creator><![CDATA[Ger]]></dc:creator>
		<pubDate>Thu, 22 Dec 2016 04:13:45 +0000</pubDate>
				<category><![CDATA[data science]]></category>
		<guid isPermaLink="false">http://gerinberg.com/?p=712</guid>

					<description><![CDATA[<p>Reinforcement learning is an area in Machine Learning which is quite different than supervised or unsupervised learning. This is because it is not about building a model based upon a dataset with given features and label(s). It is about software agents that take actions in [&#8230;]</p>
<p>The post <a href="https://gerinberg.com/2016/12/22/reinforcement-learning-in-self-driving-cars/">Reinforcement learning in smartcabs</a> appeared first on <a href="https://gerinberg.com">Ger Inberg</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Reinforcement learning is an area in Machine Learning which is quite different than supervised or unsupervised learning. This is because it is not about building a model based upon a dataset with given features and label(s). It is about software agents that take actions in a certain environment to maximize a reward. It has applications in game theory, operations research, genetic algorithms. It is also used in something that is changing the way we will transport ourselves in the future..self driving cars!</p>
<p>As part of my Machine Learning study, I have used reinforcement learning to create an agent for a self driving car. Please see my <a href="https://htmlpreview.github.io/?https://github.com/ginberg/smartcab/blob/master/report.html" target="_blank">github</a>.</p>
<p>&nbsp;</p>
<p><a href="http://gerinberg.com/wp-content/uploads/2016/12/smartcab2.png"><img decoding="async" class="alignnone wp-image-721 size-thumbnail" src="http://gerinberg.com/wp-content/uploads/2016/12/smartcab2-150x150.png" width="150" height="150" /></a><a href="http://gerinberg.com/wp-content/uploads/2016/12/smartcab.png"><img decoding="async" class="alignnone wp-image-719 size-thumbnail" src="http://gerinberg.com/wp-content/uploads/2016/12/smartcab-150x150.png" width="150" height="150" /></a></p>
<p>The post <a href="https://gerinberg.com/2016/12/22/reinforcement-learning-in-self-driving-cars/">Reinforcement learning in smartcabs</a> appeared first on <a href="https://gerinberg.com">Ger Inberg</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>What is apache spark / guest writer</title>
		<link>https://gerinberg.com/2016/11/10/what-is-apache-spark-guest-writer/</link>
		
		<dc:creator><![CDATA[Ger]]></dc:creator>
		<pubDate>Thu, 10 Nov 2016 04:55:15 +0000</pubDate>
				<category><![CDATA[data science]]></category>
		<guid isPermaLink="false">http://gerinberg.com/?p=726</guid>

					<description><![CDATA[<p>A while ago, I was asked to write some data science articles. One of these, an introduction to Apache Spark, can be found on simplylearn. Enjoy!</p>
<p>The post <a href="https://gerinberg.com/2016/11/10/what-is-apache-spark-guest-writer/">What is apache spark / guest writer</a> appeared first on <a href="https://gerinberg.com">Ger Inberg</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>A while ago, I was asked to write some data science articles. One of these, an introduction to Apache Spark, can be found on <a href="https://www.simplilearn.com/apache-spark-guide-for-newbies-article" target="_blank">simplylearn</a>. Enjoy!</p>
<p>The post <a href="https://gerinberg.com/2016/11/10/what-is-apache-spark-guest-writer/">What is apache spark / guest writer</a> appeared first on <a href="https://gerinberg.com">Ger Inberg</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>GridSearchCV with Apache Spark</title>
		<link>https://gerinberg.com/2016/10/29/gridsearchcv-with-apache-spark/</link>
		
		<dc:creator><![CDATA[Ger]]></dc:creator>
		<pubDate>Sat, 29 Oct 2016 06:17:18 +0000</pubDate>
				<category><![CDATA[data science]]></category>
		<guid isPermaLink="false">http://gerinberg.com/?p=695</guid>

					<description><![CDATA[<p>This article continues where I left with Classification for machine learning Apache Spark Apache Spark is a very popular framework in big data processing. The main reason for this: it&#8217;s fast! It can be used to parallelize your task on a cluster so it will [&#8230;]</p>
<p>The post <a href="https://gerinberg.com/2016/10/29/gridsearchcv-with-apache-spark/">GridSearchCV with Apache Spark</a> appeared first on <a href="https://gerinberg.com">Ger Inberg</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>This article continues where I left with <a href="http://gerinberg.com/2016/10/29/classification-with-machine-learning/">Classification for machine learning</a></p>
<h4></h4>
<h4>Apache Spark</h4>
<p><a href="http://spark.apache.org/">Apache Spark</a> is a very popular framework in big data processing. The main reason for this: it&#8217;s fast! It can be used to parallelize your task on a cluster so it will be completed earlier than if you would execute it serially.</p>
<p>It also can be used on a single computer, which has the advantage that you can use all in the cores in your computer.  The first solution I have written for the classification was using the sklearn package of python. Sklearn also provides functionality to do multicore processing on a single machine via <a href="https://pythonhosted.org/joblib/">joblib</a>, but since my client wanted to use explicitly Spark I have used that.</p>
<p>I have been looking into how to migrate the sklearn code to Spark ML I found out there are some initiatives already to run a sklearn solution on Spark. Because the most expensive part of the code is to find the hyperparameters with GridSearchCV, it&#8217;s important to parallelize this functionality. Databricks, the company behind the founder of Spark, has developed an <a href="https://github.com/databricks/spark-sklearn">integration package</a> for sklearn on Spark. Unfortunately, it didn&#8217;t work with my code. It was caused by the fact that I used a custom cross validator, StratifiedShuffleSplit, and I need this in order to keep balanced sample classes. I only had to make a slight modification to the code and published this on my <a href="https://github.com/ginberg/spark-sklearn">github</a>.</p>
<p>The python script can be submitted to Spark with the spark-submit command, since Spark 2.0 the pyspark command is not supported anymore to execute scripts. Spark-submit takes the python script as argument as well as some optional arguments. In the example I submit it to my local computer and specify it should use 8 cores.</p>
<pre>spark-submit --master local[8] build_model_spark.py</pre>
<p>Before my modifications, it took my laptop about 14 minutes to build the model on the whole dataset. With Spark this was reduced to less than 4 minutes, which is a pretty good improvement! My client was happy with the result and gave me a good review, so hope this results in more ML projects!</p>
<p><a href="http://gerinberg.com/wp-content/uploads/2016/10/perf_plot.png"><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-706" src="http://gerinberg.com/wp-content/uploads/2016/10/perf_plot-300x225.png" alt="perf_plot" width="300" height="225" srcset="https://gerinberg.com/wp-content/uploads/2016/10/perf_plot-300x225.png 300w, https://gerinberg.com/wp-content/uploads/2016/10/perf_plot-768x576.png 768w, https://gerinberg.com/wp-content/uploads/2016/10/perf_plot-230x173.png 230w, https://gerinberg.com/wp-content/uploads/2016/10/perf_plot-350x263.png 350w, https://gerinberg.com/wp-content/uploads/2016/10/perf_plot-480x360.png 480w, https://gerinberg.com/wp-content/uploads/2016/10/perf_plot.png 800w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a><a href="http://gerinberg.com/wp-content/uploads/2016/10/upwork.png"><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-697" src="http://gerinberg.com/wp-content/uploads/2016/10/upwork-300x260.png" alt="upwork" width="300" height="260" srcset="https://gerinberg.com/wp-content/uploads/2016/10/upwork-300x260.png 300w, https://gerinberg.com/wp-content/uploads/2016/10/upwork-230x199.png 230w, https://gerinberg.com/wp-content/uploads/2016/10/upwork-350x303.png 350w, https://gerinberg.com/wp-content/uploads/2016/10/upwork.png 467w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>The post <a href="https://gerinberg.com/2016/10/29/gridsearchcv-with-apache-spark/">GridSearchCV with Apache Spark</a> appeared first on <a href="https://gerinberg.com">Ger Inberg</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Classification with machine learning</title>
		<link>https://gerinberg.com/2016/10/29/classification-with-machine-learning/</link>
		
		<dc:creator><![CDATA[Ger]]></dc:creator>
		<pubDate>Sat, 29 Oct 2016 05:07:47 +0000</pubDate>
				<category><![CDATA[data science]]></category>
		<guid isPermaLink="false">http://gerinberg.com/?p=688</guid>

					<description><![CDATA[<p>Classification with machine learning: that was the title of one of the last projects I have done via Upwork. In this post I will tell what the project was about and what I have done. Click&#8211;through rate (CTR) is the ratio of users who click [&#8230;]</p>
<p>The post <a href="https://gerinberg.com/2016/10/29/classification-with-machine-learning/">Classification with machine learning</a> appeared first on <a href="https://gerinberg.com">Ger Inberg</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Classification with machine learning: that was the title of one of the last projects I have done via Upwork. In this post I will tell what the project was about and what I have done.</p>
<p><em>Click</em>&#8211;<em>through rate</em> (<em>CTR</em>) is the ratio of users who click on a specific link to the number of total users who view the page that contains the link. For a marketing company, a high CTR normally means an effective campaign, since many people click on the link ans thus visit the website of customer X. This project involved predicting the probability if a user would click on a given advertisement or not.</p>
<p>There were some requirements from the technical side: python in combination with jupyter notebook. For the machine learning part, there were 2 options. The first being sklearn, the second (preferred) being Spark ML. Furthermore a stacking of Gradient Boosted Trees (GBT) with Logistic Regression (LR) had to be used in combination with GridSearchCV to find the hyperparameters, a modelling approach that was effective for <a href="https://pdfs.semanticscholar.org/daf9/ed5dc6c6bad5367d7fd8561527da30e9b8dd.pdf">Facebook</a>. A quite challenging job from this perspective, since I haven&#8217;t been using stacking of algorithms that much.</p>
<h4></h4>
<h4>Data / Modelling</h4>
<p>The client provided about 2 GB of data about historical campaigns. This included features like country, browser, campaign-id and also if a user had clicked on the link or not. So, a <a href="https://en.wikipedia.org/wiki/Supervised_learning">supervised machine learning</a> challenge since the result feature (clicked or not) is in the dataset.</p>
<p>I have first build the model in sklearn. There were some challenges here, because the data was very unbalanced (a lot more data for users that did not click).  One challenge with such a dataset is that you have to choose a right metric to optimize for. Let&#8217;s say you would have a dataset in which 1% of the entries has a positive result and 99% a negative result. A simple model that is always predicting a negative result, would be right in 99% of the cases, not bad! In this situation, the accuracy which is defined by the number of right predictions divided by the total number of predictions, would not be a good choice. It would be better to use either <a href="https://en.wikipedia.org/wiki/Precision_and_recall">precision or recall</a></p>
<p>In the FB paper, the metric Normalized Entrophy (NE) is used. It is defined by the average log loss per impression divided by what the average log loss per impression would be if a model predicted the background click through rate (CTR) for every impression. The lower this score, the better the predictions are that the model has created. One other thing to be careful about is that GridSearchCV in sklearn always tries to maximize the given metric, so for a metric like NE, the <strong>negative score</strong> should be provided, to obtain the best result!</p>
<h4></h4>
<h4>Comparison of Models</h4>
<p>I have compared LR with GBT and the stacked solution of GBT+LR. The stacked solution proved to be just a little better than GBT on itself. Below the <a href="https://en.wikipedia.org/wiki/Receiver_operating_characteristic">ROC</a> curves for those models.</p>
<p><a href="http://gerinberg.com/wp-content/uploads/2016/10/roc2.png"><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-691" src="http://gerinberg.com/wp-content/uploads/2016/10/roc2-300x216.png" alt="roc2" width="300" height="216" srcset="https://gerinberg.com/wp-content/uploads/2016/10/roc2-300x216.png 300w, https://gerinberg.com/wp-content/uploads/2016/10/roc2-230x165.png 230w, https://gerinberg.com/wp-content/uploads/2016/10/roc2-350x252.png 350w, https://gerinberg.com/wp-content/uploads/2016/10/roc2-480x345.png 480w, https://gerinberg.com/wp-content/uploads/2016/10/roc2.png 544w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>After the model was finalized, I have been looking into Apache Spark and how to tweak the performance. In my next article I will tell something about that.</p>
<p>The post <a href="https://gerinberg.com/2016/10/29/classification-with-machine-learning/">Classification with machine learning</a> appeared first on <a href="https://gerinberg.com">Ger Inberg</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
