An warware: pytorch mirgina taga

mirgina taga 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:

  1. Shigo da dakunan karatu da suka dace
  2. Loda saitin bayanai
  3. ฦ˜irฦ™iri taga mai jujjuyawa
  4. Yi lissafin matsakaicin motsi na kwanaki 7
  5. 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.

Shafi posts:

Leave a Comment