日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > python >内容正文

python

python二元函数如何编写,如何用Python和sklearn编写多元对数回归?

發(fā)布時(shí)間:2025/3/19 python 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python二元函数如何编写,如何用Python和sklearn编写多元对数回归? 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

我寫了一個(gè)多元多項(xiàng)式回歸的代碼,我使用了來自sklearn的多項(xiàng)式特征和轉(zhuǎn)換函數(shù)。有可能進(jìn)行多元對(duì)數(shù)回歸嗎?

sklearn是否有某種對(duì)數(shù)變換,就像它對(duì)多項(xiàng)式特征的那樣?

如何在python中編寫多元對(duì)數(shù)回歸?在

這是我的多元多項(xiàng)式特征代碼:import numpy as np

import pandas as pd

import math

import xlrd

from sklearn import linear_model

from sklearn.model_selection import train_test_split

from sklearn.preprocessing import PolynomialFeatures

#Reading data from excel

data = pd.read_excel("dataset.xls").round(2)

data_size = data.shape[0]

#print("Number of data:",data_size,"\n",data.head())

def polynomial_prediction_of_future_strength(input_data, cement, blast_fur_slug,fly_ash,

water, superpl, coarse_aggr, fine_aggr, days):

variables = prediction_accuracy(input_data)[2]

results = prediction_accuracy(input_data)[3]

n = results.shape[0]

results = results.values.reshape(n,1) #reshaping the values so that variables and results have the same shape

#transforming the data into polynomial function

Poly_Regression = PolynomialFeatures(degree=2)

poly_variables = Poly_Regression.fit_transform(variables)

#accuracy of prediction(splitting the dataset on train and test)

poly_var_train, poly_var_test, res_train, res_test = train_test_split(poly_variables, results, test_size = 0.3, random_state = 4)

input_values = [cement, blast_fur_slug, fly_ash, water, superpl, coarse_aggr, fine_aggr, days]

input_values = Poly_Regression.transform([input_values]) #transforming the data for prediction in polynomial function

regression = linear_model.LinearRegression() #making the linear model

model = regression.fit(poly_var_train, res_train) #fitting polynomial data to the model

predicted_strength = regression.predict(input_values) #strength prediction

predicted_strength = round(predicted_strength[0,0], 2)

score = model.score(poly_var_test, res_test) #accuracy prediction

score = round(score*100, 2)

accuracy_info = "Accuracy of concrete class prediction: " + str(score) + " %\n"

prediction_info = "Prediction of future concrete class after "+ str(days)+" days: "+ str(predicted_strength)

info = "\n" + accuracy_info + prediction_info

return info

#print(polynomial_prediction_of_future_strength(data, 214.9 , 53.8, 121.9, 155.6, 9.6, 1014.3, 780.6, 7))

總結(jié)

以上是生活随笔為你收集整理的python二元函数如何编写,如何用Python和sklearn编写多元对数回归?的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。