Skip to content

Instantly share code, notes, and snippets.

View HariSan1's full-sized avatar

Hari Santanam HariSan1

View GitHub Profile
# prep data for running ludwig time series, from ludwig examples
import pandas as pd
from ludwig.utils.data_utils import add_sequence_feature_column
df = pd.read_csv(
'/content/weather_forecast/temperature.csv',
usecols=['Los Angeles']
).rename(
columns={"Los Angeles": "temperature"}
).fillna(method='backfill').fillna(method='ffill')
ludwig experiment \
--data_csv /content/weather_forecast/temperature_la.csv \
--model_definition_file /content/weather_forecast/model_definition.yaml \
--output_directory /content/weather_forecast/results/
#Now run ludwig - its that simple! watch the output below
#format is
#!ludwig train --data_train_csv <PATH TO TRAINING FILE> --data_test_csv <PATH TO TESTING FILE> --model_definition_file <MODEL DEF FILE>
#Exclamation mark required if running from Google Colab Jupyter notebook
!ludwig train \
--data_train_csv '/content/train.csv' \
--data_test_csv '/content/test.csv' \
--model_definition_file model_definition.yaml
@HariSan1
HariSan1 / ludwig-titanic-mount-copy-files
Last active February 18, 2020 16:19
mount files from Google Drive and copy files for ludwig Titanic survivor prediction example
#Do the following ONLY IF YOU ARE IN GOOGLE COLAB AND are importing the required files from Google One Drive
#Un-comment the lines below
from google.colab import drive
drive.mount('/content/drive')
!ls "/content/drive/My Drive"
#I copied the following from my Google One Drive to the colab /content/ default drive, ensure that your path is correct as needed
#read my article on how to create model definition file here:
#download the titanic dataset from Kaggle here: https://www.kaggle.com/c/titanic/
#below lines are for copying from Google One Drive to Google colab. Skip if this is not your setup
!cp "/content/drive/My Drive/Colab Notebooks/Titanic/model_definition.yaml" "/content/model_definition.yaml"
@HariSan1
HariSan1 / folium-nj-2017-crashes-gist.ipynb
Created December 27, 2018 02:28
folium-nj-2017-crashes-gist.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
##!/usr/bin/env python3
"""
Created on Mon Mar 12 21:36:39 2018
" TSB visual recognition of keras fashion dataset with SGD
" fashion dataset has images of various types of clothing and accessories
"show some of the images and predictions
"1st iteration created the model (commented out, explained in comments),
"this iteration calls and uses it
@author: hsantanam
"""
#module that moves a point (x,y) in 4 different directions, and calculates distance from another existing point
#I called the class Rocket as it could be intended for a rocket game
#Created on Thu Nov
#@author: hsantanam
#"""
from math import sqrt
class Rocket():
#TSB - Create Class in Python - rocket positions (x,y) and use to graph
import matplotlib.pyplot as plt
class Rocket():
def __init__(self, x=0, y=0):
#each rocket has (x,y) position; user or calling function has choice
#of passing in x and y values, or by default they are set at 0
self.x = x
self.y = y
#TSB - Use our own previously created module in Python - rocket positions (x,y)
import matplotlib.pyplot as plt
import simple_module1 as rg
#Make a series of rockets
rockets=[]
rockets.append(rg.Rocket())
rockets.append(rg.Rocket(0,2))
rockets.append(rg.Rocket(1,4))
rockets.append(rg.Rocket(2,6))
#TSB
#simple module to calculate rocket class and move it up, down, left, right on demand
#also calculate distance from this rocket to other rocket
from math import sqrt
class Rocket():
#create and init the class
def __init__(self, x=0, y=0):
self.x = x