Skip to content

Instantly share code, notes, and snippets.

View jasdeep06's full-sized avatar

Jasdeep Singh Chhabra jasdeep06

View GitHub Profile
from elasticsearch import Elasticsearch
import json
import requests
from elasticsearch import helpers
#To get over memory contraints
#retardness of Macs
#curl - XPUT - H "Content-Type: application/json" http: // localhost:9200 / _all / _settings - d'{"index.blocks.read_only_allow_delete": false}'
In elasticsearch,in order to apply aggregation on a filtered data,you can proceed in two ways:
1)First Way-
a) Write a filter query
b)Include aggregations in query['aggs'].
This way shows that aggregations in ES are applied on the result of queried data.This case works perfectly when the objects
retrieved after querying are fully in compliance with your query.This assumptions can be incorrect in case of nested objects.
Eg -
Let saleHistory be a nested field of property object.
'saleHistory':[
{'purchasePrice':800000,'contractDate':'20110917'},
@jasdeep06
jasdeep06 / computer_vision.md
Last active September 30, 2019 13:38
vision
  1. Reading an image in PIL gives a native PIL object.The size of the image is represented as width,height(PIL does not return channels)(400,300).This PIL object can be converted into numpy array by passing the PIL object to numpy.array().The returned object is a numpy array of shape attribute rows,columns,channels(300,400).Plotting both images in matplotlib gives rightly plotted image.
import matplotlib.pyplot as plt
from PIL import Image
import numpy as np

img = Image.open('data/image.jpg').convert('L')
print(img.size)#(400,300)

np_img = np.array(img)
  1. torch.cat(x,y,dim=0)

Concatinates tensors along the specified dimension.

The output tensor has same shape as input tensor except in dimension to be concatinated.

The input tensors must have same shape except the dimension in which concatination has to take place.

x= torch.randn(1,1,2,3)
//simple function(named)
function hello(name){
console.log("Hello",name)
}
//expression function
const hello = function(name){
console.log("Hello",name)
}