Skip to content

Instantly share code, notes, and snippets.

View davidkyle's full-sized avatar

David Kyle davidkyle

  • elastic
  • United Kingdom
View GitHub Profile
@davidkyle
davidkyle / upload_local_elser.py
Created November 8, 2023 10:33
Script to install a local copy of the ELSER model in Elasticsearch
from elasticsearch import Elasticsearch
from eland.ml.pytorch import PyTorchModel
from eland.ml.pytorch.nlp_ml_model import (
TextExpansionInferenceOptions,
NlpTrainedModelConfig,
TrainedModelInput,
NlpBertTokenizationConfig
)
@davidkyle
davidkyle / README.md
Last active December 12, 2020 09:50
Aggregations and Visualisations supporting the Inference Pipeline Agg blog

Getting started with the Inference Aggregation

First ingest the customer churn data and trained model

Ingest the linked csv files above into Elastic using the Kibana Data Visualizer. You will find the Data Visualizer in the Machine Learning section. Ingest into the indices calls and customers.

@davidkyle
davidkyle / events_agg.json
Created July 21, 2020 13:39
Script for gathering timing stats for an inference/not inference aggregation
{
"size": 1,
"aggs": {
"session": {
"composite": {
"size": 10,
"sources": [
{
"session": {
"terms": {
@davidkyle
davidkyle / ESModel.py
Created February 10, 2020 10:05 — forked from benwtrent/ESModel.py
model transformers
from typing import List
def add_if_exists(d: dict, k: str, v) -> dict:
"""
:param v:
:param k:
:type d: object
"""
if v is not None:
@davidkyle
davidkyle / inference-rescore-example.sh
Created February 7, 2020 16:37
Create a trivial model and rescore with it
#!/bin/sh
curl -XPUT -u 'elastic:password' -H 'Content-Type: application/json' 'http://localhost:9200/_ml/inference/density_model?pretty' -d '
{
"input": {
"field_names": [
"key_metric"]
},
"description": "test model for regression",
@davidkyle
davidkyle / farequote_epoch_ms.csv
Created July 2, 2018 10:32
ML Calendar Bug test data
We can't make this file beautiful and searchable because it's too large.
time,airline,responsetime,sourcetype
1403481600000,AAL,132.2046,farequote
1403481600000,JZA,990.4628,farequote
1403481600000,JBU,877.5927,farequote
1403481600000,KLM,1355.4812,farequote
1403481600000,NKS,9991.3981,farequote
1403481600000,TRS,412.1948,farequote
1403481600000,DAL,401.4948,farequote
1403481600000,FFT,181.5529,farequote
1403481600000,SWA,160.214,farequote