Saturday, 28 September 2019

Python UDF


# This function adds two numbers
def add(x, y):
   return x + y

# This function subtracts two numbers
def subtract(x, y):
   return x - y

# This function multiplies two numbers
def multiply(x, y):
   return x * y

# This function divides two numbers
def divide(x, y):
   return x / y

print("Select operation.")
print("1.Add")
print("2.Subtract")
print("3.Multiply")
print("4.Divide")

# Take input from the user
choice = input("Enter choice(1/2/3/4):")

num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))

if choice == '1':
   print(num1,"+",num2,"=", add(num1,num2))

elif choice == '2':
   print(num1,"-",num2,"=", subtract(num1,num2))

elif choice == '3':
   print(num1,"*",num2,"=", multiply(num1,num2))

elif choice == '4':
   print(num1,"/",num2,"=", divide(num1,num2))
else:
   print("Invalid input")

Thursday, 26 September 2019

DT

install.packages("party") 

library(party)

input= readingSkills[c(1:105),]

output = ctree(
  nativeSpeaker ~ age + shoeSize + score,
  data = input)

plot(output)

Wednesday, 25 September 2019

Datasetlink

https://drive.google.com/open?id=1oD1mFi4zmqz5xGuCJ7_OdUKZgW5fekct

Tuesday, 24 September 2019

DT - R

install.packages("party") 

library(party)

input= readingSkills[c(1:105),]

output = ctree(
  nativeSpeaker ~ age + shoeSize + score,
  data = input)

plot(output)

Monday, 23 September 2019

LM- R


x = c(151, 174, 138, 186, 128, 136, 179, 163, 152, 131)

y = c(63, 81, 56, 91, 47, 57, 76, 72, 62, 48)

relation = lm(y~x)
________________________________________



# Find weight of a person with height 170.
a = data.frame(x = 170)
result =  predict(relation,a)
print(result)

Saturday, 21 September 2019

Azure IOT HUB

https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-live-data-visualization-in-web-apps#code-try-2

https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-raspberry-pi-kit-node-get-started

https://azure-samples.github.io/raspberry-pi-web-simulator/#Getstarted

Friday, 20 September 2019

link

https://azure.microsoft.com/en-us/services/cognitive-services/directory/vision/

MS API

#Copyright (c) Microsoft Corporation. All rights reserved.
#Licensed under the MIT License.

# -*- coding: utf-8 -*-

import http.client, urllib.parse, json

# **********************************************
# *** Update or verify the following values. ***
# **********************************************

# Replace the subscriptionKey string value with your valid subscription key.
subscriptionKey = 'a8ad3c49b5224ff382cc138a0a52862b'

host = 'api.cognitive.microsoft.com'
path = '/bing/v7.0/Suggestions'

mkt = 'en-US'
query = 'BML'

params = '?mkt=' + mkt + '&q=' + query

def get_suggestions ():
    "Gets Autosuggest results for a query and returns the information."

    headers = {'Ocp-Apim-Subscription-Key': subscriptionKey}
    conn = http.client.HTTPSConnection(host)
    conn.request ("GET", path + params, None, headers)
    response = conn.getresponse ()
    return response.read ()

result = get_suggestions ()
print (json.dumps(json.loads(result), indent=4))