Duniyar nazarin bayanai galibi tana buฦatar yin aiki tare da bayanan jerin lokaci, kuma wata dabara ta gama gari da ake amfani da ita wajen sarrafa irin waษannan bayanan tana amfani da manufar mirgina taga. Taga mai birgima, wani lokacin ana kiranta da taga mai motsi ko taga mai zamewa, hanya ce da ke ba mu damar raba saitin bayanan mu zuwa ฦananan guntu, sarrafa su, da samun fa'ida mai fa'ida daga jerin abubuwan da aka haifar. Ana amfani da wannan fasaha mai ฦarfi sosai a fannin kuษi, hasashen hasashen, da kuma bincike na zamani, yana mai da shi fasaha mai mahimmanci don samun cikin akwatin kayan aikin bincike. A cikin wannan labarin, za mu bincika manufar taga mai birgima, magance matsala, warware matsalarta zuwa matakai masu sauฦin fahimta, da tattauna dakunan karatu da ayyukan Python masu alaฦa waษanda za su iya sauฦaฦa rayuwarmu.
Bayanin Matsala
Bari mu ษauka muna da tsarin bayanan lokaci wanda ya ฦunshi alkalumman tallace-tallace na yau da kullun na kantin sayar da kayayyaki na shekara guda. Ayyukanmu shine bincika wannan saitin bayanai da ฦididdige matsakaicin tallace-tallace na kwanaki 7 don daidaita abubuwan da ba su dace ba, gano abubuwan da ke faruwa, da jagoranci yanke shawarar kasuwanci. Za mu yi amfani da Python, sanannen kuma yaren shirye-shirye da ake amfani da shi sosai don nazarin bayanai.
Hanyar Magani
Don warware matsalar taga mai juyi, za mu bi waษannan matakan:
- Shigo da dakunan karatu da suka dace
- Loda saitin bayanai
- ฦirฦiri taga mai jujjuyawa
- Yi lissafin matsakaicin motsi na kwanaki 7
- Yi tunanin sakamakon
Bari mu fara da shigo da dakunan karatu da ake buฦata da loda saitin bayanai.
import pandas as pd import numpy as np import matplotlib.pyplot as plt # Load dataset (Assuming the dataset is a CSV file) data = pd.read_csv('sales_data.csv') # Preview the dataset print(data.head())
Bayan mun loda saitin bayanai, yanzu mun ci gaba da ฦirฦirar taga mai jujjuyawa.
ฦirฦirar Tagar Bidiyo
Mu juya zuwa ga masu iko Panda ษakin karatu don ฦirฦirar taga mai jujjuyawa ta amfani da rolling()
aiki. Tagan mai juyi zai sami girman kwanaki 7, kamar yadda muke son ฦididdige matsakaicin motsi na kwanaki 7.
# Create a rolling window of 7 days rolling_window = data['sales'].rolling(window=7)
Yanzu da muke da taga mai juyi, za mu iya ฦididdige matsakaicin motsi na kwanaki 7.
Ana ฦididdige Matsakaicin Motsi na Kwanaki 7
Don nemo matsakaita na tallace-tallace na kwanaki 7, muna kiran kawai mean()
aiki akan abin taga mu na mirgina. Sa'an nan kuma mu ฦara wannan sabon matsakaicin motsi a matsayin sabon shafi a cikin bayanan mu.
# Calculate the moving average data['7_day_avg'] = rolling_window.mean() # Preview the updated dataset print(data.head(10))
A ฦarshe, bari mu hango sakamakonmu don ฦarin fahimtar abubuwan da ke cikin bayananmu.
Sakamako Mai Kallon gani
Za mu yi amfani da mashahuri matplotlib ษakin karatu don ฦirฦirar ginshiฦi mai sauฦi wanda ke nuna duka bayanan tallace-tallace na yau da kullun da matsakaicin motsi na kwanaki 7 da aka ฦididdige.
# Plot the daily sales data plt.plot(data['sales'], label='Daily Sales') # Plot the 7-day moving average plt.plot(data['7_day_avg'], label='7-Day Moving Average', color='red') # Add labels and legend plt.xlabel('Days') plt.ylabel('Sales') plt.title('Daily Sales and 7-Day Moving Average') plt.legend() # Display the plot plt.show()
Taswirar da aka ฦirฦira yana nuna bayanan tallace-tallace na yau da kullun tare da matsakaicin motsi na kwanaki 7, yana sauฦaฦa mana gano abubuwan da ke faruwa da abubuwan da ba su da kyau.
A ฦarshe, ana amfani da taga mai birgima sosai a cikin nazarin bayanai, musamman jerin lokaci, don ikonsa na bayyana ษoyayyun alamu da abubuwan da ke faruwa a cikin manyan bayanan bayanai. Haษin Python, Pandas, da Matplotlib yana sauฦaฦe tsarin ฦididdige matsakaicin motsi da hangen nesa, yana mai da shi batun kusanci ga masu farawa da masana a fagen.