Skip to content

Instantly share code, notes, and snippets.

View mickaellegal's full-sized avatar

Mickael Le Gal mickaellegal

View GitHub Profile
@mickaellegal
mickaellegal / nyt_article_classifier.ipynb
Last active January 3, 2016 21:49
iPython Notebook: Blog article classifier
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mickaellegal
mickaellegal / app.py
Last active January 3, 2016 22:19
Python: Blog flask app
# We first import all the libraries needed
from flask import Flask, request, render_template, jsonify
from yhat import Yhat
import os
#We create the application object of class Flask
app = Flask(__name__)
# We set our credential to access our model on yhat from the Flask app
yh = Yhat(os.environ.get("YHAT_USERNAME"), os.environ.get("YHAT_APIKEY"))
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@mickaellegal
mickaellegal / 50onRed_test_mlg
Created January 27, 2014 17:38
iPython Notebook: 50onRed test
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@mickaellegal
mickaellegal / heroku.sh
Last active August 29, 2015 13:55
Shell: Heroku configuration yHat
Heroku create
git push heroku master
# Wait for the application to upload on heroku
heroku config:set YHAT_USERNAME=your_yhat_username
heroku config:set YHAT_APIKEY=your_yhat_api_key
@mickaellegal
mickaellegal / yhat.sh
Created January 30, 2014 16:49
Shell: yHat login
yh = Yhat("YHAT_USERNAME", "YHAT_APIKEY")
yh.deploy("NYTimesClassifier", myModel)
# Once everything is uploaded you should see the following message
uploading... done!
{u'modelname': u'NYTimesClassifier', u'status': u'success', u'version': 1}
@mickaellegal
mickaellegal / book_reco.py
Last active July 26, 2016 13:35
Python: Blog Pearson correlation coefficient for book reviews
# Importing the libraries
from scipy.stats.stats import pearsonr
import pandas as pd
import numpy as np
import json
data = pd.read_csv("../../Downloads/data_books.csv", sep = ",", header=None,
names=['Reviewer', 'Book', 'Rating'])
# Picking 2 books
@mickaellegal
mickaellegal / book_reco.ipynb
Created February 2, 2014 08:55
iPython Notebook: Blog book recommendation
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mickaellegal
mickaellegal / dayone_lcp
Last active February 6, 2017 05:23
Day One and Launch Center Pro Workflow
dayone://post?entry=My Daily Review
|Daily Review||
|:---|:---|
|Summary|[prompt: Today's one word summary]|
|Did I work?|[list: Did I work today?|Yes|No]|
|Did I relax?|[list: Did I relax today?|Yes|No]|
|Physical Exercise|[list: Did I workout today?|Yes|No]|
|Satisfaction|[list: Am I happy with what I did today?|Yes|No]|
|Goals|[list:Any progress toward my goals?|Yes|No]|
@mickaellegal
mickaellegal / ragged_csv.py
Created June 16, 2014 09:31
Python: Handle ragged csv files
import pandas as pd
import numpy as np
import csv
file = "YOUR_FILE_PATH"
# Read the csv with python
lines=list(csv.reader(open(file)))
# Get the name of the columns