Skip to content

Instantly share code, notes, and snippets.

View erichare's full-sized avatar
🏠
Working from home

Eric Hare erichare

🏠
Working from home
View GitHub Profile
@erichare
erichare / add_two_chain.py
Created July 14, 2022 13:31
A Daisi Chaining Example with Add Two Numbers
import pydaisi as pyd
add_two_numbers = pyd.Daisi("exampledaisies/Add Two Numbers")
first_sum = add_two_numbers.compute(firstNumber=5, secondNumber=6)
second_sum = add_two_numbers.compute(firstNumber=2, secondNumber=1)
add_two_numbers.compute(firstNumber=first_sum, secondNumber=second_sum).value
@erichare
erichare / add_two.py
Created July 14, 2022 13:05
Call add two numbers
import pydaisi as pyd
add_two_numbers = pyd.Daisi("exampledaisies/Add Two Numbers")
add_two_numbers.compute(firstNumber=5, secondNumber=6).value
@erichare
erichare / pca_pydaisi.R
Created July 7, 2022 20:34
Calling PCA Daisi with R
library(rdaisi)
configure_daisi(python_path = "/usr/local/bin/python3")
principal_components_analysis <- Daisi("erichare/Principal Components Analysis")
principal_components_analysis$fit_pca(df=NULL, vars=NULL, n_components=2)$value()
@erichare
erichare / pca_pydaisi.py
Created July 7, 2022 20:32
Calling PCA Daisi with PyDaisi
import pydaisi as pyd
principal_components_analysis = pyd.Daisi("erichare/Principal Components Analysis")
pca_data = principal_components_analysis.fit_pca(df=None, vars=None, n_components=2).value
pca_data
@erichare
erichare / fit_pca.py
Created July 7, 2022 20:26
Fit a PCA using scikit-learn
def fit_pca(pca_data, x_component=1, y_component=2, split_by=None):
...
pca_df = df[vars]
pca = PCA(n_components=n_components)
pca.fit(pca_df)
...
pca_data = pd.DataFrame(pca.fit_transform(pca_df))
@erichare
erichare / yolo_v6_daisi_sample.py
Created June 30, 2022 23:24
Sample of the YOLO v6 Daisi Code
def yolo(image: np.ndarray=None, return_type: list=["Image", "Labels"]):
...
inferer = Inferer(source, weights, device="", yaml="coco.yaml",
img_size=new_width, half=False)
inferer.infer(conf_thres=.25, iou_thres=.45, classes=None,
agnostic_nms=False, max_det=1000, save_dir=tmpdir,
save_txt=save_txt, save_img=save_img, hide_labels=False, hide_conf=False)
...
return yolo_result, label_result
@erichare
erichare / yolo_v6_pydaisi.py
Last active June 30, 2022 23:15
YOLO v6 Object Detection Implemented with Daisies
import pydaisi as pyd
from PIL import Image
yolo_object_detection = pyd.Daisi("erichare/YOLO v6 Object Detection")
img = Image.open("busystreet.png")
img.load()
yolo_result = yolo_object_detection.yolo(img, return_type=['Image']).value
> gn_daisi <- Daisi("GoogleNews")
[1] "Looking for Daisi: GoogleNews"
[1] "https://app.daisi.io/pebble-api/daisies/connect?name=GoogleNews"
> gn_execution <- gn_daisi$get_news(query = "Apple", num = 6)
[1] "Executing Daisi: 4cc93acc-ac2d-4c3b-aeac-f67e96a5c658"
> gn_execution$value()[,1:3]
[1] "Fetching Result: b76e037a-7c7b-4c2f-8a22-cf561ca398aa"
title desc
> bert_daisi <- Daisi("Ask BERT")
[1] "Looking for Daisi: Ask BERT"
[1] "https://app.daisi.io/pebble-api/daisies/connect?name=Ask%20BERT"
> bert_execution <- bert_daisi$compute(context = "Daisi seamlessly integrates the immense power of cloud computing into the workspace of every data scientist. If you are writing data science, AI, or Machine Learning applications, contact us for a free sneak peak of Daisi – the cloud platform to deploy, share, and discover Python serverless functions.", query = "What are Daisies for?")
> bert_execution$value()
[1] "Fetching Result: 4715353b-9703-452d-82fa-88ca7af3fcbe"
[[1]]
[1] "to deploy, share, and discover Python serverless functions."
> titanic_daisi <- Daisi("Titanic Statistics")
[1] "Looking for Daisi: Titanic Statistics"
[1] "https://app.daisi.io/pebble-api/daisies/connect?name=Titanic%20Statistics"
> titanic_execution <- titanic_daisi$raw(rows = 8)
> titanic_execution$value()
[1] "Fetching Result: c2395f17-44a6-459c-b17c-60e394bd4f3e"
PassengerId Sex Age SibSp Parch
1 1 male 22 1 0
2 2 female 38 1 0