• Chiziqli regressiyadan foydalanish uchun uni import qilishimiz kerak
  • import statsmodels.api as sm




    Download 91,33 Kb.
    bet3/4
    Sana29.05.2024
    Hajmi91,33 Kb.
    #257013
    1   2   3   4
    Bog'liq
    713 19 J Muxamadaliyev

    ## Without a constant import statsmodels.api as sm X = df["RM"] y = target["MEDV"] # Note the difference in argument order model = sm.OLS(y, X).fit() predictions = model.predict(X) # make the predictions by the model # Print out the statistics model.summary()

    ## Without a constant import statsmodels.api as sm X = df["RM"] y = target["MEDV"] # Note the difference in argument order model = sm.OLS(y, X).fit() predictions = model.predict(X) # make the predictions by the model # Print out the statistics model.summary()

    SKLearnda chiziqli regressiya - Pythonda mashinani o'rganish haqida gap ketganda, SKLearn deyarli oltin standartdir. U regressiya, tasniflash, klasterlash va o'lchamlarni kamaytirish uchun ko'plab o'rganish algoritmlariga ega. Turli xil algoritmlar xaritasi va SKLearn ga boshqa havolalar uchun KNN algoritmidagi foydalanadi.

    Chiziqli regressiyadan foydalanish uchun uni import qilishimiz kerak:

    from sklearn import linear_model

    Keling, avvalroq foydalangan ma'lumotlar to'plamidan, uy narxlaridan foydalanaylik. Dastlab, jarayon bir xil bo'ladi: SKLearn-dan ma'lumotlar to'plamlarini import qiling va ularni uy ma'lumotlar to'plamiga yuklang:

    Keling, avvalroq foydalangan ma'lumotlar to'plamidan, uy narxlaridan foydalanaylik. Dastlab, jarayon bir xil bo'ladi: SKLearn-dan ma'lumotlar to'plamlarini import qiling va ularni uy ma'lumotlar to'plamiga yuklang:

    from sklearn import datasets ## imports datasets from scikit-learn data = datasets.load_boston() ## loads home dataset from datasets library

    Keyinchalik, ma'lumotlarni Pandasga yuklaymiz (avvalgidek):

    # define the data/predictors as the pre-set feature names df = pd.DataFrame(data.data, columns=data.feature_names) # Put the target (housing value -- MEDV) in another DataFrame target = pd.DataFrame(data.target, columns=["MEDV"])

    Shunday qilib, endi, avvalgidek, bizda mustaqil o'zgaruvchilar ("df") va bog'qa o'zgaruvchiga ega bo'lgan ma'lumotlar to'plami ("maqsad" belgisi) mavjud. SKLearn yordamida regressiya modelini moslashtiramiz. Avval biz X va Y ni aniqlaymiz - bu safar uy narxlarini taxmin qilish uchun dataframedagi barcha o'zgaruvchilardan foydalanamiz:


    Download 91,33 Kb.
    1   2   3   4




    Download 91,33 Kb.