<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.7.4">Jekyll</generator><link href="https://fengliplatform.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://fengliplatform.github.io/" rel="alternate" type="text/html" /><updated>2019-04-15T01:43:34+00:00</updated><id>https://fengliplatform.github.io/feed.xml</id><title type="html">Feng Li</title><subtitle>Younger Than That Now</subtitle><entry><title type="html">Flux Redis</title><link href="https://fengliplatform.github.io/flux-redis/" rel="alternate" type="text/html" title="Flux Redis" /><published>2019-04-14T00:00:00+00:00</published><updated>2019-04-14T00:00:00+00:00</updated><id>https://fengliplatform.github.io/flux-redis</id><content type="html" xml:base="https://fengliplatform.github.io/flux-redis/">&lt;p&gt;It is interesting that we can find flux topology example for HBase and Kafka but it’s hard to find one for Redis.&lt;/p&gt;

&lt;p&gt;A HBASE + Storm/Flux example can be found at: https://github.com/apache/storm/blob/master/flux/flux-examples/src/main/resources/simple_hbase.yaml&lt;/p&gt;

&lt;p&gt;A Kafka + Storm/Flux example can be found at:
https://docs.microsoft.com/en-us/azure/hdinsight/hdinsight-apache-storm-with-kafka&lt;/p&gt;

&lt;p&gt;Let’s see how we can do a write to Redis.&lt;/p&gt;

&lt;p&gt;So a flux word count example can be found at https://github.com/Azure-Samples/hdinsight-python-storm-wordcount. On top of
that what if we want to save the word count results to Redis?&lt;/p&gt;

&lt;p&gt;We just need to add a bolt to receive word count results from count bolt and write them to Redis. We can call this bolt “redis-store-bolt”.
Simply it can be defined like following in Flux topology.yaml:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;id: “redis-store-bolt”
className: “org.apache.storm.redis.bolt.RedisStoreBolt”
constructorArgs:
    &lt;ul&gt;
      &lt;li&gt;ref: “poolConfig”&lt;/li&gt;
      &lt;li&gt;ref: “storeMapper”
parallelism: 1&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Storm has ready-to-use class to talk to Redis - org.apache.storm.redis.bolt.RedisStoreBolt. To initialize this class we need two
parameters: 1) Redis service configuration in the format of class JedisPoolConfig, 2) a RedisStoreMapper object to map incoming
data to be key/value pairs in Redis. 
(See details: https://storm.apache.org/releases/1.1.2/javadocs/org/apache/storm/redis/bolt/RedisStoreBolt.html).&lt;/p&gt;

&lt;p&gt;And in “components” section of the topology.yaml file we can define for the two parameters:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;id: “poolConfig”
className: “org.apache.storm.redis.common.config.JedisPoolConfig”
constructorArgs:
    &lt;ul&gt;
      &lt;li&gt;“localhost”&lt;/li&gt;
      &lt;li&gt;6379&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;id: “storeMapper”
className: “org.apache.storm.redis.common.mapper.RedisStoreMapper”
constructorArgs:&lt;/li&gt;
&lt;/ul&gt;
&lt;ToDo&gt;
&lt;/ToDo&gt;</content><author><name></name></author><summary type="html">It is interesting that we can find flux topology example for HBase and Kafka but it’s hard to find one for Redis.</summary></entry><entry><title type="html">Install/Configure Hive 3.1.1 Using MySQL Metastore</title><link href="https://fengliplatform.github.io/hive/" rel="alternate" type="text/html" title="Install/Configure Hive 3.1.1 Using MySQL Metastore" /><published>2019-01-13T00:00:00+00:00</published><updated>2019-01-13T00:00:00+00:00</updated><id>https://fengliplatform.github.io/hive</id><content type="html" xml:base="https://fengliplatform.github.io/hive/">&lt;p&gt;This task is verified on top of Hadoop 3.1.1.
Work as user “hadoop” if not specified.&lt;/p&gt;

&lt;h1 id=&quot;download-hive-311&quot;&gt;Download Hive 3.1.1&lt;/h1&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;pwd&lt;/span&gt;
/localuser/hadoop

&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;wget http://mirror.dsrg.utoronto.ca/apache/hive/hive-3.1.1/apache-hive-3.1.1-bin.tar.gz

&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;tar &lt;/span&gt;zxvf apache-hive-3.1.1-bin.tar.gz

&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;ls
&lt;/span&gt;apache-hive-3.1.1-bin  apache-hive-3.1.1-bin.tar.gz  hadoop  hadoop-3.1.1.tar.gz  hadoopdata  perl5

&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;mv apache-hive-3.1.1-bin hive

&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;ls
&lt;/span&gt;apache-hive-3.1.1-bin.tar.gz  hadoop  hadoop-3.1.1.tar.gz  hadoopdata  hive  perl5
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;set-environment-variables&quot;&gt;Set environment variables&lt;/h1&gt;
&lt;p&gt;Set environment variables for user “hadoop”. With all the Hadoop settings user hadoop’s “.bashrc” file should look like following:&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cat&lt;/span&gt; .bashrc
&lt;span class=&quot;c&quot;&gt;# .bashrc&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# Source global definitions&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt; /etc/bashrc &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt; /etc/bashrc
&lt;span class=&quot;k&quot;&gt;fi&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# Uncomment the following line if you don't like systemctl's auto-paging feature:&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# export SYSTEMD_PAGER=&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# User specific aliases and functions&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;HADOOP_HOME&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/localuser/hadoop/hadoop
&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;HADOOP_INSTALL&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$HADOOP_HOME&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;HADOOP_MAPRED_HOME&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$HADOOP_HOME&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;HADOOP_COMMON_HOME&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$HADOOP_HOME&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;HADOOP_HDFS_HOME&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$HADOOP_HOME&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;YARN_HOME&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$HADOOP_HOME&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;HADOOP_COMMON_LIB_NATIVE_DIR&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$HADOOP_HOME&lt;/span&gt;/lib/native
&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;PATH&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$PATH&lt;/span&gt;:&lt;span class=&quot;nv&quot;&gt;$HADOOP_HOME&lt;/span&gt;/sbin:&lt;span class=&quot;nv&quot;&gt;$HADOOP_HOME&lt;/span&gt;/bin

&lt;span class=&quot;c&quot;&gt;# hive&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;HIVE_HOME&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/localuser/hadoop/hive
&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;PATH&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$HIVE_HOME&lt;/span&gt;/bin:&lt;span class=&quot;nv&quot;&gt;$PATH&lt;/span&gt;

&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;hadoop@li-9 ~]&lt;span class=&quot;err&quot;&gt;$&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;hadoop@li-9 ~]&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;source&lt;/span&gt; .bashrc
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;create-directories-on-hdfs-for-hive&quot;&gt;Create directories on HDFS for Hive&lt;/h1&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;hadoop fs &lt;span class=&quot;nt&quot;&gt;-mkdir&lt;/span&gt; /tmp
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;hadoop fs &lt;span class=&quot;nt&quot;&gt;-mkdir&lt;/span&gt; /user
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;hadoop fs &lt;span class=&quot;nt&quot;&gt;-mkdir&lt;/span&gt; /user/hadoop
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;hadoop fs &lt;span class=&quot;nt&quot;&gt;-mkdir&lt;/span&gt; /user/hive
&lt;span class=&quot;c&quot;&gt;# warehouse is where Hive stores actual data if you create a table and insert data later on.&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;hadoop fs &lt;span class=&quot;nt&quot;&gt;-mkdir&lt;/span&gt; /user/hive/warehouse
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;hadoop fs &lt;span class=&quot;nt&quot;&gt;-chmod&lt;/span&gt; g+w /tmp
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;hadoop fs &lt;span class=&quot;nt&quot;&gt;-chmod&lt;/span&gt; g+w /user/hive/warehouse
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Note, following jar file is provided by both Hadoop and Hive. We’ll remove it from Hive to avoid errors.&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;rm /localuser/hadoop/hive/lib/log4j-slf4j-impl.jar
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;configure-hive-sitexml-with-metastore-information-to-be-used&quot;&gt;Configure hive-site.xml with metastore information to be used&lt;/h1&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;pwd&lt;/span&gt;
/localuser/hadoop/hive/conf
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cat &lt;/span&gt;hive-site.xml
&amp;lt;configuration&amp;gt;

 &amp;lt;property&amp;gt;
    &amp;lt;name&amp;gt;javax.jdo.option.ConnectionURL&amp;lt;/name&amp;gt;
    &amp;lt;value&amp;gt;jdbc:mysql://&amp;lt;MySQL Server&amp;gt;:3306/hive?createDatabaseIfNotExist&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;&amp;lt;/value&amp;gt;
    &amp;lt;description&amp;gt;JDBC connect string &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;a JDBC metastore&amp;lt;/description&amp;gt;
&amp;lt;/property&amp;gt;

 &amp;lt;property&amp;gt;
    &amp;lt;name&amp;gt;javax.jdo.option.ConnectionDriverName&amp;lt;/name&amp;gt;
    &amp;lt;value&amp;gt;com.mysql.jdbc.Driver&amp;lt;/value&amp;gt;
    &amp;lt;description&amp;gt;Driver class name &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;a JDBC metastore&amp;lt;/description&amp;gt;
 &amp;lt;/property&amp;gt;

 &amp;lt;property&amp;gt;
    &amp;lt;name&amp;gt;javax.jdo.option.ConnectionUserName&amp;lt;/name&amp;gt;
    &amp;lt;value&amp;gt;hadoop&amp;lt;/value&amp;gt;
    &amp;lt;description&amp;gt;username to use against metastore database&amp;lt;/description&amp;gt;
 &amp;lt;/property&amp;gt;

 &amp;lt;property&amp;gt;
    &amp;lt;name&amp;gt;javax.jdo.option.ConnectionPassword&amp;lt;/name&amp;gt;
    &amp;lt;value&amp;gt;hadoop123&amp;lt;/value&amp;gt;
    &amp;lt;description&amp;gt;password to use against metastore database&amp;lt;/description&amp;gt;
 &amp;lt;/property&amp;gt;

 &amp;lt;property&amp;gt;
    &amp;lt;name&amp;gt;hive.metastore.uris&amp;lt;/name&amp;gt;
    &amp;lt;value&amp;gt;thrift://localhost:9083&amp;lt;/value&amp;gt;
 &amp;lt;/property&amp;gt;

&amp;lt;/configuration&amp;gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;configure-mysql-database-for-hive-sitexml&quot;&gt;Configure MySQL database for hive-site.xml&lt;/h1&gt;
&lt;p&gt;On MySQL database server as user root, create “hive” database and user “hadoop” based on information in hive-site.xml:&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# mysql -uroot -p&lt;/span&gt;
Enter password:
Welcome to the MySQL monitor.  Commands end with &lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; or &lt;span class=&quot;se&quot;&gt;\g&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
...

mysql&amp;gt; create database hive&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
Query OK, 1 row affected &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;0.00 sec&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;

mysql&amp;gt; create user &lt;span class=&quot;s1&quot;&gt;'hadoop'&lt;/span&gt;@&lt;span class=&quot;s1&quot;&gt;'%'&lt;/span&gt; identified by &lt;span class=&quot;s1&quot;&gt;'hadoop123'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
Query OK, 0 rows affected &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;0.00 sec&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;

mysql&amp;gt; grant all privileges on hive.&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt; to &lt;span class=&quot;s1&quot;&gt;'hadoop'&lt;/span&gt;@&lt;span class=&quot;s1&quot;&gt;'%'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
Query OK, 0 rows affected &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;0.00 sec&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;

mysql&amp;gt; FLUSH PRIVILEGES&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
Query OK, 0 rows affected &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;0.00 sec&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;

mysql&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Back on Hive machine, Verify above changes:&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;mysql &lt;span class=&quot;nt&quot;&gt;-h&lt;/span&gt; &amp;lt;MySQL server&amp;gt; &lt;span class=&quot;nt&quot;&gt;-u&lt;/span&gt; hadoop &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt;
Enter password:
Welcome to the MariaDB monitor.  Commands end with &lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; or &lt;span class=&quot;se&quot;&gt;\g&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
...

MySQL &lt;span class=&quot;o&quot;&gt;[(&lt;/span&gt;none&lt;span class=&quot;o&quot;&gt;)]&amp;gt;&lt;/span&gt; show databases&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| hive               |
| mysql              |
| &lt;span class=&quot;nb&quot;&gt;test&lt;/span&gt;               |
+--------------------+
4 rows &lt;span class=&quot;k&quot;&gt;in &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;0.00 sec&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;

MySQL &lt;span class=&quot;o&quot;&gt;[(&lt;/span&gt;none&lt;span class=&quot;o&quot;&gt;)]&amp;gt;&lt;/span&gt; use hive&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
Database changed
MySQL &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;hive]&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h1 id=&quot;put-mysql-jdbc-jar-file-in-place-for-hive&quot;&gt;Put MySQL JDBC jar file in place for Hive&lt;/h1&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;pwd&lt;/span&gt;
/localuser/hadoop/hive/lib
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;cp /scratch/support/li/pac-package/mysql-connector-java-5.1.22-bin.jar &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;initialize-metastore-schemas&quot;&gt;Initialize metastore schemas&lt;/h1&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;schematool &lt;span class=&quot;nt&quot;&gt;-dbType&lt;/span&gt; mysql &lt;span class=&quot;nt&quot;&gt;-initSchema&lt;/span&gt;
Metastore connection URL:     jdbc:mysql://li-4:3306/hive?createDatabaseIfNotExist&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;true
&lt;/span&gt;Metastore Connection Driver :     com.mysql.jdbc.Driver
Metastore connection User:     hadoop
Starting metastore schema initialization to 3.1.0
Initialization script hive-schema-3.1.0.mysql.sql
…
Initialization script completed
schemaTool completed

&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;mysql &lt;span class=&quot;nt&quot;&gt;-h&lt;/span&gt; li-4 &lt;span class=&quot;nt&quot;&gt;-u&lt;/span&gt; hadoop &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt;
Enter password:
Welcome to the MariaDB monitor.  Commands end with &lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; or &lt;span class=&quot;se&quot;&gt;\g&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
...

MySQL &lt;span class=&quot;o&quot;&gt;[(&lt;/span&gt;none&lt;span class=&quot;o&quot;&gt;)]&amp;gt;&lt;/span&gt; show databases&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| hive               |
| mysql              |
| &lt;span class=&quot;nb&quot;&gt;test&lt;/span&gt;               |
+--------------------+
4 rows &lt;span class=&quot;k&quot;&gt;in &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;0.00 sec&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;

MySQL &lt;span class=&quot;o&quot;&gt;[(&lt;/span&gt;none&lt;span class=&quot;o&quot;&gt;)]&amp;gt;&lt;/span&gt; use hive
Reading table information &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;completion of table and column names
You can turn off this feature to get a quicker startup with &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt;

Database changed
MySQL &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;hive]&amp;gt; show tables&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
+-------------------------------+
| Tables_in_hive                |
+-------------------------------+
| AUX_TABLE                     |
| BUCKETING_COLS                |
…...
| WM_TRIGGER                    |
| WRITE_SET                     |
+-------------------------------+
74 rows &lt;span class=&quot;k&quot;&gt;in &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;0.00 sec&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;launch-metastore-service&quot;&gt;Launch metastore service&lt;/h1&gt;
&lt;p&gt;Modify/create hive-env.sh in /localuser/hadoop/hive/conf/hive-env.sh to add&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;        &lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;METASTORE_PORT&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;9083
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;This port should be consistent to the thrift URI parameter in hive-site.xml:&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;property&amp;gt;
    &amp;lt;name&amp;gt;hive.metastore.uris&amp;lt;/name&amp;gt;
    &amp;lt;value&amp;gt;thrift://localhost:9083&amp;lt;/value&amp;gt;
 &amp;lt;/property&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now start metastore service&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;hive &lt;span class=&quot;nt&quot;&gt;--service&lt;/span&gt; metastore
Start Metastore Service ...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;launch-hive-cli-and-do-tests&quot;&gt;Launch Hive CLI and Do Tests&lt;/h1&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;hive
...
hive&amp;gt; show tables&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
OK
Time taken: 1.929 seconds
hive&amp;gt;
hive&amp;gt; create table mytable
    &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; no int,
    &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; name string,
    ...
    &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; row format delimited
    &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; fields terminated by &lt;span class=&quot;s1&quot;&gt;','&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
OK
Time taken: 15.778 seconds
hive&amp;gt; show tables&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
OK
mytable
Time taken: 0.085 seconds, Fetched: 1 row&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;s&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
hive&amp;gt;
hive&amp;gt; load data &lt;span class=&quot;nb&quot;&gt;local &lt;/span&gt;inpath &lt;span class=&quot;s1&quot;&gt;'/localuser/hadoop/testhive/mytabledata.txt'&lt;/span&gt; overwrite into table mytable&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
Loading data to table default.mytable
OK
Time taken: 2.205 seconds
hive&amp;gt; &lt;span class=&quot;k&quot;&gt;select&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;*&lt;/span&gt; from mytable&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
OK
...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Hive stores the actual data in HDFS Hive warehouse&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;hadoop fs &lt;span class=&quot;nt&quot;&gt;-ls&lt;/span&gt; /user/hive/warehouse
Found 1 items
drwxr-xr-x   - hadoop supergroup          0 2019-01-11 12:50 /user/hive/warehouse/mytable
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;hadoop fs &lt;span class=&quot;nt&quot;&gt;-ls&lt;/span&gt; /user/hive/warehouse/employee
Found 1 items
&lt;span class=&quot;nt&quot;&gt;-rw-r--r--&lt;/span&gt;   1 hadoop supergroup        156 2019-01-11 12:50 /user/hive/warehouse/mytable/mytabledata.txt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name></name></author><summary type="html">This task is verified on top of Hadoop 3.1.1. Work as user “hadoop” if not specified.</summary></entry><entry><title type="html">Pattern Mining using Apriori algorithm</title><link href="https://fengliplatform.github.io/apriori/" rel="alternate" type="text/html" title="Pattern Mining using Apriori algorithm" /><published>2018-02-19T00:00:00+00:00</published><updated>2018-02-19T00:00:00+00:00</updated><id>https://fengliplatform.github.io/apriori</id><content type="html" xml:base="https://fengliplatform.github.io/apriori/">&lt;p&gt;Given an input file which is an attributes list of one place. The attributes of the place consists of a number of category instances. Each line represents one place. Examples are as following:&lt;/p&gt;

&lt;p&gt;Breakfast &amp;amp; Brunch;American (Traditional);Restaurants&lt;br /&gt;
Sandwiches;Restaurants&lt;br /&gt;
Local Services;IT Services &amp;amp; Computer Repair&lt;br /&gt;
Restaurants;Italian&lt;br /&gt;
Food;Coffee &amp;amp; Tea&lt;br /&gt;
Fast Food;Restaurants&lt;br /&gt;
Mortgage Brokers;Home Services;Real Estate&lt;/p&gt;

&lt;p&gt;So the task is to mine frequent category patterns under a given min-support.&lt;/p&gt;

&lt;p&gt;The philosophy of Apriori algorithm includes two steps: frequent pattern generating and pruning. It’s an iterative process that starts from Candidates set and ends up with Frequent set. Starts from 1-item to 2-items and so on. For example,&lt;br /&gt;
Step 1, Scan data to generate 1-item candidate set. And filter the patterns with min-support to find frequent patterns.&lt;br /&gt;
Step 2,  Generate 2-item candidate set based on 1-item set and &lt;br /&gt;
	- Trim the data by removing infrequent 1-item patterns.&lt;br /&gt;
	- Calculate support for 2-item patterns and prune to with min-support to get 2-item frequent patterns.  &lt;br /&gt;
Step 3, repeat above steps 2 to generate 3-item frequent patterns and so on. Until there is no x-item patterns exist in data or no patterns satisfy the min-support.&lt;/p&gt;

&lt;p&gt;So we’ll work on this “category of places” data to find all frequent patterns. What’s the value of this? To find what services are always together in one place could be used as references to open your new stores for best profits. &lt;br /&gt;
Let’s say if we find “Hotels &amp;amp; Travel”, “Hotels” and “Event Planning &amp;amp; Services” are associate most in some places what business chances you want to take there?&lt;/p&gt;

&lt;p&gt;So we’ll get started.&lt;/p&gt;

&lt;p&gt;It looks familiar to generate 1-item patterns calculating supports as to do a classic “word count”. So  just use handy Spark cluster to get this done firstly.  &lt;br /&gt;
&lt;img src=&quot;/images/apriori/wc.png&quot; alt=&quot;wc&quot; /&gt;&lt;/p&gt;

&lt;p&gt;After that we’ll need to adjust format and apply min-support (771) to get 1-item frequent set.  &lt;br /&gt;
&lt;img src=&quot;/images/apriori/part1.png&quot; alt=&quot;part1&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Here is a look at the 1-item frequent set - “support:category” as following:&lt;br /&gt;
&lt;img src=&quot;/images/apriori/item1.png&quot; alt=&quot;item1&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Next, we’ll work on 2-item frequent set.&lt;br /&gt;
Step 1, we’ll generate 2-item candidate set based on 1-item frequent set using itertools.combinations method.&lt;br /&gt;
&lt;img src=&quot;/images/apriori/part21.png&quot; alt=&quot;part21&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Step 2, we’ll remove infrequent 1-item categories from dataset and then calculate support for 2-item candidate category set.&lt;br /&gt;
&lt;img src=&quot;/images/apriori/part22.png&quot; alt=&quot;part22&quot; /&gt;&lt;br /&gt;
&lt;img src=&quot;/images/apriori/part23.png&quot; alt=&quot;part23&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Now we have 2-item frequent category set.&lt;br /&gt;
&lt;img src=&quot;/images/apriori/part24.png&quot; alt=&quot;part24&quot; /&gt;&lt;/p&gt;

&lt;p&gt;So we can continue to get 3-items frequent category set like this - only one line: &lt;br /&gt;
&lt;img src=&quot;/images/apriori/part25.png&quot; alt=&quot;part25&quot; /&gt;&lt;/p&gt;

&lt;p&gt;By now we can also tell this is the end of the frequent patterns - three items cannot make up four or more patterns.&lt;/p&gt;

&lt;p&gt;Lastly we can combine all the frequent patterns: 1-item, 2-item and 3-item patterns together to get all the frequent patterns out of this dataset.&lt;br /&gt;
&lt;img src=&quot;/images/apriori/last.png&quot; alt=&quot;last&quot; /&gt;&lt;/p&gt;</content><author><name></name></author><summary type="html">Given an input file which is an attributes list of one place. The attributes of the place consists of a number of category instances. Each line represents one place. Examples are as following:</summary></entry><entry><title type="html">Brief Exercises with Pig Latin</title><link href="https://fengliplatform.github.io/pig/" rel="alternate" type="text/html" title="Brief Exercises with Pig Latin" /><published>2018-01-31T00:00:00+00:00</published><updated>2018-01-31T00:00:00+00:00</updated><id>https://fengliplatform.github.io/pig</id><content type="html" xml:base="https://fengliplatform.github.io/pig/">&lt;p&gt;With Hortonworks Sandbox 2.6 we’ll have a brief exercise using Pig to take a look at movie dataset.&lt;/p&gt;

&lt;p&gt;So a movie dataset can be downloaded from http://files.grouplens.org/datasets/movielens/ml-100k.zip. It includes After extracting the zip file, we’ll need u.data and u.item two files.&lt;/p&gt;

&lt;p&gt;u.data     – There are 100,000 ratings by 943 users on 1682 movies. This is a comma separated list of 
	         user id | item id | rating | timestamp. (The time stamps are unix seconds since 1/1/1970 UTC)&lt;/p&gt;

&lt;p&gt;Sample data from file u.data: 
196,242,3,881250949 # user #196 rated movie #242 with score 3 at time of 881250949
186,302,3,891717742
22,377,1,878887116&lt;/p&gt;

&lt;table&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;u.item     – Information about the items (movies); this is a tab separated list of “movie id&lt;/td&gt;
      &lt;td&gt;movie title&lt;/td&gt;
      &lt;td&gt;release date&lt;/td&gt;
      &lt;td&gt;…” The fields after “release date” are not related to our task so we ignore them for now.&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;Sample data from file u.item:
1|Toy Story (1995)|01-Jan-1995|…
2|GoldenEye (1995)|01-Jan-1995|…
3|Four Rooms (1995)|01-Jan-1995|…&lt;/p&gt;

&lt;p&gt;So the question we’re going to attack is “what are the top 20 best rated latest movies?”&lt;/p&gt;

&lt;p&gt;Following are Pig Latin script to do so:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ratings = LOAD '/user/maria_dev/ml-100k/u.data' 
          USING PigStorage(',') 
          AS (userID:int, movieID:int, rating:int, ratingTime:int);

metadata = LOAD '/user/maria_dev/ml-100k/u.item' 
           USING PigStorage('|')
           AS (movieID:int, movieTitle:chararray, releaseDate:chararray,
               videoRelease:chararray, imdbLink:chararray);
               
nameLookup = FOREACH metadata GENERATE movieID, movieTitle, 
                 ToUnixTime(ToDate(releaseDate, 'dd-MMM-yyyy')) AS releaseTime;
                 
ratingByMovie = GROUP ratings BY movieID;

avgRatings = FOREACH ratingByMovie GENERATE group as movieID, 
                                           AVG(ratings.rating) AS avgRating;

fiveStarMovies = FILTER avgRatings BY avgRating &amp;gt; 4.5;

fiveStarMoviesWithData = JOIN fiveStarMovies BY movieID, nameLookup BY movieID;

oldestFiveStarMovies = ORDER fiveStarMoviesWithData BY nameLookup::releaseTime DESC;

first20 = LIMIT oldestFiveStarMovies 20;

DUMP first20;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Run this script in Pig View in Ambari we’ll get the latest top 20 movie list that are best rated. The latest movie in this small 
dataset is dated to April 1998.
&lt;img src=&quot;/images/pig/good.png&quot; alt=&quot;good&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Next, based on this script, we can also find what movies are most rated by using COUNT(ratings.rating).&lt;br /&gt;
It could be interesting to find most rated movie with lowest ratings.&lt;/p&gt;

&lt;p&gt;We can do that with following Pig Latin script:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ratings = LOAD '/user/maria_dev/ml-100k/u.data' 
          USING PigStorage(',') 
          AS (userID:int, movieID:int, rating:int, ratingTime:int);

metadata = LOAD '/user/maria_dev/ml-100k/u.item' 
           USING PigStorage('|')
           AS (movieID:int, movieTitle:chararray, releaseDate:chararray,
               videoRelease:chararray, imdbLink:chararray);
               
nameLookup = FOREACH metadata GENERATE movieID, movieTitle, 
                 ToUnixTime(ToDate(releaseDate, 'dd-MMM-yyyy')) AS releaseTime;
                 
ratingByMovie = GROUP ratings BY movieID;

countRatings = FOREACH ratingByMovie GENERATE group as movieID, 
                       AVG(ratings.rating) AS avgRating, COUNT(ratings.rating) AS numRatings;

lowestRatingMovies = FILTER countRatings BY avgRating &amp;lt; 2.0;

lowestRatingMoviesWithData = JOIN lowestRatingMovies BY movieID, nameLookup BY movieID;

mostRatedLowestRatingMovies = FOREACH lowestRatingMoviesWithData GENERATE nameLookup::movieTitle AS movieName,
                                      lowestRatingMovies::avgRating AS avgRating, lowestRatingMovies::numRatings AS numRatings;

mostRatedLowestRatingMoviesSorted = ORDER mostRatedLowestRatingMovies BY numRatings DESC;

first20 = LIMIT mostRatedLowestRatingMoviesSorted 20;

DUMP first20;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Run above script in Ambari:
&lt;img src=&quot;/images/pig/bad.png&quot; alt=&quot;bad&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This is an exercise in Udemy course “the-ultimate-hands-on-hadoop-tame-your-big-data”.&lt;/p&gt;</content><author><name></name></author><summary type="html">With Hortonworks Sandbox 2.6 we’ll have a brief exercise using Pig to take a look at movie dataset.</summary></entry><entry><title type="html">Central Limit Theorem(CLT) test with R</title><link href="https://fengliplatform.github.io/CLT/" rel="alternate" type="text/html" title="Central Limit Theorem(CLT) test with R" /><published>2017-12-31T00:00:00+00:00</published><updated>2017-12-31T00:00:00+00:00</updated><id>https://fengliplatform.github.io/CLT</id><content type="html" xml:base="https://fengliplatform.github.io/CLT/">&lt;p&gt;In this simple note, I will investigate the exponential distribution in R and compare it with the Central Limit Theorem(CLT). 
CLT tells us that sample mean distribution is a normal distribution when sample size is large enough (for example &amp;gt;30). Expected 
value of sample mean distribution is used to estimate population mean. Sample mean variance is population variance divided 
by sample size.&lt;/p&gt;

&lt;p&gt;In following plot, red line stands for sample mean and green line stands for theoretical mean.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/ds-r-jhu/CLT.png&quot; alt=&quot;CLT&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This simple note is from Data Science course by JHU in Coursera. For details &lt;a href=&quot;http://rpubs.com/fengliplatform/260393&quot;&gt;check on RPubs&lt;/a&gt;&lt;/p&gt;</content><author><name></name></author><summary type="html">In this simple note, I will investigate the exponential distribution in R and compare it with the Central Limit Theorem(CLT). CLT tells us that sample mean distribution is a normal distribution when sample size is large enough (for example &amp;gt;30). Expected value of sample mean distribution is used to estimate population mean. Sample mean variance is population variance divided by sample size.</summary></entry><entry><title type="html">NOAA Storm Data Analysis</title><link href="https://fengliplatform.github.io/NOAA/" rel="alternate" type="text/html" title="NOAA Storm Data Analysis" /><published>2017-12-31T00:00:00+00:00</published><updated>2017-12-31T00:00:00+00:00</updated><id>https://fengliplatform.github.io/NOAA</id><content type="html" xml:base="https://fengliplatform.github.io/NOAA/">&lt;p&gt;Storms and other severe weather events can cause both public health and economic problems for communities and municipalities. 
Many severe events can result in fatalities, injuries, and property damage, and preventing such outcomes to the extent possible is a 
key concern.&lt;/p&gt;

&lt;p&gt;This project involves exploring the U.S. National Oceanic and Atmospheric Administration’s (NOAA) storm database. This database tracks 
characteristics of major storms and weather events in the United States, including when and where they occur, as well as estimates of 
any fatalities, injuries, and property damage.&lt;/p&gt;

&lt;p&gt;This data analysis will address the following questions:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Across the United States, which types of events (as indicated in the EVTYPE variable) are most harmful with respect to population health?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;img src=&quot;/images/ds-r-jhu/top10harm-health.png&quot; alt=&quot;top10harm-health&quot; /&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Across the United States, which types of events have the greatest economic consequences?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;img src=&quot;/images/ds-r-jhu/top10harm-eco.png&quot; alt=&quot;top10harm-eco&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This was a homework in Data Science course by JHU in Coursera. For details, &lt;a href=&quot;http://rpubs.com/fengliplatform/254905&quot;&gt;check on Rpubs&lt;/a&gt;&lt;/p&gt;</content><author><name></name></author><summary type="html">Storms and other severe weather events can cause both public health and economic problems for communities and municipalities. Many severe events can result in fatalities, injuries, and property damage, and preventing such outcomes to the extent possible is a key concern.</summary></entry><entry><title type="html">Airquality Dataset Viz with Vega-lite</title><link href="https://fengliplatform.github.io/dv-vega-lite/" rel="alternate" type="text/html" title="Airquality Dataset Viz with Vega-lite" /><published>2017-12-31T00:00:00+00:00</published><updated>2017-12-31T00:00:00+00:00</updated><id>https://fengliplatform.github.io/dv-vega-lite</id><content type="html" xml:base="https://fengliplatform.github.io/dv-vega-lite/">&lt;p&gt;This project is a final project for Data Viz course by UIUC in Coursera. The purpose of the project is to practice narrative visualization structure using Java script plus Vega/Vega-lite libraries.&lt;/p&gt;

&lt;p&gt;This Data Viz project can be seen at &lt;a href=&quot;https://fengliplatform.github.io/dataviz-uiuc/index.html&quot;&gt;link&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This project follows the Interactive Slideshow narrative visualization structure. It is a hybrid structure mixing author-lead and reader-lead scenes. This project consists a Home page, three Scene pages and a Final summary page. So user will follow an author directed path through the slideshow. During home page and the three scenes user can drill down a little bit for some details which they are interested. Or user can just continue if they are not interested to certain pages.&lt;/p&gt;

&lt;p&gt;In addition, the project provides this About page to describe the design of this project.&lt;/p&gt;

&lt;p&gt;The charts were built using Vega-lite to complete this project in limited time. Note, Vega plus D3 will support advanced interaction to those charts which leave the improvement at a later time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;User Interface Events&lt;/strong&gt;
The buttons in the navigation bar (page top) and the Prev, Next buttons (page bottom) enable the User Interface events. The buttons allow user to walk through the author-lead structure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Annotations&lt;/strong&gt;
The annotation is represented by the legend on top right of the scatter plots and tooltips when mouse is hovered over the bar chart.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Triggers&lt;/strong&gt;
The mouse click acts as a trigger event for navigation on button. The mouse hover event is a trigger for the tooltip in bar chart. Also the mouse can be used to zoom in/out the scatter plots in the three scene pages for details.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Parameters&lt;/strong&gt;
All the pages are hyper linked to each other. The page names are passed as input to the buttons on page top and page bottom.&lt;/p&gt;

&lt;p&gt;Source code location is &lt;a href=&quot;https://github.com/fengliplatform/dataviz-uiuc&quot;&gt;link&lt;/a&gt;&lt;/p&gt;</content><author><name></name></author><summary type="html">This project is a final project for Data Viz course by UIUC in Coursera. The purpose of the project is to practice narrative visualization structure using Java script plus Vega/Vega-lite libraries.</summary></entry><entry><title type="html">Create a map marked with UofT using leaflet</title><link href="https://fengliplatform.github.io/leaflet-r/" rel="alternate" type="text/html" title="Create a map marked with UofT using leaflet" /><published>2017-12-31T00:00:00+00:00</published><updated>2017-12-31T00:00:00+00:00</updated><id>https://fengliplatform.github.io/leaflet-r</id><content type="html" xml:base="https://fengliplatform.github.io/leaflet-r/">&lt;p&gt;The requirements to this assignment in DS course by JHU:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Create a web page using R Markdown that features a map created with Leaflet.&lt;/li&gt;
  &lt;li&gt;Host your webpage on either GitHub Pages, RPubs, or NeoCities.&lt;/li&gt;
  &lt;li&gt;Your webpage must contain the date that you created the document, and it must contain a map created with Leaflet.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;/images/ds-r-jhu/map-uoft.png&quot; alt=&quot;map-uoft&quot; /&gt;&lt;/p&gt;

&lt;p&gt;So R code and interactive map can be &lt;a href=&quot;http://rpubs.com/fengliplatform/265198&quot;&gt;found on RPubs&lt;/a&gt;&lt;/p&gt;</content><author><name></name></author><summary type="html">The requirements to this assignment in DS course by JHU: Create a web page using R Markdown that features a map created with Leaflet. Host your webpage on either GitHub Pages, RPubs, or NeoCities. Your webpage must contain the date that you created the document, and it must contain a map created with Leaflet.</summary></entry><entry><title type="html">Take a quick look at MPG using box plot, t-test and build a regression model</title><link href="https://fengliplatform.github.io/mtcars-r/" rel="alternate" type="text/html" title="Take a quick look at MPG using box plot, t-test and build a regression model" /><published>2017-12-31T00:00:00+00:00</published><updated>2017-12-31T00:00:00+00:00</updated><id>https://fengliplatform.github.io/mtcars-r</id><content type="html" xml:base="https://fengliplatform.github.io/mtcars-r/">&lt;p&gt;This project assumes that you work for Motor Trend, a magazine about the automobile industry. Looking at a data set (mtcars from datasets 
library) of a collection of cars, they are interested in exploring the relationship between a set of variables and miles per gallon (MPG) 
(outcome). They are particularly interested in the following two questions:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;“Is an automatic or manual transmission better for MPG”&lt;/li&gt;
  &lt;li&gt;“Quantify the MPG difference between automatic and manual transmissions”&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The purpose of this project report is to address above two questions use the knowledge from course 7 regression models.&lt;/p&gt;

&lt;p&gt;Can you draw any conclusion from following plot for the first question?&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/ds-r-jhu/box-mpg.png&quot; alt=&quot;box&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Statistical analysis (t-test) for the second question and more can be &lt;a href=&quot;http://rpubs.com/fengliplatform/262307&quot;&gt;found on RPubs&lt;/a&gt;&lt;/p&gt;</content><author><name></name></author><summary type="html">This project assumes that you work for Motor Trend, a magazine about the automobile industry. Looking at a data set (mtcars from datasets library) of a collection of cars, they are interested in exploring the relationship between a set of variables and miles per gallon (MPG) (outcome). They are particularly interested in the following two questions:</summary></entry><entry><title type="html">NLP with R part 2 predict next words using Shiny App</title><link href="https://fengliplatform.github.io/nlp-r-2/" rel="alternate" type="text/html" title="NLP with R part 2 predict next words using Shiny App" /><published>2017-12-31T00:00:00+00:00</published><updated>2017-12-31T00:00:00+00:00</updated><id>https://fengliplatform.github.io/nlp-r-2</id><content type="html" xml:base="https://fengliplatform.github.io/nlp-r-2/">&lt;p&gt;This project was capstone project for Coursera Data Science Specialization held by Johns Hopkins University. SwiftKey is corporate partner in this project.&lt;/p&gt;

&lt;p&gt;The purpose of this project is to learn and practice text mining and NLP knowledge and skills. We’ll start from text dataset provided by SwiftKey, build up algorithms to predict next most likely word following given text. A Shiny application will be created to accept user input and display predicted word.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Algorithm Description&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;After random sampling the text data set, a corpus data was created and cleaned. Data cleaning approaches include: change to lower case, remove number, remove punctuation, strip whitespaces, remove English end words.&lt;/p&gt;

&lt;p&gt;Based on this, tokenization was conducted to create bi-grams and tri-grams data matrixes.&lt;/p&gt;

&lt;p&gt;For example,  &lt;br /&gt;
Top 5 bi-gram words are: “right now”, “dont know”, “last year”,  “new york”, “cant wait”     &lt;br /&gt;
Top 5 tri-gram words are: “happy mothers day”, “cant wait see”, “new york city”, “let us know”, “world war ii”&lt;/p&gt;

&lt;p&gt;Furthermore, frequency data tables are created respectively and thus being used for prediction.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Shiny App Description&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This app accept user input text at left sidebar and display the predicted next word on right panel. For example, input “happy” and press Enter, “birthday” will be predicted. Input “let us”, “know” will be predicted. &lt;br /&gt;
The app takes input words and match them in frequency data table to find the most likely next word.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/ds-r-jhu/wp.png&quot; alt=&quot;words prediction&quot; /&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;App is hosted on &lt;a href=&quot;https://fengliplatform.shinyapps.io/theapp/&quot;&gt;Shiny server&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Source code on &lt;a href=&quot;https://github.com/fengliplatform/datasciencecoursera/tree/master/capstone&quot;&gt;Github&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content><author><name></name></author><summary type="html">This project was capstone project for Coursera Data Science Specialization held by Johns Hopkins University. SwiftKey is corporate partner in this project.</summary></entry></feed>