SlideShare una empresa de Scribd logo
1 de 24
Data Visualization in
  Python/Django
   By KENNETH EMEKA ODOH
     By KENNETH EMEKA
     ODOH
Table of Contents
Introduction
Motivation
Method
Appendices
Conclusion
References
Introduction
 My background
 Requirements (
 Python, Django, Matplotlib, ajax ) and other
 third-party libraries.

 What this talk is not about ( we are not trying
 to re-implement Google analytics ).

 Source codes are available at (
  https://github.com/kenluck2001/PyCon2012
  _Talk ).
"Everything should be made as simple as
MOTIVATION
There is a need to represent the business
 analytic data in a graphical form. This because
 a picture speaks more than a thousand words.




   Source: en.wikipedia.org
Where do we find
data?




   Source: en.wikipedia.org
Sources of Data

• CSV
• DATABASES
Data Processing
 Identify the data source.
 Preprocessing of the data (
  removing nulls, wide characters
  ) e.g. Google refine.
 Actual data processing.
 Present the clean data in
  descriptive format. i.e. Data
  visualization
   See Appendix 1
Visual Representation of
            data
     Charts / Diagram format
     Texts format
      Tables
      Log files




Source: devk2.wordpress.com   Source: elementsdatabase.com
Categorization of data
Real-time
 See Appendix 2
Batch-based
  See Appendix 2
Rules of Data Collection
 Keep data in the easiest
  processable form e.g
  database, csv
 Keep data collected with
  timestamp.
 Gather data that are relevant to
  the business needs.
 Remove old data
Where is the data
   visualization done?
 Server
  See Appendix from 2 - 6
 Client
  Examples of Javascript library
  DS.js ( http://d3js.org/ )
  gRaphael.js (
   http://g.raphaeljs.com/ )
Factors to Consider for
Choice of Visualization
 Where do we perform the
  visualization processing?
 Is it Server or Client?


It depends
 Security
 Scalability
Tools needed for data
analysis
 Csvkit (
  http://csvkit.readthedocs.org/en/latest/ )
 networkx ( http://networkx.lanl.gov/ )
 pySAL ( http://code.google.com/p/pysal/
  )
Appendices
Let the codes begin




     Source:
     caseinsights.com
Appendix 1
## This describes a scatter plot of solar radiation against the month.
This aim to describe the steps of data gathering.CSV file from data science
hackathon website. The source code is available in a folder named
“plotCode”

import csv
from matplotlib.backends.backend_agg
import FigureCanvasAgg as FigureCanvas
from matplotlib.figure import Figure

def prepareList(month_most_common_list):
''' Prepare the input for process by removing all unnecessary values. Replace "NA"
with 0''„
    output_list = []
    for x in month_most_common_list:
    if x != 'NA':
        output_list.append(x)
    else:
        output_list.append(0)
    return output_list
Appendix 1
def plotSolarRadiationAgainstMonth(filename):
                                                                contd.
  trainRowReader = csv.reader(open(filename, 'rb'), delimiter=',')
  month_most_common_list = []
  Solar_radiation_64_list = []
  for row in trainRowReader:
      month_most_common = row[3]
      Solar_radiation_64 = row[6]
      month_most_common_list.append(month_most_common)
      Solar_radiation_64_list.append(Solar_radiation_64)
  #convert all elements in the list to float while skipping the first element for the 1st element is a
description of the field.
  month_most_common_list = [float(i) for i in prepareList(month_most_common_list)[1:] ]
  Solar_radiation_64_list = [float(i) for i in prepareList(Solar_radiation_64_list)[1:] ]
  fig=Figure()
  ax=fig.add_subplot(111)
  title='Scatter Diagram of solar radiation against month of the year'
  ax.set_xlabel('Most common month')
  ax.set_ylabel('Solar Radiation')
  fig.suptitle(title, fontsize=14)
  try:
      ax.scatter(month_most_common_list, Solar_radiation_64_list)
      #it is possible to make other kind of plots e.g bar charts, pie charts, histogram
  except ValueError:
      pass
  canvas = FigureCanvas(fig)
  canvas.print_figure('solarRadMonth.png',dpi=500)

  if __name__ == "__main__":
      plotSolarRadiationAgainstMonth('TrainingData.csv')
Appendix 2
From the project in folder named WebMonitor

class LoadEvent:
…
def fillMonitorModel(self):
   for monObj in self.monitorObjList:
      mObj = Monitor(url = monObj[2], httpStatus =
monObj[0], responseTime = monObj[1], contentStatus
= monObj[5])
      mObj.save()

#also see the following examples in project named
YAAStasks.py This shows how the analytic tables are
loaded with real-time data.
Appendix 3
from django.http import HttpResponse
from matplotlib.backends.backend_agg
import FigureCanvasAgg as FigureCanvasfrom matplotlib.figure
import Figurefrom YAAS.stats.models import RegisteredUser, OnlineUser, StatBid #scatter diagram of number of bids
made against number of online users
# weekly report
@staff_member_required
def weeklyScatterOnlinUsrBid(request, week_no):
   page_title='Weekly Scatter Diagram based on Online user verses Bid'
   weekno=week_no
   fig=Figure()
   ax=fig.add_subplot(111)
   year=stat.getYear()
   onlUserObj = OnlineUser.objects.filter(week=weekno).filter(year=year)
   bidObj = StatBid.objects.filter(week=weekno).filter(year=year)
   onlUserlist = list(onlUserObj.values_list('no_of_online_user', flat=True))
   bidlist = list(bidObj.values_list('no_of_bids', flat=True))
    title='Scatter Diagram of number of online User against number of bids (week {0}){1}'.format(weekno,year)
   ax.set_xlabel('Number of online Users')
   ax.set_ylabel('Number of Bids')
   fig.suptitle(title, fontsize=14)
   try:
       ax.scatter(onlUserlist, bidlist)
    except ValueError:
       pass
   canvas = FigureCanvas(fig)
   response = HttpResponse(content_type='image/png')
   canvas.print_png(response)
   return response

More info. can be found in YAAS/graph/The folder named
"graph"
Appendix 4
# Example of how database may be deleted to recover some space.
From folder named “YAAS”. Check task.py
@periodic_task(run_every=crontab(hour=1, minute=30, day_of_week=
0))
def deleteOldItemsandBids():
   hunderedandtwentydays = datetime.today() -
datetime.timedelta(days=120)
   myItem = Item.objects.filter(end_date__lte=hunderedandtwentydays
).delete()
   myBid = Bid.objects.filter(end_date__lte=hunderedandtwentydays
).delete()#populate the registereduser and onlineuser model at regular
intervals
Appendix 5

Check project in
YAAS/stats/

for more information on
statistical processing
Appendix 6
 # how to refresh the views in django. To keep the charts.
 updated. See WebMonitor project

 {% extends "base.html" %}

 {% block site_wrapper %}
 <div id="messages">Updating tables ...</div>
 <script>
    function refresh() {
       $.ajax({
              url: "/monitor/",
              success: function(data) {
 $('#messages').html(data);
              }
      });
         setInterval("refresh()", 100000);
  }
 $(function(){ refresh(); });
 </script>
 {% endblock %}
References
 Python documentation ( http://www.python.org/ )
 Django documentation (
  https://www.djangoproject.com/ )
 Stack overflow ( http://stackoverflow.com/ )
 Celery documentation
  (http://ask.github.com/celery/)


Pictures
 email logo ( http:// ambrosedesigns.co.uk )
 blog logo ( http:// sociolatte.com )
Thanks for listening
           Follow me using any of


                    @kenluck2001

                    kenluck2001@yahoo.com


                    http://kenluck2001.tumblr.com
                    /

                    https://github.com/kenluck200
                    1

Más contenido relacionado

La actualidad más candente

Minicourse on Network Science
Minicourse on Network ScienceMinicourse on Network Science
Minicourse on Network SciencePavel Loskot
 
проект з розгалуженням голодна мавпочка
 проект з розгалуженням голодна мавпочка проект з розгалуженням голодна мавпочка
проект з розгалуженням голодна мавпочкаOksana_Babenko
 
1 seaborn introduction
1 seaborn introduction 1 seaborn introduction
1 seaborn introduction YuleiLi3
 
Representation learning on graphs
Representation learning on graphsRepresentation learning on graphs
Representation learning on graphsDeakin University
 
오토인코더의 모든 것
오토인코더의 모든 것오토인코더의 모든 것
오토인코더의 모든 것NAVER Engineering
 
Classification decision tree
Classification  decision treeClassification  decision tree
Classification decision treeyazad dumasia
 
Dropout as a Bayesian Approximation
Dropout as a Bayesian ApproximationDropout as a Bayesian Approximation
Dropout as a Bayesian ApproximationSangwoo Mo
 
Python. Объектно-ориентированное программирование
Python. Объектно-ориентированное программирование Python. Объектно-ориентированное программирование
Python. Объектно-ориентированное программирование Theoretical mechanics department
 
Feature selection
Feature selectionFeature selection
Feature selectionDong Guo
 
A Unified Approach to Interpreting Model Predictions (SHAP)
A Unified Approach to Interpreting Model Predictions (SHAP)A Unified Approach to Interpreting Model Predictions (SHAP)
A Unified Approach to Interpreting Model Predictions (SHAP)Rama Irsheidat
 
Graph kernels
Graph kernelsGraph kernels
Graph kernelsLuc Brun
 
ID3 Algorithm & ROC Analysis
ID3 Algorithm & ROC AnalysisID3 Algorithm & ROC Analysis
ID3 Algorithm & ROC AnalysisTalha Kabakus
 
Machine learning basics using trees algorithm (Random forest, Gradient Boosting)
Machine learning basics using trees algorithm (Random forest, Gradient Boosting)Machine learning basics using trees algorithm (Random forest, Gradient Boosting)
Machine learning basics using trees algorithm (Random forest, Gradient Boosting)Parth Khare
 
Optimization for Deep Learning
Optimization for Deep LearningOptimization for Deep Learning
Optimization for Deep LearningSebastian Ruder
 
[컨퍼런스] 모두콘 2018 리뷰
[컨퍼런스] 모두콘 2018 리뷰[컨퍼런스] 모두콘 2018 리뷰
[컨퍼런스] 모두콘 2018 리뷰Donghyeon Kim
 

La actualidad más candente (20)

Minicourse on Network Science
Minicourse on Network ScienceMinicourse on Network Science
Minicourse on Network Science
 
проект з розгалуженням голодна мавпочка
 проект з розгалуженням голодна мавпочка проект з розгалуженням голодна мавпочка
проект з розгалуженням голодна мавпочка
 
1 seaborn introduction
1 seaborn introduction 1 seaborn introduction
1 seaborn introduction
 
Representation learning on graphs
Representation learning on graphsRepresentation learning on graphs
Representation learning on graphs
 
gSpan algorithm
gSpan algorithmgSpan algorithm
gSpan algorithm
 
오토인코더의 모든 것
오토인코더의 모든 것오토인코더의 모든 것
오토인코더의 모든 것
 
Classification decision tree
Classification  decision treeClassification  decision tree
Classification decision tree
 
Deepwalk vs Node2vec
Deepwalk vs Node2vecDeepwalk vs Node2vec
Deepwalk vs Node2vec
 
Uml Common Mechanism
Uml Common MechanismUml Common Mechanism
Uml Common Mechanism
 
Dropout as a Bayesian Approximation
Dropout as a Bayesian ApproximationDropout as a Bayesian Approximation
Dropout as a Bayesian Approximation
 
Decision tree
Decision treeDecision tree
Decision tree
 
Python. Объектно-ориентированное программирование
Python. Объектно-ориентированное программирование Python. Объектно-ориентированное программирование
Python. Объектно-ориентированное программирование
 
Feature selection
Feature selectionFeature selection
Feature selection
 
A Unified Approach to Interpreting Model Predictions (SHAP)
A Unified Approach to Interpreting Model Predictions (SHAP)A Unified Approach to Interpreting Model Predictions (SHAP)
A Unified Approach to Interpreting Model Predictions (SHAP)
 
Random forest
Random forestRandom forest
Random forest
 
Graph kernels
Graph kernelsGraph kernels
Graph kernels
 
ID3 Algorithm & ROC Analysis
ID3 Algorithm & ROC AnalysisID3 Algorithm & ROC Analysis
ID3 Algorithm & ROC Analysis
 
Machine learning basics using trees algorithm (Random forest, Gradient Boosting)
Machine learning basics using trees algorithm (Random forest, Gradient Boosting)Machine learning basics using trees algorithm (Random forest, Gradient Boosting)
Machine learning basics using trees algorithm (Random forest, Gradient Boosting)
 
Optimization for Deep Learning
Optimization for Deep LearningOptimization for Deep Learning
Optimization for Deep Learning
 
[컨퍼런스] 모두콘 2018 리뷰
[컨퍼런스] 모두콘 2018 리뷰[컨퍼런스] 모두콘 2018 리뷰
[컨퍼런스] 모두콘 2018 리뷰
 

Destacado

Data visualization by Kenneth Odoh
Data visualization by Kenneth OdohData visualization by Kenneth Odoh
Data visualization by Kenneth Odohpyconfi
 
Data Visualization(s) Using Python
Data Visualization(s) Using PythonData Visualization(s) Using Python
Data Visualization(s) Using PythonAniket Maithani
 
What is a Deployment Tool and How Can it Help Me?
What is a Deployment Tool and How Can it Help Me?What is a Deployment Tool and How Can it Help Me?
What is a Deployment Tool and How Can it Help Me?XebiaLabs
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2fishwarter
 
Visdjango presentation django_boston_oct_2014
Visdjango presentation django_boston_oct_2014Visdjango presentation django_boston_oct_2014
Visdjango presentation django_boston_oct_2014jlbaldwin
 
Delineating Cancer Genomics through Data Visualization
Delineating Cancer Genomics through  Data VisualizationDelineating Cancer Genomics through  Data Visualization
Delineating Cancer Genomics through Data VisualizationRupam Das
 
Con-Action Project Midterm Presentation
Con-Action Project Midterm PresentationCon-Action Project Midterm Presentation
Con-Action Project Midterm PresentationJ S
 
Building a desktop app with HTTP::Engine, SQLite and jQuery
Building a desktop app with HTTP::Engine, SQLite and jQueryBuilding a desktop app with HTTP::Engine, SQLite and jQuery
Building a desktop app with HTTP::Engine, SQLite and jQueryTatsuhiko Miyagawa
 
Using Django for a scientific document analysis (web) application
Using Django for a scientific document analysis (web) applicationUsing Django for a scientific document analysis (web) application
Using Django for a scientific document analysis (web) applicationvanatteveldt
 
Making Sense of Millions of Thoughts: Finding Patterns in the Tweets
Making Sense of Millions of Thoughts: Finding Patterns in the TweetsMaking Sense of Millions of Thoughts: Finding Patterns in the Tweets
Making Sense of Millions of Thoughts: Finding Patterns in the TweetsKrist Wongsuphasawat
 
Adventure in Data: A tour of visualization projects at Twitter
Adventure in Data: A tour of visualization projects at TwitterAdventure in Data: A tour of visualization projects at Twitter
Adventure in Data: A tour of visualization projects at TwitterKrist Wongsuphasawat
 
Titan and Cassandra at WellAware
Titan and Cassandra at WellAwareTitan and Cassandra at WellAware
Titan and Cassandra at WellAwaretwilmes
 
Apache Cassandra for Timeseries- and Graph-Data
Apache Cassandra for Timeseries- and Graph-DataApache Cassandra for Timeseries- and Graph-Data
Apache Cassandra for Timeseries- and Graph-DataGuido Schmutz
 
Coastal Urban DEM project - Mapping the vulnerability of Australia's Coast
Coastal Urban DEM project - Mapping the vulnerability of Australia's CoastCoastal Urban DEM project - Mapping the vulnerability of Australia's Coast
Coastal Urban DEM project - Mapping the vulnerability of Australia's CoastFungis Queensland
 
Digital image processing - What is digital image processign
Digital image processing - What is digital image processignDigital image processing - What is digital image processign
Digital image processing - What is digital image processignE2MATRIX
 
Multi Tenancy With Python and Django
Multi Tenancy With Python and DjangoMulti Tenancy With Python and Django
Multi Tenancy With Python and Djangoscottcrespo
 
Python Visualisation for Data Science
Python Visualisation for Data SciencePython Visualisation for Data Science
Python Visualisation for Data ScienceAmit Kapoor
 

Destacado (20)

Data visualization by Kenneth Odoh
Data visualization by Kenneth OdohData visualization by Kenneth Odoh
Data visualization by Kenneth Odoh
 
Data Visualization(s) Using Python
Data Visualization(s) Using PythonData Visualization(s) Using Python
Data Visualization(s) Using Python
 
What is a Deployment Tool and How Can it Help Me?
What is a Deployment Tool and How Can it Help Me?What is a Deployment Tool and How Can it Help Me?
What is a Deployment Tool and How Can it Help Me?
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2
 
Visdjango presentation django_boston_oct_2014
Visdjango presentation django_boston_oct_2014Visdjango presentation django_boston_oct_2014
Visdjango presentation django_boston_oct_2014
 
Delineating Cancer Genomics through Data Visualization
Delineating Cancer Genomics through  Data VisualizationDelineating Cancer Genomics through  Data Visualization
Delineating Cancer Genomics through Data Visualization
 
Con-Action Project Midterm Presentation
Con-Action Project Midterm PresentationCon-Action Project Midterm Presentation
Con-Action Project Midterm Presentation
 
Building a desktop app with HTTP::Engine, SQLite and jQuery
Building a desktop app with HTTP::Engine, SQLite and jQueryBuilding a desktop app with HTTP::Engine, SQLite and jQuery
Building a desktop app with HTTP::Engine, SQLite and jQuery
 
Using Django for a scientific document analysis (web) application
Using Django for a scientific document analysis (web) applicationUsing Django for a scientific document analysis (web) application
Using Django for a scientific document analysis (web) application
 
Python Científico
Python CientíficoPython Científico
Python Científico
 
Making Sense of Millions of Thoughts: Finding Patterns in the Tweets
Making Sense of Millions of Thoughts: Finding Patterns in the TweetsMaking Sense of Millions of Thoughts: Finding Patterns in the Tweets
Making Sense of Millions of Thoughts: Finding Patterns in the Tweets
 
Adventure in Data: A tour of visualization projects at Twitter
Adventure in Data: A tour of visualization projects at TwitterAdventure in Data: A tour of visualization projects at Twitter
Adventure in Data: A tour of visualization projects at Twitter
 
Data_Visualization_Project
Data_Visualization_ProjectData_Visualization_Project
Data_Visualization_Project
 
Titan and Cassandra at WellAware
Titan and Cassandra at WellAwareTitan and Cassandra at WellAware
Titan and Cassandra at WellAware
 
Apache Cassandra for Timeseries- and Graph-Data
Apache Cassandra for Timeseries- and Graph-DataApache Cassandra for Timeseries- and Graph-Data
Apache Cassandra for Timeseries- and Graph-Data
 
MATLAB Fundamentals (1)
MATLAB Fundamentals (1)MATLAB Fundamentals (1)
MATLAB Fundamentals (1)
 
Coastal Urban DEM project - Mapping the vulnerability of Australia's Coast
Coastal Urban DEM project - Mapping the vulnerability of Australia's CoastCoastal Urban DEM project - Mapping the vulnerability of Australia's Coast
Coastal Urban DEM project - Mapping the vulnerability of Australia's Coast
 
Digital image processing - What is digital image processign
Digital image processing - What is digital image processignDigital image processing - What is digital image processign
Digital image processing - What is digital image processign
 
Multi Tenancy With Python and Django
Multi Tenancy With Python and DjangoMulti Tenancy With Python and Django
Multi Tenancy With Python and Django
 
Python Visualisation for Data Science
Python Visualisation for Data SciencePython Visualisation for Data Science
Python Visualisation for Data Science
 

Similar a Data visualization in python/Django

Django tech-talk
Django tech-talkDjango tech-talk
Django tech-talkdtdannen
 
droidQuery: The Android port of jQuery
droidQuery: The Android port of jQuerydroidQuery: The Android port of jQuery
droidQuery: The Android port of jQueryPhDBrown
 
Building Modern Apps using Android Architecture Components
Building Modern Apps using Android Architecture ComponentsBuilding Modern Apps using Android Architecture Components
Building Modern Apps using Android Architecture ComponentsHassan Abid
 
Art & music vs Google App Engine
Art & music vs Google App EngineArt & music vs Google App Engine
Art & music vs Google App Enginethomas alisi
 
Relevance trilogy may dream be with you! (dec17)
Relevance trilogy  may dream be with you! (dec17)Relevance trilogy  may dream be with you! (dec17)
Relevance trilogy may dream be with you! (dec17)Woonsan Ko
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with ClojureDmitry Buzdin
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to DjangoJoaquim Rocha
 
Backbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCBackbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCpootsbook
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsJeff Durta
 
A Gentle Introduction to Angular Schematics - Angular SF 2019
A Gentle Introduction to Angular Schematics - Angular SF 2019A Gentle Introduction to Angular Schematics - Angular SF 2019
A Gentle Introduction to Angular Schematics - Angular SF 2019Matt Raible
 
A Basic Django Introduction
A Basic Django IntroductionA Basic Django Introduction
A Basic Django IntroductionGanga Ram
 
Html5 and web technology update
Html5 and web technology updateHtml5 and web technology update
Html5 and web technology updateDoug Domeny
 
EclipseCon2011 Cross-Platform Mobile Development with Eclipse
EclipseCon2011 Cross-Platform Mobile Development with EclipseEclipseCon2011 Cross-Platform Mobile Development with Eclipse
EclipseCon2011 Cross-Platform Mobile Development with EclipseHeiko Behrens
 

Similar a Data visualization in python/Django (20)

Django tech-talk
Django tech-talkDjango tech-talk
Django tech-talk
 
JQuery Flot
JQuery FlotJQuery Flot
JQuery Flot
 
droidQuery: The Android port of jQuery
droidQuery: The Android port of jQuerydroidQuery: The Android port of jQuery
droidQuery: The Android port of jQuery
 
Building Modern Apps using Android Architecture Components
Building Modern Apps using Android Architecture ComponentsBuilding Modern Apps using Android Architecture Components
Building Modern Apps using Android Architecture Components
 
Art & music vs Google App Engine
Art & music vs Google App EngineArt & music vs Google App Engine
Art & music vs Google App Engine
 
huhu
huhuhuhu
huhu
 
Android best practices
Android best practicesAndroid best practices
Android best practices
 
Data Science on Google Cloud Platform
Data Science on Google Cloud PlatformData Science on Google Cloud Platform
Data Science on Google Cloud Platform
 
Django crush course
Django crush course Django crush course
Django crush course
 
Relevance trilogy may dream be with you! (dec17)
Relevance trilogy  may dream be with you! (dec17)Relevance trilogy  may dream be with you! (dec17)
Relevance trilogy may dream be with you! (dec17)
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to Django
 
Backbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCBackbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVC
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
 
A Gentle Introduction to Angular Schematics - Angular SF 2019
A Gentle Introduction to Angular Schematics - Angular SF 2019A Gentle Introduction to Angular Schematics - Angular SF 2019
A Gentle Introduction to Angular Schematics - Angular SF 2019
 
Spring boot
Spring boot Spring boot
Spring boot
 
A Basic Django Introduction
A Basic Django IntroductionA Basic Django Introduction
A Basic Django Introduction
 
Html5 and web technology update
Html5 and web technology updateHtml5 and web technology update
Html5 and web technology update
 
EclipseCon2011 Cross-Platform Mobile Development with Eclipse
EclipseCon2011 Cross-Platform Mobile Development with EclipseEclipseCon2011 Cross-Platform Mobile Development with Eclipse
EclipseCon2011 Cross-Platform Mobile Development with Eclipse
 

Más de kenluck2001

Salt Identification Challenge
Salt Identification ChallengeSalt Identification Challenge
Salt Identification Challengekenluck2001
 
Compressed Sensing using Generative Model
Compressed Sensing using Generative ModelCompressed Sensing using Generative Model
Compressed Sensing using Generative Modelkenluck2001
 
Tutorial on Cryptography
Tutorial on CryptographyTutorial on Cryptography
Tutorial on Cryptographykenluck2001
 
Landmark Retrieval & Recognition
Landmark Retrieval & RecognitionLandmark Retrieval & Recognition
Landmark Retrieval & Recognitionkenluck2001
 
Tracking the tracker: Time Series Analysis in Python from First Principles
Tracking the tracker: Time Series Analysis in Python from First PrinciplesTracking the tracker: Time Series Analysis in Python from First Principles
Tracking the tracker: Time Series Analysis in Python from First Principleskenluck2001
 
Tracking the tracker: Time Series Analysis in Python from First Principles
Tracking the tracker: Time Series Analysis in Python from First PrinciplesTracking the tracker: Time Series Analysis in Python from First Principles
Tracking the tracker: Time Series Analysis in Python from First Principleskenluck2001
 

Más de kenluck2001 (7)

Salt Identification Challenge
Salt Identification ChallengeSalt Identification Challenge
Salt Identification Challenge
 
Compressed Sensing using Generative Model
Compressed Sensing using Generative ModelCompressed Sensing using Generative Model
Compressed Sensing using Generative Model
 
Tutorial on Cryptography
Tutorial on CryptographyTutorial on Cryptography
Tutorial on Cryptography
 
Landmark Retrieval & Recognition
Landmark Retrieval & RecognitionLandmark Retrieval & Recognition
Landmark Retrieval & Recognition
 
Tracking the tracker: Time Series Analysis in Python from First Principles
Tracking the tracker: Time Series Analysis in Python from First PrinciplesTracking the tracker: Time Series Analysis in Python from First Principles
Tracking the tracker: Time Series Analysis in Python from First Principles
 
Tracking the tracker: Time Series Analysis in Python from First Principles
Tracking the tracker: Time Series Analysis in Python from First PrinciplesTracking the tracker: Time Series Analysis in Python from First Principles
Tracking the tracker: Time Series Analysis in Python from First Principles
 
Kaggle kenneth
Kaggle kennethKaggle kenneth
Kaggle kenneth
 

Último

Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfOverkill Security
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 

Último (20)

Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 

Data visualization in python/Django

  • 1. Data Visualization in Python/Django By KENNETH EMEKA ODOH By KENNETH EMEKA ODOH
  • 3. Introduction  My background  Requirements ( Python, Django, Matplotlib, ajax ) and other third-party libraries.  What this talk is not about ( we are not trying to re-implement Google analytics ).  Source codes are available at ( https://github.com/kenluck2001/PyCon2012 _Talk ). "Everything should be made as simple as
  • 4. MOTIVATION There is a need to represent the business analytic data in a graphical form. This because a picture speaks more than a thousand words. Source: en.wikipedia.org
  • 5. Where do we find data? Source: en.wikipedia.org
  • 6. Sources of Data • CSV • DATABASES
  • 7. Data Processing  Identify the data source.  Preprocessing of the data ( removing nulls, wide characters ) e.g. Google refine.  Actual data processing.  Present the clean data in descriptive format. i.e. Data visualization See Appendix 1
  • 8. Visual Representation of data  Charts / Diagram format  Texts format Tables Log files Source: devk2.wordpress.com Source: elementsdatabase.com
  • 9. Categorization of data Real-time See Appendix 2 Batch-based See Appendix 2
  • 10. Rules of Data Collection  Keep data in the easiest processable form e.g database, csv  Keep data collected with timestamp.  Gather data that are relevant to the business needs.  Remove old data
  • 11. Where is the data visualization done?  Server See Appendix from 2 - 6  Client Examples of Javascript library DS.js ( http://d3js.org/ ) gRaphael.js ( http://g.raphaeljs.com/ )
  • 12. Factors to Consider for Choice of Visualization  Where do we perform the visualization processing?  Is it Server or Client? It depends  Security  Scalability
  • 13. Tools needed for data analysis  Csvkit ( http://csvkit.readthedocs.org/en/latest/ )  networkx ( http://networkx.lanl.gov/ )  pySAL ( http://code.google.com/p/pysal/ )
  • 14. Appendices Let the codes begin Source: caseinsights.com
  • 15. Appendix 1 ## This describes a scatter plot of solar radiation against the month. This aim to describe the steps of data gathering.CSV file from data science hackathon website. The source code is available in a folder named “plotCode” import csv from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas from matplotlib.figure import Figure def prepareList(month_most_common_list): ''' Prepare the input for process by removing all unnecessary values. Replace "NA" with 0''„ output_list = [] for x in month_most_common_list: if x != 'NA': output_list.append(x) else: output_list.append(0) return output_list
  • 16. Appendix 1 def plotSolarRadiationAgainstMonth(filename): contd. trainRowReader = csv.reader(open(filename, 'rb'), delimiter=',') month_most_common_list = [] Solar_radiation_64_list = [] for row in trainRowReader: month_most_common = row[3] Solar_radiation_64 = row[6] month_most_common_list.append(month_most_common) Solar_radiation_64_list.append(Solar_radiation_64) #convert all elements in the list to float while skipping the first element for the 1st element is a description of the field. month_most_common_list = [float(i) for i in prepareList(month_most_common_list)[1:] ] Solar_radiation_64_list = [float(i) for i in prepareList(Solar_radiation_64_list)[1:] ] fig=Figure() ax=fig.add_subplot(111) title='Scatter Diagram of solar radiation against month of the year' ax.set_xlabel('Most common month') ax.set_ylabel('Solar Radiation') fig.suptitle(title, fontsize=14) try: ax.scatter(month_most_common_list, Solar_radiation_64_list) #it is possible to make other kind of plots e.g bar charts, pie charts, histogram except ValueError: pass canvas = FigureCanvas(fig) canvas.print_figure('solarRadMonth.png',dpi=500) if __name__ == "__main__": plotSolarRadiationAgainstMonth('TrainingData.csv')
  • 17.
  • 18. Appendix 2 From the project in folder named WebMonitor class LoadEvent: … def fillMonitorModel(self): for monObj in self.monitorObjList: mObj = Monitor(url = monObj[2], httpStatus = monObj[0], responseTime = monObj[1], contentStatus = monObj[5]) mObj.save() #also see the following examples in project named YAAStasks.py This shows how the analytic tables are loaded with real-time data.
  • 19. Appendix 3 from django.http import HttpResponse from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvasfrom matplotlib.figure import Figurefrom YAAS.stats.models import RegisteredUser, OnlineUser, StatBid #scatter diagram of number of bids made against number of online users # weekly report @staff_member_required def weeklyScatterOnlinUsrBid(request, week_no): page_title='Weekly Scatter Diagram based on Online user verses Bid' weekno=week_no fig=Figure() ax=fig.add_subplot(111) year=stat.getYear() onlUserObj = OnlineUser.objects.filter(week=weekno).filter(year=year) bidObj = StatBid.objects.filter(week=weekno).filter(year=year) onlUserlist = list(onlUserObj.values_list('no_of_online_user', flat=True)) bidlist = list(bidObj.values_list('no_of_bids', flat=True)) title='Scatter Diagram of number of online User against number of bids (week {0}){1}'.format(weekno,year) ax.set_xlabel('Number of online Users') ax.set_ylabel('Number of Bids') fig.suptitle(title, fontsize=14) try: ax.scatter(onlUserlist, bidlist) except ValueError: pass canvas = FigureCanvas(fig) response = HttpResponse(content_type='image/png') canvas.print_png(response) return response More info. can be found in YAAS/graph/The folder named "graph"
  • 20. Appendix 4 # Example of how database may be deleted to recover some space. From folder named “YAAS”. Check task.py @periodic_task(run_every=crontab(hour=1, minute=30, day_of_week= 0)) def deleteOldItemsandBids(): hunderedandtwentydays = datetime.today() - datetime.timedelta(days=120) myItem = Item.objects.filter(end_date__lte=hunderedandtwentydays ).delete() myBid = Bid.objects.filter(end_date__lte=hunderedandtwentydays ).delete()#populate the registereduser and onlineuser model at regular intervals
  • 21. Appendix 5 Check project in YAAS/stats/ for more information on statistical processing
  • 22. Appendix 6 # how to refresh the views in django. To keep the charts. updated. See WebMonitor project {% extends "base.html" %} {% block site_wrapper %} <div id="messages">Updating tables ...</div> <script> function refresh() { $.ajax({ url: "/monitor/", success: function(data) { $('#messages').html(data); } }); setInterval("refresh()", 100000); } $(function(){ refresh(); }); </script> {% endblock %}
  • 23. References  Python documentation ( http://www.python.org/ )  Django documentation ( https://www.djangoproject.com/ )  Stack overflow ( http://stackoverflow.com/ )  Celery documentation (http://ask.github.com/celery/) Pictures  email logo ( http:// ambrosedesigns.co.uk )  blog logo ( http:// sociolatte.com )
  • 24. Thanks for listening Follow me using any of @kenluck2001 kenluck2001@yahoo.com http://kenluck2001.tumblr.com / https://github.com/kenluck200 1