Python JSON Datasıyla Çalışmak




Python JSON Datasıyla Çalışmak

import requests
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np

response = requests.get('URL',
                         auth=('KULLANICI_ADI', 'SIFRE'))

data = response.json()

veriler = data['BASLIK']

df = pd.DataFrame(veriler, columns=['Yil','Ay','KisiSayisi'])

print(df)

yil = df['Yil'].astype(str).astype(int)
ay = df['Ay'].astype(str).astype(int)

df["yeni"] =(yil - yil.min()) * 12 + ay

X=df.iloc[:,-1:].values
y=df.iloc[:,2].values

from sklearn.linear_model import LinearRegression
regres=LinearRegression()
regres.fit(X,y)

sort=df.sort_values(by="yeni")
plt.figure(figsize=(15,8))
plt.scatter(X,y,color="red", label='Gerçek Değerler')
plt.plot(X,regres.predict(X),color='blue', label='Tahmini Değerler')
plt.title("Süt Yardımı Kişi Sayısı Tahmini")
plt.legend()
plt.xlabel("Zaman")
plt.ylabel("Kişi Sayısı")
plt.xticks(sort["yeni"].values, sort["Yil"].astype(str).values +"/"+ sort["Ay"].astype(str).values, rotation=90)
plt.show()


print('2018 Ocak Ayı Tahmini:', int(np.round(np.array(regres.predict(37)),2)))
print('2018 Şubat Ayı Tahmini:', int(np.round(np.array(regres.predict(38)),2)))
print('2018 Mart Ayı Tahmini:', int(np.round(np.array(regres.predict(39)),2)))
print('2018 Nisan Ayı Tahmini:', int(np.round(np.array(regres.predict(40)),2)))
print('2018 Mayıs Ayı Tahmini:', int(np.round(np.array(regres.predict(41)),2)))
print('2018 Haziran Ayı Tahmini:', int(np.round(np.array(regres.predict(42)),2)))
print('2018 Temmuz Ayı Tahmini:', int(np.round(np.array(regres.predict(43)),2)))
print('2018 Ağustos Ayı Tahmini:', int(np.round(np.array(regres.predict(44)),2)))
print('2018 Eylül Ayı Tahmini:', int(np.round(np.array(regres.predict(45)),2)))
print('2018 Ekim Ayı Tahmini:', int(np.round(np.array(regres.predict(46)),2)))
print('2018 Kasım Ayı Tahmini:', int(np.round(np.array(regres.predict(47)),2)))
print('2018 Aralık Ayı Tahmini:', int(np.round(np.array(regres.predict(48)),2)))










Unknown Business Intelligence Specialist

Karar Destek Sistemi, Oracle İş Zekası, Business Intelligence, Obiee 11g, PlSql, R Programming, ODI, Veri madenciliği, Data Mining, Big Data, Python.

Hiç yorum yok:

Yorum Gönder