回归算法似乎正在处理以数字表示的特征.例如:
此数据集不包含分类要素/变量.很清楚如何对这些数据进行回归并预测价格.
但现在我想对包含分类特征的数据进行回归分析:
有5个特点:District,Condition,Material,Security,Type
如何对这些数据进行回归?我是否必须手动将所有这些字符串/分类数据转换为数字?我的意思是,如果我必须创建一些编码规则,并根据该规则将所有数据转换为数值.有没有简单的方法将字符串数据转换为数字而无需手动创建自己的编码规则?可能有一些Python中的库可用于此吗?由于"编码错误",回归模型是否存在某些风险?
python regression machine-learning linear-regression feature-selection
在我的Azure帐户上,我有几个Web应用程序.
我正在尝试使用Publish从Visual Studio 2015部署我的ASP.NET MVC项目.但它在我的Azure帐户上找不到任何现有的Web应用程序.我在Visual Studio中登录.凭证是正确的.但VS中的现有Web应用程序列表为空:
我选择Microsoft Azure Web Apps:
然后加载一段时间,最后现有Web应用程序列表为空.

我认为这是我的具体项目不起作用.然后我创建了新的ASP MVC Web应用程序(模板).列表仍然是空的.
我的IDE:MS Visual Studio Professional 2015-U3
VS无法在我的Azure云帐户上找到现有Web应用程序的原因是什么?我试图重新输入我的凭据,注销并登录.没有.
asp.net-mvc azure azure-web-sites visual-studio-2015 azure-web-app-service
我正在使用多个变量/特征进行线性回归.我尝试通过让θ驱动(系数)的正规方程法(使用矩阵求逆),numpy的最小二乘numpy.linalg.lstsq工具和np.linalg.solve工具.在我的数据中,我有n = 143个特征,m = 13000个训练样例.
对于正则化的正规方程方法,我使用这个公式:
正则化用于解决矩阵不可逆性的潜在问题(XtX矩阵可能变为奇异/不可逆)
数据准备代码:
import pandas as pd
import numpy as np
path = 'DB2.csv'
data = pd.read_csv(path, header=None, delimiter=";")
data.insert(0, 'Ones', 1)
cols = data.shape[1]
X = data.iloc[:,0:cols-1]
y = data.iloc[:,cols-1:cols]
IdentitySize = X.shape[1]
IdentityMatrix= np.zeros((IdentitySize, IdentitySize))
np.fill_diagonal(IdentityMatrix, 1)
Run Code Online (Sandbox Code Playgroud)
对于最小二乘法,我使用Numpy的numpy.linalg.lstsq.这是Python代码:
lamb = 1
th = np.linalg.lstsq(X.T.dot(X) + lamb …Run Code Online (Sandbox Code Playgroud) python numpy machine-learning linear-algebra linear-regression
什么是最有效("pythonic")方法来测试/检查Python中两个数字是否是共同素数(相对素数).
目前我有这个代码:
def gcd(a, b):
while b != 0:
a, b = b, a % b
return a
def coprime(a, b):
return gcd(a, b) == 1
print(coprime(14,15)) #Should be true
print(coprime(14,28)) #Should be false
Run Code Online (Sandbox Code Playgroud)
用于检查/测试两个数字是否相对素数的代码可以被认为是"Pythonic"还是有更好的方法?
我正在尝试为屏幕截图中显示的示例数据创建折线图.我google了很多,看了下面的一些链接,并尝试使用matplotlib,但我无法得到所需的输出,如下面的linegraph(截图)所示,任何人都可以提供一个示例参考入门?如何获得下面显示的样本输入的折线图?
http://www.josechristian.com/programming/smooth-line-plots-python/ http://yaboolog.blogspot.com/2011/07/python-tips-create-line-graph-with.html
码:
import matplotlib.pyplot as plt
import numpy as np
# just create some random data
fnx = lambda : np.random.randint(3, 10, 10)
y = np.row_stack((fnx(), fnx(), fnx()))
# this call to 'cumsum' (cumulative sum), passing in your y data,
# is necessary to avoid having to manually order the datasets
x = np.arange(10)
y_stack = np.cumsum(y, axis=0) # a 3x10 array
fig = plt.figure()
plt.savefig('smooth_plot.png')
Run Code Online (Sandbox Code Playgroud) 我按照以下说明安装了由Datastax分发的用于Windows x64的Cassandra: 安装适用于Windows的Apache Cassandra 3.x的DataStax发行版
但是,即使安装成功完成,该服务也无法启动以下错误.我使用的是Windows 7 x64,我使用提升的命令提示符启动安装.
ERROR [main] 2016-10-11 13:40:22,710 CassandraDaemon.java:747 - 启动时遇到异常:缺少cdc_raw_directory且未设置-Dcassandra.storagedir
有什么建议?我不知道我应该设置cdc_raw_directory或Dcassandra.storagedir到.
我从这里安装了免费的Python发行版Anaconda:https
:
//www.continuum.io/downloads
我的操作系统:Windows 10 64位.我用Python 2.7下载了Anaconda for Windows 64位.
当我在IPython控制台窗口中启动Spyder IDE时,我看到标题有一些错误:
启动内核时出错
在上面显示的错误日志的末尾,我看到以下几行:
[IPKernelApp] CRITICAL | Bad config encountered during initialization:
[IPKernelApp] CRITICAL | Could not decode 'C:\\Users\\\xc0\xe4\xec\xe8\xed\xe8\xf1\xf2\xf0\xe0\xf2\xee\xf0\\AppData\\Roaming\\jupyter\\runtime' for unicode trait 'connection_dir' of an IPKernelApp instance.
Run Code Online (Sandbox Code Playgroud)
这是我安装此发行版的第二次.在第一次我在Windows 8上安装了Anaconda,它运行良好没有任何问题.我刚安装它,可以立即使用它.目前,我正在尝试在Windows 10上使用它并发生此类错误.怎么解决?
我放置了一个jQuery颜色框,它会调出一个文本输入字段,但由于某种原因,我无法输入我的手机上的输入字段.但它适用于我的桌面.当我将光标放在某个字段上时,它不会放在输入字段上.它开始一些加载.然后让我回到默认位置(颜色框仍然打开,我不能将光标放在文本字段上.我可以将光标和文本放入字段的唯一方法是在文本字段上保留一些时间.然后出现"粘贴"选项所以我可以在文本字段中粘贴文本,但我无法输入.
HTML(显示在彩盒中的表单):
<div class="compare" style="margin-top: 20px;"><a id="fast_order" href="#fast_order_form" class="button" />?????? ? 1 ????</a></div>
<div style="display:none">
<div id="fast_order_form">
<input id="product_name" type="hidden" value="<?php echo $heading_title; ?>">
<input id="product_price" type="hidden" value="<?php echo ($special ? $special : $price); ?>">
<div class="fast_order_center"><?php echo $heading_title; ?> — ??? ?????</div>
<div class="fast_order_left">
<p>???:</p>
<p>???????:</p>
<p>???????????:</p>
</div>
<div class="fast_order_right">
<p><input type="text" id="customer_name"/></p>
<p><input type="text" id="customer_phone"/></p>
<p><input type="text" id="customer_message"/></p>
</div>
<div class="fast_order_center">
<p id="fast_order_result">??????????, ??????? ???? ??? ? ???????</p>
<button class="fast_order_button"><span>???????????</span></button>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS(此颜色框表单的CSS):
#fast_order_form .fast_order_left { …Run Code Online (Sandbox Code Playgroud) 我必须重现http://scholar.harvard.edu/files/mankiw/files/permanent_income.pdf使用的代码.我理解线性回归和工具变量的概念,在编写脚本时我无法找到错误.
该代码首先分析一组数据并识别数据中的内生性,因此实现了工具变量方法.
现在我正在尝试重现表2 [p.272]但是无法通过简单的OLS.然而,我卡住了复制OLS.
我会一步一步解释我的程序,希望你们能找到我的错误.
1.-首先给出表1,在第268页(第3.1节)中,作者声明他将使用特定样本.因此,我将我的数据集限制为该样本.我刚刚在开头留下了一个额外的步骤.
#Load data and modification
EF <- read.delim("Z:/EF.txt", dec=",")
View(EF)
EF<-EF[-c(1:23), ]
View(EF)
Run Code Online (Sandbox Code Playgroud)
2.-在第267页的最后一段中,他指出,对于表2,他将Y和C除以Y的滞后值.
#Dividing by one lag of Y
Table2Y<-mat.or.vec(dim(EF)[1]-1,1)
Table2C<-mat.or.vec(dim(EF)[1]-1,1)
for (i in 2:dim(EF)[1] ) {
Table2Y[i-1] = EF$Income[i]/EF$Income[i-1]
Table2C[i-1] = EF$Consumption[i]/EF$Income[i-1]
}
Run Code Online (Sandbox Code Playgroud)
3.-在第2节第2段的第266页中,他将Delta变量定义为第一个差异.
#Making First Differences
Table2Y<- diff(Table2Y,1) #This is called dY in the text
Table2C<- diff(Table2C,1) #This is called dC in the text
Run Code Online (Sandbox Code Playgroud)
3.-然后,在第272页的表2的注释中,清楚地表明回归是dC = a + b*dY
lm(Table2C~Table2Y)
summary(lm(Table2C~Table2Y))
Run Code Online (Sandbox Code Playgroud)
我对b的结果是.493,标准差为0.0325.正确的结果应分别为.296和.044.
任何人都可以提供我的问题的任何见解?
我使用 Laravel 5.1,我想在这个请求类中返回翻译的验证错误。请帮助如何返回翻译的数据。
class ContactRequest extends Request
{
public function authorize()
{
return true;
}
public function rules()
{
return [
'name' => 'required',
'g-recaptcha-response' => 'required|captcha',
'email' => 'required|email',
'message' => 'required',
'phone' => 'required'
];
}
}
Run Code Online (Sandbox Code Playgroud) python ×5
algorithm ×1
anaconda ×1
asp.net-mvc ×1
azure ×1
cassandra ×1
css ×1
html ×1
input ×1
javascript ×1
jquery ×1
kernel ×1
laravel ×1
laravel-5.1 ×1
linechart ×1
matplotlib ×1
numpy ×1
primes ×1
python-2.7 ×1
python-3.x ×1
r ×1
regression ×1
spyder ×1
translation ×1