当前位置:首页 > 经验 >

以e为底的指数函数(指数函数六种图像)

来源:原点资讯(www.yd166.com)时间:2022-11-02 07:54:38作者:YD166手机阅读>>

五、非线性回归模型

"""非线性回归""" import numpy as np import pandas as pd import matplotlib.pyplot as plt from linear_regression import LinearRegression data = pd.read_csv('../data/non-linear-regression-x-y.csv') x = data['x'].values.reshape((data.shape[0], 1)) y = data['y'].values.reshape((data.shape[0], 1)) data.head(10) # visualize the training and test datasets to see the shape of the data plt.plot(x, y) plt.show() # Set up linear regression parameters. num_iterations = 50000 learning_rate = 0.02 polynomial_degree = 15 # The degree of additional polynomial features. sinusoid_degree = 15 # The degree of sinusoid parameter multipliers of additional features. normalize_date = True # Init linear regression instance. # linear_regression = LinearRegression(x, y, normalize_date) # 线性回归 linear_regression = LinearRegression(x, y, polynomial_degree, sinusoid_degree, normalize_date) # Train linear regression (theta, cost_history) = linear_regression.train( learning_rate, num_iterations ) print('开始损失: {:.2f}'.format(cost_history[0])) print('结束损失: {:.2f}'.format(cost_history[-1])) theta_table = pd.DataFrame({'Model Parameters': theta.flatten()}) # Plot gradient descent progress. plt.plot(range(num_iterations), cost_history) plt.xlabel('Iterations') plt.ylabel('Cost') plt.title('Gradient Descent Progress') plt.show() # Get model predictions for the trainint set. predictions_num = 1000 x_predictions = np.linspace(x.min(), x.max(), predictions_num).reshape(predictions_num,1) y_predictions = linear_regression.predict(x_predictions) # Plot training data with predictions. plt.scatter(x, y, label='Training Dataset') plt.plot(x_predictions, y_predictions, 'r', label='Prediction') plt.show()

执行效果:

开始损失: 580629.11

结束损失: 8777.68

以e为底的指数函数,指数函数六种图像(37)

非线性回归方程:

以e为底的指数函数,指数函数六种图像(38)

,

栏目热文

指数函数性质(指数函数的特点)

指数函数性质(指数函数的特点)

明确指数函数的定义:只指数函数的定义指数函数的定义要注意如下几个方面:1.底数a的取值范围是大于0且≠1的。2.指数函数...

2022-11-02 08:12:55查看全文 >>

幂函数图像及性质总结(幂函数九个基本图像)

幂函数图像及性质总结(幂函数九个基本图像)

按α=0,α=1,0<α<1,α<0五种类型分类,列表如下:,...

2022-11-02 07:52:26查看全文 >>

指数函数的一般形式(指数函数的变式)

指数函数的一般形式(指数函数的变式)

一、根式典型例题1:1、分数指数幂与根式的关系:分数指数幂与根式可以相互转化,通常利用分数指数幂的意义把根式的运算转化为...

2022-11-02 08:35:15查看全文 >>

指数函数的三种形式(指数函数的三种表示方法)

指数函数的三种形式(指数函数的三种表示方法)

数学很难,它们需要抽象的思维和利用某些逻辑基本规则运算数学符号的能力。这就是为什么在整个数学史上,我们想出了许多方法来简...

2022-11-02 08:14:19查看全文 >>

指数函数引入的经典例子(指数函数有趣的例子)

指数函数引入的经典例子(指数函数有趣的例子)

指数函数标志着高一正式进入初等函数的学习,是第一章函数性质的举例应用,相比之下比较不会抽象,但容易混乱。如果第一章没学...

2022-11-02 08:19:00查看全文 >>

指数函数的底数为啥不能为负(指数函数的底数不能等于零吗)

指数函数的底数为啥不能为负(指数函数的底数不能等于零吗)

今天为同学们分享的是高中数学必修一关于“指数函数”的常考、必考、易错知识点,手抄笔记不容易,希望同学们珍惜现在的学习机会...

2022-11-02 08:25:50查看全文 >>

指数函数比较大小诀窍(指数函数比较大小的方法口诀)

指数函数比较大小诀窍(指数函数比较大小的方法口诀)

【解题研究】指数与对数比较大小的方法典型例题,大家有问题可以评论区留言提问,谢谢,...

2022-11-02 08:33:55查看全文 >>

文档排行