Skip to content

Instantly share code, notes, and snippets.

@klaus82
klaus82 / airflow-kmeas.py
Created March 31, 2019 13:37
airflow dag for kmeans
from airflow import DAG
from airflow.operators.python_operator import PythonOperator
from datetime import datetime, timedelta
from algorithm import test
default_args = {
"owner": "airflow",
"depends_on_past": False,
"start_date": datetime(2015, 6, 1),
"email": ["airflow@airflow.com"],
from keras.callbacks import ModelCheckpoint
# checkpoint
filepath="weights.best.hdf5"
checkpoint = ModelCheckpoint(filepath, monitor='val_acc', verbose=1, save_best_only=True, mode='max')
callbacks_list = [checkpoint]
batch_size = 512
history = model.fit(partial_X_train,
partial_Y_train,
@klaus82
klaus82 / tweet_classification_index_creator.sh
Last active May 2, 2018 11:00
tweet_classification_index_creator.sh
#####!/usr/bin/env /bin/bash
#! /bin/bash
INDEX_NAME="tweet-classification"
curl -XPUT "http://localhost:9200/$INDEX_NAME/" -d '{
"settings": {
"number_of_shards": 2,
"number_of_replicas": 1
},
"mappings": {
"classified-tweet": {
@klaus82
klaus82 / load_nn_keras.py
Created May 2, 2018 08:52
load neural network with keras from file
from keras.models import load_model
def load_nn(nn_hdf5_filename):
model = load_model(nn_hdf5_filename)
return model
def main():
#load neural network model
model = load_nn('weights.best.hdf5')
@klaus82
klaus82 / dockerfile
Created January 14, 2018 07:07
My data science container
# base image
FROM python:3.6
# updating repository
RUN apt-get update
# copying requirements.txt file
COPY requirements.txt requirements.txt
# pip install
# ## Sentiment analysis
# In[12]:
import nltk
# In[8]:
nltk.download("punkt")
@klaus82
klaus82 / Flight_tweet_analysis.py
Last active September 18, 2017 19:15
Flight_tweet_analysis
# coding: utf-8
# In[1]:
import pandas as pd
import numpy as np
# In[2]:
#Read the dataset in csv
tweets = pd.read_csv('./twitter-airline-sentiment/Tweets.csv', sep=',')
import matplotlib.pyplot as plt
import numpy as np
import tensorflow as tf
import pandas as pd
import csv
num_clusters = 4
num_steps = 100
num_vectors = 1000
public class Singleton {
private static final Singleton instance = new Singleton();
public static Singleton getInstance() { return instance; }
private Singleton() {}
}