嗨,我在Matlab中有一段代码。我的目标是将其转换为Python,如下所示。但是python代码给了我以下错误。您能帮我在这里找出语法错误吗?
Matlab代码:
biopsy_final = na.omit(biopsy[,-c(1)]) # ID & NA excluded
ctrl <- trainControl(method="repeatedcv", number=1, repeats=1)
nn_grid <- expand.grid(k=c(1:12))
nn_grid
best_knn <- train(class~., data=biopsy_,
method="knn",
trControl=ctrl,
preProcess = c("center", "scale"), # standardize
tuneGrid=nn_grid)
print(best_knn)
Python翻译:
for j = 1:length(Filters)
if j == 1
Shifts(1) = int16(-(round(log2(sqrt(size(Filters{j},3))*2/16))));
Shifts(1) = Shifts(1)-int16(4);
elseif j < length(Filters)
Shifts(j) = int16(-(round(log2(sqrt(size(Filters{j},3))*2/16))));
end
有没有更好的方式用Python表示我的代码。