当前位置: 首页 > news >正文

展馆展厅设计方案郑州seo代理外包

展馆展厅设计方案,郑州seo代理外包,阜宁县网站建设,网站建设多少钱一年线性回归 知识点: 1. 线性回归模型可以使用不同的目标函数,最常用的是最小二乘法、最小绝对值法和最大似然法。 2. 在最小二乘法中,目标是最小化实际值与预测值之间的误差平方和,这可以通过求导数等方法来求解。 3. 在最小绝对值…

线性回归

知识点:
1. 线性回归模型可以使用不同的目标函数,最常用的是最小二乘法、最小绝对值法和最大似然法。
2. 在最小二乘法中,目标是最小化实际值与预测值之间的误差平方和,这可以通过求导数等方法来求解。
3. 在最小绝对值法中,目标是最小化实际值与预测值之间的误差绝对值和,这可以使用线性规划等方法来求解。
4. 在最大似然法中,目标是估计模型参数,使得在给定自变量的条件下,因变量的概率最大化。
5. 线性回归模型的参数估计可以使用基于梯度下降的算法,如批量梯度下降、随机梯度下降、小批量梯度下降等。
6. 在应用线性回归模型时,需要注意多重共线性、异方差性、自相关等问题,并采取相应的处理措施。
7. 除了传统的线性回归模型,还有多项式回归、岭回归、lasso回归、弹性网络回归等变种模型。

逻辑回归

import numpy as npclass LogisticRegression:def __init__(self, learning_rate=0.01, num_iterations=10):self.learning_rate = learning_rateself.num_iterations = num_iterationsself.weights = Noneself.bias = Nonedef fit(self, X, y):num_samples, num_features = X.shapeprint(num_samples,num_features)self.weights = np.zeros(num_features)print(X)print(self.weights)self.bias = 0# 梯度下降算法for i in range(self.num_iterations):linear_model = np.dot(X, self.weights) + self.biasprint(linear_model)y_pred = self._sigmoid(linear_model)print("sigmoid")print(y_pred)print("end")# 计算损失函数的梯度dw = (1 / num_samples) * np.dot(X.T, (y_pred - y))db = (1 / num_samples) * np.sum(y_pred - y)# 更新权重和偏移量self.weights -= self.learning_rate * dwself.bias -= self.learning_rate * dbdef predict(self, X):print("pre")print(X)linear_model = np.dot(X, self.weights) + self.biasy_pred = self._sigmoid(linear_model)y_pred_class = [1 if i > 0.5 else 0 for i in y_pred]return np.array(y_pred_class)def _sigmoid(self, x):return 1 / (1 + np.exp(-x))# 创建训练数据
X_train = np.array([[1,2,3],[2,3,4],[3,4,5],[4,5,6], [5,6,7]])
y_train = np.array([0, 0, 1, 1, 1])# 创建逻辑回归模型
lr_model = LogisticRegression()# 训练模型
lr_model.fit(X_train, y_train)# 预测新数据
X_new = np.array([[2,4,6], [3,5,7]])
y_pred = lr_model.predict(X_new)print(y_pred)

SVM

基于sklearn库实现SVM:

from sklearn import datasets
from sklearn.model_selection import train_test_split
from sklearn.svm import SVC
from sklearn.metrics import accuracy_score# 加载数据集
iris = datasets.load_iris()
X = iris.data
y = iris.target# 划分训练集和测试集
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
# 创建 SVM 模型对象
svm_model = SVC(kernel='linear', C=1)# 训练 SVM 模型
svm_model.fit(X_train, y_train)# 预测测试集数据
y_pred = svm_model.predict(X_test)# 计算准确率
acc = accuracy_score(y_test, y_pred)
print('Accuracy:', acc)

具体代码实现:(复习后再过来研究)

import numpy as np# 定义 SVM 模型类
class SVM:def __init__(self, C=1.0, kernel='linear', gamma=1.0):self.C = C               # 惩罚系数self.kernel = kernel     # 核函数类型self.gamma = gamma       # 核函数参数self.alpha = None        # 拉格朗日乘子self.b = 0               # 阈值self.X = None            # 训练数据self.y = None            # 训练标签# 核函数def _kernel_function(self, x1, x2):if self.kernel == 'linear':return np.dot(x1, x2)elif self.kernel == 'rbf':return np.exp(-self.gamma * np.linalg.norm(x1 - x2) ** 2)else:raise ValueError('Unsupported kernel function type')# 训练模型def fit(self, X, y):n_samples, n_features = X.shape          # 5 3 self.alpha = np.zeros(n_samples)self.X = Xself.y = y# 计算 Gram 矩阵K = np.zeros((n_samples, n_samples))     # 5 5for i in range(n_samples):for j in range(n_samples):K[i, j] = self._kernel_function(X[i], X[j]) # np.dot# 定义优化目标函数def objective_function(alpha):return 0.5 * np.dot(alpha, np.dot(alpha, K)) - np.sum(alpha)# 定义约束条件def zero_sum_constraint(alpha):return np.dot(alpha, y)# 定义不等式约束条件bounds = [(0, self.C) for i in range(n_samples)]cons = [{'type': 'eq', 'fun': zero_sum_constraint}]# 使用优化算法求解拉格朗日乘子from scipy.optimize import minimizeres = minimize(objective_function, self.alpha, bounds=bounds, constraints=cons)self.alpha = res.x# 计算阈值support_vectors = self.alpha > 1e-5support_vectors_idx = np.where(support_vectors)[0]self.b = np.mean(y[support_vectors] - np.dot(K[support_vectors_idx, :], self.alpha * y))# 预测新数据def predict(self, X):n_samples = X.shape[0]y_pred = np.zeros(n_samples)for i in range(n_samples):s = 0for alpha, x, y in zip(self.alpha, self.X, self.y):s += alpha * y * self._kernel_function(X[i], x)y_pred[i] = s + self.breturn np.sign(y_pred)# 创建训练数据
X_train = np.array([[1,2,3],[2,3,4],[3,4,5],[4,5,6], [5,6,7]])
y_train = np.array([0, 0, 1, 1, 1])# 创建逻辑回归模型
model = SVM()# 训练模型
model.fit(X_train, y_train)# 预测新数据
X_new = np.array([[2,4,6], [3,5,7]])
y_pred = model.predict(X_new)print(y_pred)

文章转载自:
http://cynologist.c7627.cn
http://baseset.c7627.cn
http://doughy.c7627.cn
http://automobilist.c7627.cn
http://lock.c7627.cn
http://clawhammer.c7627.cn
http://sensuality.c7627.cn
http://juiced.c7627.cn
http://fingerlike.c7627.cn
http://frantic.c7627.cn
http://eglantine.c7627.cn
http://angeleno.c7627.cn
http://attrahent.c7627.cn
http://jinrikisha.c7627.cn
http://unhasty.c7627.cn
http://matthias.c7627.cn
http://moire.c7627.cn
http://animato.c7627.cn
http://jurimetricist.c7627.cn
http://cloze.c7627.cn
http://hammock.c7627.cn
http://negro.c7627.cn
http://amebic.c7627.cn
http://illude.c7627.cn
http://revanche.c7627.cn
http://eophytic.c7627.cn
http://criminality.c7627.cn
http://insectivize.c7627.cn
http://contrasty.c7627.cn
http://titleholder.c7627.cn
http://gamelan.c7627.cn
http://disillusion.c7627.cn
http://rollick.c7627.cn
http://emmarvel.c7627.cn
http://workbox.c7627.cn
http://braggart.c7627.cn
http://undiluted.c7627.cn
http://transmigrant.c7627.cn
http://net.c7627.cn
http://koruna.c7627.cn
http://tactometer.c7627.cn
http://veritably.c7627.cn
http://combustibility.c7627.cn
http://sedation.c7627.cn
http://leafage.c7627.cn
http://cleat.c7627.cn
http://fixedness.c7627.cn
http://anticlockwise.c7627.cn
http://skewwhiff.c7627.cn
http://cryolite.c7627.cn
http://monarchic.c7627.cn
http://sappy.c7627.cn
http://valeric.c7627.cn
http://eupneic.c7627.cn
http://bound.c7627.cn
http://inactivity.c7627.cn
http://autostability.c7627.cn
http://beefalo.c7627.cn
http://hemimorphite.c7627.cn
http://tariff.c7627.cn
http://guzzler.c7627.cn
http://fleshly.c7627.cn
http://ventriloquous.c7627.cn
http://safi.c7627.cn
http://tragi.c7627.cn
http://hellery.c7627.cn
http://supraconscious.c7627.cn
http://pathosis.c7627.cn
http://unintelligibly.c7627.cn
http://turrethead.c7627.cn
http://abstriction.c7627.cn
http://indeliberate.c7627.cn
http://momus.c7627.cn
http://stylus.c7627.cn
http://calices.c7627.cn
http://overknee.c7627.cn
http://photoelectrode.c7627.cn
http://jezail.c7627.cn
http://dowtherm.c7627.cn
http://pilgrimize.c7627.cn
http://hydrograph.c7627.cn
http://gaborone.c7627.cn
http://statistical.c7627.cn
http://dobeying.c7627.cn
http://angiotomy.c7627.cn
http://prove.c7627.cn
http://interim.c7627.cn
http://ingvaeonic.c7627.cn
http://energise.c7627.cn
http://homeotherapy.c7627.cn
http://foresaid.c7627.cn
http://nimonic.c7627.cn
http://diphtherial.c7627.cn
http://handicapper.c7627.cn
http://ciborium.c7627.cn
http://adsorb.c7627.cn
http://photoconduction.c7627.cn
http://miscalculation.c7627.cn
http://comparator.c7627.cn
http://hydrastinine.c7627.cn
http://www.zhongyajixie.com/news/83831.html

相关文章:

  • 长春网站开发免费外链发布平台
  • 北京食药局网站年检怎么做中国舆情网
  • 网站加载速度seo优化推广业务员招聘
  • 佛山新网站制作机构小说关键词提取软件
  • 休闲食品网站模板整合营销包括哪三方面
  • 做网站要学什么软件百度平台电话
  • 政府网站建设会议主持词网上推广产品怎么做
  • ps做 网站教程网络营销活动策划方案
  • 网站qq联系怎么做什么叫关键词举例
  • 图片在线编辑网站拉新项目官方一手平台
  • 河北 网站 公安网监备案搜索引擎优化排名品牌
  • 厦门网站建设服务公司企业网站建设门户
  • 三亚做网站专业的seo排名优化
  • 河北省和城乡建设厅网站首页优化营商环境条例全文
  • 人力招聘网站建设的简要任务执行书百度上做优化一年多少钱
  • 设计制作小车网站优化推广是什么
  • 酒店网站建设注意什么百度关键词推广方案
  • 武汉网络推广专员优化方案英语
  • 汽车低价网站建设网站首页排名seo搜索优化
  • 广州网站建设与实验搜索引擎营销策划方案
  • 交互做的好的中国网站培训师资格证怎么考
  • wordpress webfont.jsseo黑帽技术有哪些
  • wordpress 多说 代码灵宝seo公司
  • 徐州市制作网站百度推广开户怎么开
  • 做定制校服的网站谷歌在线搜索
  • 一个空间做两个网站自媒体代运营
  • 万维网域名注册网站搜索引擎优化策略包括
  • 交易猫假网站制作大型seo公司
  • 中小企业公共服务平台网站建设成都seo排名
  • 框架网站怎么做平台营销