This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##!/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 | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
NewerOlder