InfiniteWing

Give me a place to stand on, and I will move the Earth

  • 2017-07-21
    Kaggle►Notebook

    [Kaggle]顧客訂單視覺化

    非關視覺化

    幾天前在Kaggle上建立了人生第一次的iPython筆記(iPython Notebook),主要是處理Instacart Market Basket Analysis這項競賽中,產出每個顧客的歷史訂單視覺化。

    由於我深知在Hexo上有許多實用的套件,Google一下關鍵字就找到了hexo-ipynb。本來是想輕輕鬆鬆就能匯入我的iPython Notebook…但是世事難料,不知道是不是版本不同的原因,該套件並無法正確運作。由於覺得要Debug麻煩的關係,我就只好自己寫一個類似的功能囉!

    首先你必須要把你的notebook檔案透過jupyter notebook轉成HTML檔案,並加到你的post_asset_folder當中。然後到你的js檔案中,新增以下幾行:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    function iframeLoaded() {
    var iFrameID = document.getElementById('ipynb');
    if(iFrameID) {
    // here you can make the height, I delete it first, then I make it again
    iFrameID.height = "";
    iFrameID.height = (iFrameID.contentWindow.document.body.scrollHeight+20) + "px";
    }
    }
    (function($){
    //ipython notebook html ifram
    $('iframe').load( function() {
    $('iframe').contents().find("body").css("background","#303030");
    iframeLoaded();
    });
    $( window ).resize(function() {
    iframeLoaded();
    });
    })(jQuery);

    完成上述的前置工作後,如果你要在文章中插入notebook檔案,你只需要在你的文章中插入以下html,就大功告成囉!

    1
    <iframe id="ipynb" src="notebook.HTML" width="100%"></iframe>

    事不宜遲,我們來看看呈現出來的成果,這也是我在這篇文章中主要要呈現的,沒想到又變成更改Hexo設置的一環:

    特別需要注意的是,你的html檔案檔名必須要改成大寫的.HTML,不然Hexo預設的文章解析器會把他當成一個獨立的Post,算是一個小小的Trick…本來我是也打算改這一個設定,但找了半天也還沒找到要怎麼去改解析器,最後就決定大事化小、小事化無,畢竟我也有點懶得找了xDDD。

    完結灑花!
    To be continued..
    Posted at 2017-07-21 08:50:36
    Share 留言
    • Kaggle
    • Notebook
    • Visualization
    • 第一次
    下一篇
    [Kaggle]初探深度學習─亞馬遜叢林辨識(下)
    上一篇
    [Kaggle]初探深度學習─亞馬遜叢林辨識(上)

    InfiniteWing

    總覺得我一直在尋覓著什麼

    最新文章

    • [Performance comparison] CSV reader C/C++ V.S. Python - 2020-07-11
    • [Kaggle] Jigsaw Unintended Bias in Toxicity Classification - 2019-06-28
    • [Kaggle] Instant Gratification - A synchronous Kernels-only competition - 2019-06-21
    • 楓之谷APP開發日誌 ─ 小結 - 2018-08-21
    • WSDM - KKBox's Churn Prediction Challenge - 2018-01-01

    分類

    • Big Data13
      • Cloud Computing3
      • Competition8
      • Deep Learning2
    • FreeBSD1
      • 系統防護1
    • Kaggle1
      • Notebook1
    • Performance comparison1
      • C/C++1
        • Python1
    • 個人作品8
      • 楓之谷APP8
    • 網站設計2
      • Hexo2
    • 論文寫作1

    標籤雲

    Android APP8 Big Data13 C/C++1 CNN2 Cloud Computing3 Deep Learning2 Experience1 FreeBSD1 GCP3 Hexo2 KO1 Kaggle11 Keras2 NLP1 Notebook4 Performance comparison1 Python1 Visualization1 WSDM1 ssmtp1 個人作品8 童年8 第一次3 系統防護1 經驗16 網站設計2 論文寫作1 資訊安全1

    彙整

    • 七月 20201
    • 六月 20192
    • 八月 20181
    • 一月 20181
    • 十二月 20171
    • 十一月 20171
    • 十月 20171
    • 九月 20171
    • 八月 20174
    • 七月 20177
    • 二月 20171
    • 一月 20172
    • 十一月 20151
    • 十月 20152
    • 九月 20151
    © 2021 InfiniteWing all rights reserved.
    Powered by Hexo
  • Home
  • About
  • Archives
  • Work
  • Gallery
  • Private