Quantcast
Channel: Jive Syndication Feed
Viewing all articles
Browse latest Browse all 10881

My Journey With Predictive Analysis Custom R Scripts

$
0
0

Hi,

 

In this rainy sunday, being sent out of home because some serious tidy-up and cleaning going on inside home

 

i decided i will find somewhere to grab a coffee, listen to some awesome music and explore possibilities with R programming.

 

Since i am not very proficient in coding, i will look for some ready code on the internet and will try to adapt it.

 

I believe some social media content will really make my demos and presentations shine, so let's see what we can do with Facebook API.

 

Result component link is at the bottom of this page, ready to be used,

 

What we want to achieve? See this viz.

 

http://snapplab.blogs.wm.edu/files/2013/12/fbnetwork3.jpg

 

First Step :

 

Log on to FB, visit this page, click on "get access token" (dont forget to authorize for friends data) :

 

https://developers.facebook.com/tools/explorer/?method=GET&path=716590462%3Ffields%3Did%2Cname

 

ScreenHunter_326 Mar. 09 14.19.jpg

 

 

Here's the github link to the original code i found online. it gets your friend list and their friends to plot a network cluster to visualize their connections to each other. Will be intresting to try:

 

https://github.com/pablobarbera/Rdataviz/blob/master/code/05_networks.R

 

We have to wrap this inside a function, add a print to actually plot the graph, make the api key a variable so we can pass from the algorithm properties page.

 

ScreenHunter_327 Mar. 09 14.26.jpg

 

Now let's configure our key and run the component :

 

ScreenHunter_330 Mar. 09 14.35.jpg

ScreenHunter_328 Mar. 09 14.30.jpg

 

Run the component and...!!!

 

ScreenHunter_329 Mar. 09 14.32.jpg

 

The code basically plots the clusters, and creates a legend to show names of people right on the center of each cluster. You chan tweak the code to change plot parameters which will probably make it look visually more appealing, like this  :

 

ScreenHunter_332 Mar. 09 15.12.jpg

 

 

Looking at the plot and names which i didnt include in the screenshot, i understand that they are mainly :

 

1) Work network

2) University friends

3) High-school friends,

4) Elementary school friends (yes we did find each other via facebook

5) Family

 

I believe that's a simple enough example of what clustering is, understanding different subcategories amongst a big list.

 

My next aim will be to replicate something similar but using a "product page" from facebook, visualizing people who "liked" the page. Any help is highly apreciated

 

Here's the re-usable component for SAP Predictive Analysis, download it and paste it into the apropriate folder which may look like

 

C:\Users\"usernamecomeshere"\SAP Predictive Components\RScript

 

Please note that the code is provided "as-is" and is not supported by SAP.

https://share.sap.com/a:rcoxsl/MyAttachments/3e3fc10c-3ae7-493b-a49f-a58c424e6711/

 

Happy coding



Viewing all articles
Browse latest Browse all 10881

Trending Articles