IndexError:元组索引使用部分关联函数

时间:2018-04-28 16:10:18

标签: arrays python-3.x numpy scipy tuples

我正在使用由Fabian Pedregosa-Izquierdo开发的部分相关函数(MatLab的parrcor副本)。

但是,我正在尝试将其应用于我的数据,我一直收到以下错误:

 Traceback (most recent call last):
File "atd.py", line 280, in <module>
partialcorr = partial_corr(values_outliers)
File "/Users/dingo/Desktop/ATD/MiniProjATD/partial_corr.py", line 50, in partial_corr
p = C.shape[1]
IndexError: tuple index out of range

我的values_outliers是一个np.array,如下所示:https://pastebin.com/AHhwmpTg

可以在此处找到部分相关代码的实现:https://gist.github.com/fabianp/9396204419c7b638d38f

非常感谢!

1 个答案:

答案 0 :(得分:0)

您发布的函数希望接收<!--\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ Registration \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ ---> <div class="container-fluid even" id="membership_form" data-aos="fade-up" data-aos-once="true"> <div class="container"> <?php $errors = array(); foreach($_POST as $key => $value){ $_POST[$key] = trim($value); $_POST[$key] = stripslashes($value); $_POST[$key] = strip_tags($value); } if(empty($_POST['name'])) $errors[] = 'Name is required'; else{ $_POST['name'] = upper_case_by_space_n_hyphen($_POST['name']); } if(empty($_POST['surname'])) $errors[] = 'Surname is required'; else{ $_POST['surname'] = upper_case_by_space_n_hyphen($_POST['surname']); } if(empty($_POST['email'])) $errors[] = 'Email is required.'; else{ if(!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)){ $errors[] = 'Email address is not valid.'; } } if(empty($_POST['address1']) || empty($_POST['address2']) || empty($_POST['address3'])) $errors[] = 'Address line 1-3 is required.'; else{ $address = upper_case_by_space_n_hyphen($_POST['address1']) . ',\n' . upper_case_by_space_n_hyphen($_POST['address2']) . ',\n' .upper_case_by_space_n_hyphen($_POST['address3']); if(isset($_POST['address4'])) $address .= ',\n' . upper_case_by_space_n_hyphen($_POST['address4']); } /*if(empty($_POST['eircode'])) $errors[] = 'Eircode is required.'; else{ $_POST['eircode'] = toUpperCase($_POST['eircode']); } if(empty($_POST['mobile'])) $errors[] = 'Mobile is required.'; else{ //if(!preg_match('\+\d{3}-\d{3}-\d{4}|00\d{3}-\d{3}-\d{4}|08\d-\d{3}-\d{4}|\+\d{10}|00\d{10}|08\d{8}', $_POST['mobile'])) $errors[] = 'Mobile format is invalid.'; }*/ echo '<pre>'; print_r($_POST); echo '</br>' . $address . '</br>'; //print_r($errors); echo '</pre>'; ?> </div> </div> 矩阵作为参数。您传递的是一个长度为n x m的数组。要使数据形状正确,您可以执行以下操作:

n

重塑的my_data = [1.234, 5.6789, -32.101] C = np.array(my_data).reshape((-1,1)) partial_corr(C) 参数表示将所有数据放在(-1,1)数组的第一列中。