• AMALIY MASHG’ULOT
  • Chiziqli regressiya tushunchasi. Ikkinchi darajali polynomial regressiya tushunchasi. y=wx+b va y=w1x2+w2x+b funksiyalardagi og`irliklar va bias qiymatlarini topish. Gradient pastlash va Loss grafigi.
  • O‘zbekiston respublikasi axborot texnologiyalari va kommunikatsiyalarini rivojlantirish vazirligi




    Download 0,78 Mb.
    bet1/2
    Sana22.05.2024
    Hajmi0,78 Mb.
    #250635
      1   2
    Bog'liq
    Mashinali o`qitish amaliy ish


    O‘ZBEKISTON RESPUBLIKASI
    AXBOROT TEXNOLOGIYALARI VA
    KOMMUNIKATSIYALARINI RIVOJLANTIRISH VAZIRLIGI

    MUHAMMAD AL-XORAZMIY NOMIDAGI
    TOSHKЕNT AXBOROT TЕXNOLOGIYALARI UNIVЕRSITЕTI


    MACHINALI O’QITISHGA KIRISH FANIDAN


    AMALIY MASHG’ULOT

    Guruh: AX 070-20
    Bajardi: Mingboyev.A
    Tekshirdi: Qobilov. S


    Toshkent 2024

    AMALIY MASHG`ULOT.
    Python kutubxonalaridan foydalangan holda dataset xosil qilish. Bunda o‘zgaruvchilar soni kamida 10 tani va qatorlar soni 20 tani tashkil etishi lozim. Olingan datasetdan foydalangan holda har bir talaba sklearn kutubxonasi orqali modelini tuzadi.

    1. import numpy as np
      import pandas as pd
      from sklearn.model_selection import train_test_split
      from sklearn.linear_model import LinearRegression
      from sklearn.metrics import mean_squared_error

      # Randomly generate a dataset with at least 10 features and 20 samples


      np.random.seed(0)
      num_features = 10
      num_samples = 20
      X = np.random.rand(num_samples, num_features)
      y = np.random.rand(num_samples)

      # Split the dataset into training and test sets


      X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=0)

      # Train a linear regression model


      model = LinearRegression()
      model.fit(X_train, y_train)

      # Evaluate the model


      y_pred = model.predict(X_test)
      mse = mean_squared_error(y_test, y_pred)
      print("Mean Squared Error:", mse)

    import pandas as pd


    from sklearn.datasets import load_wine

    wine_data = load_wine()

    # Convert data to pandas dataframe
    wine_df = pd.DataFrame(wine_data.data, columns=wine_data.feature_names)

    # Add the target label


    wine_df["target"] = wine_data.target

    # Take a preview


    wine_df.head()
    N atija:

    Chiziqli regressiya tushunchasi. Ikkinchi darajali polynomial regressiya tushunchasi. y=wx+b va y=w1x2+w2x+b funksiyalardagi og`irliklar va bias qiymatlarini topish. Gradient pastlash va Loss grafigi.


    Dastur kodi:
    import time
    import numpy as np
    import matplotlib.pyplot as plt
    N=int(input("N sonini kiriting =>"))
    x=np.zeros(N)
    y=np.zeros(N-1)
    r=np.zeros(N)
    w=np.zeros(N)
    w1=np.zeros(N-1)
    x[0]=1
    for i in range(1,N):
    x[i]=x[i-1]+1
    y[i-1]=-2*x[i-1]

    w[0] = 0
    a=0.01


    for i in range(1,N):
    S=0
    for j in range(0,3):
    r[j]=pow(w[i-1]*x[j]-y[j],2)
    S=S+r[j]
    w1[i-1]=S/3
    w[i] = w[i-1] + a
    print(w1[i-1])
    plt.plot(w1)
    plt.show()

    Download 0,78 Mb.
      1   2




    Download 0,78 Mb.

    Bosh sahifa
    Aloqalar

        Bosh sahifa



    O‘zbekiston respublikasi axborot texnologiyalari va kommunikatsiyalarini rivojlantirish vazirligi

    Download 0,78 Mb.