我试图用多个因变量和多个自变量做回归.基本上我House Prices在整个美国的县级,这是我的IV.然后我在县级(GDP,construction employment)有几个其他变量,这些变量构成我的因变量.我想知道是否有一种有效的方法可以同时完成所有这些回归.我想得到:
lm(IV1 ~ DV11 + DV21)
lm(IV2 ~ DV12 + DV22)
Run Code Online (Sandbox Code Playgroud)
我想为每个独立变量和每个因变量做这个.
编辑: OP添加了这些信息以回应我的回答,现在已删除,误解了这个问题.
我不认为我很好地解释了这个问题,我道歉.每个因变量都有2个与之关联的独立变量,这是唯一的.因此,如果我有500个因变量,我有500个唯一的自变量1和500个唯一的自变量2.
好的,我会再试一次,如果我再也不能解释自己,我可能会放弃(哈哈).我不知道你mtcars对R的意思是什么[这是关于Metrics的答案],所以让我这样试试吧.我将有3个数据向量,每个数据大约500行.我正在尝试从每行数据中构建回归.假设向量1是我的因变量(我试图预测的那个),向量2和3组成我的自变量.因此,第一个回归将包含每个向量的第1行值,第2个将包含每个向量的第2行值,依此类推.再次感谢大家.
我有一个与之相似的稀疏矩阵,但是更大。
library(Matrix)
dfmtest<-new("dgCMatrix"
, i = c(0L, 1L, 2L, 4L, 5L, 6L, 8L, 0L, 1L, 2L, 3L, 4L, 6L, 7L, 8L,
0L, 2L, 3L, 6L, 7L, 8L, 1L, 2L, 4L, 5L, 6L, 7L, 8L, 9L, 0L, 1L,
3L, 4L, 5L, 6L, 7L, 8L, 9L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L,
9L, 0L, 1L, 3L, 4L, 6L, 7L, 8L, 9L, 0L, 2L, 3L, 5L, 6L, 7L, 9L,
0L, 1L, 2L, 3L, 4L, 5L, 6L, 8L, 9L, 0L, 1L, …Run Code Online (Sandbox Code Playgroud) 我正在尝试更多地了解计算机视觉模型,并且我正在尝试对它们的工作方式进行一些探索。为了理解如何更多地解释特征向量,我尝试使用 Pytorch 来提取特征向量。下面是我从不同地方拼凑起来的代码。
import torch
import torch.nn as nn
import torchvision.models as models
import torchvision.transforms as transforms
from torch.autograd import Variable
from PIL import Image
img=Image.open("Documents/01235.png")
# Load the pretrained model
model = models.resnet18(pretrained=True)
# Use the model object to select the desired layer
layer = model._modules.get('avgpool')
# Set model to evaluation mode
model.eval()
transforms = torchvision.transforms.Compose([
torchvision.transforms.Resize(256),
torchvision.transforms.CenterCrop(224),
torchvision.transforms.ToTensor(),
torchvision.transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
])
def get_vector(image_name):
# Load the image with Pillow library
img = Image.open("Documents/Documents/Driven Data …Run Code Online (Sandbox Code Playgroud) 我有一个以下形式的 pandas 数据框:
其中“it”、“their”和“charact”是索引。如何根据索引选择一个值?当我尝试以下操作时:
corpus_df.iloc['it',1]
Run Code Online (Sandbox Code Playgroud)
我收到错误:
ValueError: Location based indexing can only have [integer, integer slice (START point is INCLUDED, END point is EXCLUDED), listlike of integers, boolean array] types
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Transformer 包的 BertTokenizer 部分。首先我安装如下。
pip install transformers
Run Code Online (Sandbox Code Playgroud)
这说明它成功了。
当我尝试导入如下所示的包的某些部分时,我得到以下信息。
from transformers import BertTokenizer
Traceback (most recent call last):
File "<ipython-input-2-89505a24ece6>", line 1, in <module>
from transformers import BertTokenizer
File "C:\Users\User\anaconda3\lib\site-packages\transformers\__init__.py", line 22, in <module>
from .integrations import ( # isort:skip
File "C:\Users\User\anaconda3\lib\site-packages\transformers\integrations.py", line 42, in <module>
from .trainer_utils import PREFIX_CHECKPOINT_DIR, BestRun # isort:skip
File "C:\Users\User\anaconda3\lib\site-packages\transformers\trainer_utils.py", line 10, in <module>
from .tokenization_utils_base import ExplicitEnum
File "C:\Users\User\anaconda3\lib\site-packages\transformers\tokenization_utils_base.py", line 31, in <module>
from tokenizers import AddedToken
File "C:\Users\User\anaconda3\lib\site-packages\tokenizers\__init__.py", line 17, in <module> …Run Code Online (Sandbox Code Playgroud)