An warware: nemo dokokin yanke shawara itace

A cikin duniyar yau, bishiyar yanke shawara wani muhimmin sashi ne na koyon injina da nazarin bayanai. Suna ba mu damar yin abubuwan da suka dace ta hanyar la'akari da alaƙa da dogaro tsakanin mabambantan bayanai. A cikin wannan labarin, mun zurfafa cikin ƙa'idodin bishiyar yanke shawara, aikace-aikacen su, da yadda ake magance matsaloli ta amfani da lambar Python. Bugu da ƙari, za mu bincika wasu ɗakunan karatu na Python da ayyukan da ke cikin tsarin.

Dokokin Bishiyoyin yanke shawara

Bishiyoyin yanke hukunci kayan aiki ne mai ƙarfi don ba da mafita a fagage daban-daban, kamar sanin ƙima, nazarin yanke shawara, da hankali na wucin gadi. Manufarsu ta farko ita ce samar da ingantacciyar wakilcin hadaddun hanyoyin warware matsalolin da sauƙaƙe yanke shawara. Wasu mahimman ƙa'idodin bishiyar yanke shawara sun haɗa da:

  • Kowane kumburi yana wakiltar wani sifa ko yanke shawara.
  • Rassan sun dace da yuwuwar sakamako ko ƙimar sifa na iyaye.
  • Ƙungiyoyin ganye na ƙarshe suna wakiltar rarrabuwa ko yanke shawara.

Ta bin waɗannan ƙa'idodin, itacen yanke shawara zai iya hango duk yanke shawara da sakamako masu yuwuwa kuma ya taimaka wa manazarta yin ƙarin yanke shawara na tushen bayanai.

Gina Bishiyar yanke shawara a Python

Don ƙirƙirar bishiyar yanke shawara don magance matsala, za mu yi amfani da Python azaman harshen shirye-shirye. Python yana ba da ɗakunan karatu da yawa don koyon injin, kamar Scikit-learn, wanda ya zo cike da kayan aikin gina bishiyar yanke shawara.

Mataki 1: Sanya ɗakin karatu da ake buƙata

Kafin mu fara, muna buƙatar shigar da ɗakin karatu na Scikit idan ba a riga an shigar da shi ba:

!pip install scikit-learn

Mataki 2: Shirya bayanai

Bari mu ɗauka muna da kundin bayanai mai ɗauke da bayanai game da abokan ciniki daban-daban da abubuwan da suke so don siyan samfura. Za mu raba bayanan zuwa tsarin horo da gwaji don shirya shi don ƙirar bishiyar yanke shawara.

import pandas as pd
from sklearn.model_selection import train_test_split

# Load and prepare the dataset
data = pd.read_csv('customer_data.csv')
X = data.drop('Preferred_Product', axis=1)
y = data['Preferred_Product']

# Split the dataset into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)

Mataki 3: Gina ƙirar bishiyar yanke shawara

Yin amfani da ɗakin karatu na Scikit, za mu ƙirƙiri mai rarraba bishiyar yanke shawara kuma mu horar da shi akan saitin bayanai.

from sklearn.tree import DecisionTreeClassifier

# Create the decision tree classifier and train it
dt = DecisionTreeClassifier()
dt.fit(X_train, y_train)

Bayanin Python Code

Mun fara da shigar da ɗakin karatu na Scikit-learn, sanannen ɗakin karatu don koyon inji a Python. Bayan haka, mun shirya bayanan ta hanyar raba shi zuwa tsarin horo da gwaji. Wannan yana tabbatar da cewa muna da bayanai don horar da ƙirarmu da bayanan don gwada aikinta daga baya.

Babban ɓangaren lambar ya ta'allaka ne akan amfani da aikin DecisionTreeClassifier daga ɗakin karatu na Scikit don gina ƙirar bishiyar yanke shawara. Aikin yana ɗaukar ma'auni don keɓance mai rarrabawa. Sa'an nan kuma mu dace da classifier ta amfani da dace() hanya da horar da shi a kan bayanan da aka shirya.

Ƙarin Dakunan karatu na Python da Ayyuka

A cikin wannan labarin, mun mayar da hankali kan gina bishiyar yanke shawara mai sauƙi ta amfani da ɗakin karatu na Scikit a Python. Koyaya, akwai ƙarin ɗakunan karatu da ayyuka masu alaƙa da yanke shawara bishiyoyi da koyan injina.

  • Graphviz: Laburare don ganin tsarin tsarin bishiyar yanke shawara don ƙarin fahimtar ƙirar ƙarshe.
  • RandomForestClassifier: Aiki a cikin ɗakin karatu na Scikit wanda ke haifar da tarin bishiyoyi masu yanke shawara, haɓaka hasashen gaba ɗaya da kwanciyar hankali.

A ƙarshe, ƙa'idodin bishiyar yanke shawara suna da mahimmanci don fahimtar tsarin bayanai da kuma yanke shawara mafi kyau. Python, tare da manyan ɗakunan karatu na koyon injin, yana sauƙaƙa don gina ƙirar bishiyar yanke shawara da bincika yuwuwar su a cikin yanayin warware matsaloli daban-daban. Ta hanyar yin amfani da waɗannan ɗakunan karatu da ayyuka, za mu iya inganta samfuranmu da yin ƙarin yanke shawara na tushen bayanai a cikin ayyukanmu.

Shafi posts:

Leave a Comment