Alustuseks lihtsamad tehted Üldotstarbeliste arendusplatvormide kursuse juures
print("tere")
print("tere")
Juku | Kati | Mati |
---|---|---|
169 | 173 | 165 |
algne kiri
Juku vastus ja vastuse jätk
Eraldi real vastus
3+2
import pandas as pd
#lapsed=pd.read_csv("http://www.tlu.ee/~jaagup/andmed/muu/5klass.txt")
m={'eesnimi':["Juku", "Kati", "Mati"], 'pikkus':[165, 172, 171],
'mass':[58, 49, 56], 'sugu':["m","n", "m"]}
lapsed=pd.DataFrame(data=m)
lapsed.head()
lapsed[lapsed.sugu=="m"]
lapsed[lapsed.pikkus>170]
lapsed.eesnimi.count()
lapsed.groupby("sugu").eesnimi.count()
lapsed["pikkusm"]=lapsed.pikkus/100
lapsed
del lapsed["pikkusm"]
lapsed
eesnimed=lapsed.eesnimi.values.tolist()
eesnimed
eesnimed[0]
print(lapsed.mass.min())
print(lapsed.pikkus.mean())
lapsed.pikkus.median()
lapsed.mass.cumsum()
import matplotlib.pyplot as plt
%matplotlib inline
plt.plot([160, 180, 170])
lapsed.plot("pikkus", "mass")
lapsed.plot(x="pikkus", kind="bar")
lapsed.plot.pie(y="mass")
plt.figure()
plt.xlim([155, 185])
plt.ylim([30, 50])
plt.title("Laste andmed")
plt.xlabel("pikkused")
plt.ylabel("massid")
plt.plot([160, 175, 170], [38, 35, 39], "ro")
plt.plot([166, 175, 177], [41, 38, 45], "bo")
from azureml import Workspace
ws = Workspace()
experiment = ws.experiments['66e373b2084d4ffa9395c0e34ce9ccaa.f-id.c9bd98833fb248499b4c909fbeedfceb']
ds = experiment.get_intermediate_dataset(
node_id='39083f31-4d5a-42c9-8ea2-2ca379c33f7a-1107',
port_name='Results dataset',
data_type_id='GenericCSV'
)
frame = ds.to_dataframe()
frame.head()
#Kuvage xY-joonis, kus on näha õunte suurused augustis ja septembris
#Lisage telgede nimetused ja pealkiri
#frame.august.values.tolist()
plt.figure()
plt.title("Õunte suurused")
plt.xlabel("august")
plt.ylabel("september")
plt.xlim([0, 100])
plt.ylim([0, 100])
plt.scatter(frame.august, frame.september, color="green")
augustkesk=frame.august.mean()
septemberkesk=frame.september.mean()
plt.plot([augustkesk, augustkesk], [0, 100], linestyle="dotted", linewidth=0.3)
plt.plot([0, 100],[septemberkesk, septemberkesk],
linestyle="dotted", linewidth=0.3)
#Tõmmake keskmise joon ka septembri kohta
#Muutke joon õrnemaks
import numpy as np
tous, vabaliige=np.polyfit(frame.august, frame.september, 1)
x0=frame.august.min()
y0=tous*x0+vabaliige
x1=frame.august.max()
y1=tous*x1+vabaliige
plt.plot([x0, x1], [y0, y1])
import urllib.request
import json
data = {
"Inputs": {
"sisend":
[
{'august': "1",},
{'august': "50",},
{'august': "60",}
],
},
"GlobalParameters": {
}
}
body = str.encode(json.dumps(data))
url = 'https://ussouthcentral.services.azureml.net/workspaces/66e373b2084d4ffa9395c0e34ce9ccaa/services/eb1244be63a54bb9b0863642e0d30f20/execute?api-version=2.0&format=swagger'
api_key = 'H6jP3QxxDAR7QgnCVu0h0l82CZa075/6ZHDF4rELwP4hizvteG9J1UVMF52HCf7GESIPPjVcUdidVIAZhsnx9Q==' # Replace this with the API key for the web service
headers = {'Content-Type':'application/json', 'Authorization':('Bearer '+ api_key)}
req = urllib.request.Request(url, body, headers)
try:
response = urllib.request.urlopen(req)
result = response.read()
obj=json.loads(result.decode("utf-8"))
print(obj["Results"]["ennustus"])
m=[float(vastus["Scored Labels"]) for vastus in obj["Results"]["ennustus"]]
print(m)
except urllib.error.HTTPError as error:
print("The request failed with status code: " + str(error.code))
# Print the headers - they include the requert ID and the timestamp, which are useful for debugging the failure
print(error.info())
print(json.loads(error.read().decode("utf8", 'ignore')))