将数组数组转换为单个一维向量

时间:2015-08-28 18:55:28

标签: python image-processing multidimensional-array machine-learning

我正在为我的图像处理项目培训SVM分类器。我已经计算了正负样本的特征,并且我给了SVM机器。以下是它的代码 -

from skimage.feature import local_binary_pattern
from sklearn.svm import LinearSVC
from sklearn.linear_model import LogisticRegression
from sklearn.externals import joblib
import argparse as ap
import glob
import os
import numpy as np
from config import *
from sklearn.datasets import load_svmlight_file
if __name__ == "__main__":
    # Parse the command line arguments
    parser = ap.ArgumentParser()
    parser.add_argument('-p', "--posfeat", help="Path to the positive features directory", required=True)
    parser.add_argument('-n', "--negfeat", help="Path to the negative features directory", required=True)
    parser.add_argument('-c', "--classifier", help="Classifier to be used", default="LIN_SVM")
    args = vars(parser.parse_args())

    pos_feat_path =  args["posfeat"]
    neg_feat_path = args["negfeat"]

    # Classifiers supported
    clf_type = args['classifier']

    fds = []
    labels = []    

    # Load the positive features
    for feat_path in glob.glob(os.path.join(pos_feat_path,"*.feat")):
        fd = joblib.load(feat_path)
        fds.append(fd)
        labels.append(1)

    # Load the negative features
    for feat_path in glob.glob(os.path.join(neg_feat_path,"*.feat")):
        fd = joblib.load(feat_path)
        fds.append(fd)
        labels.append(0)

    if clf_type is "LIN_SVM":
        clf = LinearSVC()
        print "Training a Linear SVM Classifier"
        print fds
        clf.fit(fds, labels)
        # If feature directories don't exist, create them
        if not os.path.isdir(os.path.split(model_path)[0]):
            os.makedirs(os.path.split(model_path)[0])
        joblib.dump(clf, model_path)
        print "Classifier saved to {}".format(model_path)

实际上问题出在 clf.fit()上。它接受feature参数作为列方向向量,但在我的情况下 fds 是数组数组。当我打印 fds 的内容时,我得到以下输出 -

[array([ 0.00277933,  0.00070328,  0.00168657, ...,  0.00408768,
        0.00297903,  0.00028435]), array([  6.52768819e-02,   2.63171446e-02,   2.08603860e-02, ...,
         1.83740761e-03,   2.47804233e-03,   4.40952106e-18]), array([ 0.,  0.,  0., ...,  0.,  0.,  0.]), array([ 0.00620965,  0.01182592,  0.00999352, ...,  0.00089589,
        0.00134092,  0.0026002 ]), array([ 0.,  0.,  0., ...,  0.,  0.,  0.]), array([  3.64590106e-02,   5.63983750e-02,   6.84983685e-02, ...,
         1.39839195e-03,  -4.10784429e-20,  -2.38254969e-18]), array([ 0.01085514,  0.01018574,  0.02266318, ...,  0.00684619,
        0.00036176,  0.00130271]), array([  2.16485104e-03,   1.50226723e-03,   3.21942375e-03,
         2.64656094e-03,   2.37626208e-03,   1.34057657e-04,
         2.39091821e-04,   8.97521723e-04,   1.38454609e-04,
         1.24197312e-03,   1.60666499e-03,   1.92435265e-03,
         3.34864054e-03,   4.85894399e-03,   3.66780053e-03,
         1.40191912e-03,   2.38874303e-05,   1.26082007e-03,
         6.97647267e-04,   3.96445045e-20,   9.20237544e-04,
         9.11937075e-04,   2.84391853e-03,   2.27833476e-03,
         8.45884552e-04,   7.49838529e-04,   9.92053442e-04,
         3.71845597e-03,   8.97953013e-04,   4.03147212e-03,
         3.63879390e-03,   3.47202846e-03,   2.49844107e-03,
         3.58805258e-03,   1.81755692e-03,   6.15611050e-04,
         3.87421125e-02,   5.28292081e-02,   4.50205552e-02,
         1.87053052e-02,   2.38757517e-03,   5.76913479e-04,
         1.08746617e-02,   4.45025259e-03,   1.65023747e-02,
         4.88377889e-03,   1.37183167e-02,   3.05583432e-02,
         1.45078200e-02,   1.54068986e-02,   1.25567916e-02,
         3.15812077e-03,   2.03465022e-03,   1.30152773e-02,
         1.17611551e-02,   8.41835019e-03,   7.26126040e-03,
         7.09438642e-03,   4.13387457e-04,   3.67045146e-03,
         3.24655772e-03,   3.62208618e-03,   7.05961786e-03,
         5.32413350e-02,   2.94643428e-02,   5.24565899e-03,
         9.08009594e-04,   1.17463672e-03,   1.40689894e-03,
         2.44819931e-03,   3.55238586e-03,   2.68153796e-03,
         1.02494651e-03,   1.74641589e-05,   9.21788648e-04,
         5.10051628e-04,   2.89841944e-20,   6.72787925e-04,
         6.66719432e-04,   2.07919581e-03,   1.66569613e-03,
         6.18428270e-04,   5.48208787e-04,   7.25292704e-04,
         1.52719734e-03,   2.52585599e-04,   5.04195253e-04,
         5.49185184e-04,   1.97899522e-03,   8.02619830e-04,
         1.19393286e-03,   2.24160583e-03,   2.96601637e-03,
         2.83244534e-02,   3.86235636e-02,   3.29146383e-02,
         1.36754945e-02,   1.74556206e-03,   4.21782859e-04,
         7.95049185e-03,   3.25359058e-03,   1.20649266e-02,
         3.57054272e-03,   1.00294950e-02,   2.23412797e-02,
         1.06067027e-02,   1.12640214e-02,   9.18030115e-03,
         2.30890984e-03,   1.48753777e-03,   9.51550118e-03,
         3.26482882e-03,   4.71849778e-03,   2.04148875e-02,
         5.97050449e-02,   3.04274415e-02,   2.23696435e-02,
        -5.65191791e-19,   7.45718312e-04,   2.20736964e-03,
         3.89248705e-02,   2.15414533e-02,   3.83511415e-03,
         3.91414576e-03,   2.39010537e-02,   1.45339174e-02,
         1.18966993e-02,   1.47790204e-02,   4.08729725e-02,
         5.43413826e-04,   7.07381440e-03,   2.30874856e-02,
         1.15286340e-01,   7.00020973e-02,   1.66219341e-02,
         9.65820714e-04,   9.15703260e-03,   7.32836318e-03,
         4.97580251e-03,   8.64347941e-03,   6.12213806e-02,
         8.66396141e-02,   1.16438218e-02,   3.46289205e-03,
         9.99954707e-19,   1.87641186e-03,   4.77370866e-04,
         5.48322443e-04,   3.11589718e-20,   7.23269368e-04,
         7.16745536e-04,   2.23520456e-03,   1.79067867e-03,
         6.64830933e-04,   5.89342657e-04,   7.79713750e-04,
         1.64178787e-03,   2.71537910e-04,   5.42026646e-04,
         5.90392316e-04,   2.12748560e-03,   8.62842979e-04,
         1.28351748e-03,   2.40980073e-03,   3.18856612e-03,
         4.44089967e-04,   2.88681852e-04,   3.20667485e-04,
         1.63589710e-03,   2.11776424e-03,   1.73073346e-03,
         1.89914765e-03,   1.93551321e-03,   2.74125624e-04,
         3.83845203e-03,   1.07820403e-02,   2.40176178e-02,
         1.14025578e-02,   1.21091971e-02,   9.86912869e-03,
         2.48215477e-03,   1.59915251e-03,   1.02294799e-02,
         3.50979944e-03,   5.07254185e-03,   2.19466823e-02,
         6.41849066e-02,   3.27105104e-02,   2.40481099e-02,
        -6.07599950e-19,   8.01671957e-04,   2.37299569e-03,
         2.52452640e-03,   1.79646442e-03,   3.03974636e-02,
         1.35202488e-01,   2.95568822e-02,   8.82444253e-03,
         2.61691132e-03,   1.93112678e-03,   1.00102477e-03,
         5.84187914e-04,   7.60458546e-03,   2.48198140e-02,
         1.23936645e-01,   7.52545799e-02,   1.78691314e-02,
         1.03828935e-03,   9.84411423e-03,   7.87823386e-03,
         5.34915299e-03,   9.29202749e-03,   6.58150179e-02,
         9.31404632e-02,   1.25174952e-02,   3.72272399e-03,
         1.07498453e-18,   2.01720508e-03,   5.13189539e-04,
         2.74115205e-03,   2.42065051e-03,   1.83539029e-02,
         1.58962250e-02,   3.77837253e-03,   3.56301635e-03,
         2.99458196e-03,   1.90410601e-04,   2.39738687e-03,
         2.12355483e-03,   3.51218114e-04,   7.01079183e-04,
         7.63637297e-04,   2.75177592e-03,   1.11603600e-03,
         1.66015342e-03,   3.11693371e-03,   4.12422037e-03,
         5.74403923e-04,   3.73392782e-04,   4.14764293e-04,
         2.11593546e-03,   2.73920191e-03,   2.23860064e-03,
         2.45643437e-03,   2.50347106e-03,   3.54565167e-04,
         5.12390092e-04,   4.03022742e-20,   1.13218940e-03,
         1.39102995e-03,   2.38894617e-03,   1.89726190e-03,
         1.63466741e-03,   1.39621447e-03,   1.07267287e-03,
         4.53971653e-03,   6.56103077e-03,   2.83867264e-02,
         8.30193538e-02,   4.23090969e-02,   3.11047978e-02,
        -7.85894347e-19,   1.03691493e-03,   3.06932858e-03,
         3.26532454e-03,   2.32361973e-03,   3.93173087e-02,
         1.74876366e-01,   3.82300668e-02,   1.14138908e-02,
         3.38481893e-03,   2.49779747e-03,   1.29476592e-03,
         3.30566432e-03,   5.81677128e-03,   2.99128816e-02,
         5.72199005e-02,   2.42549955e-02,   3.24375413e-03,
         3.12173241e-03,   5.57935157e-03,   3.99256425e-04,
         6.91881080e-03,   1.20186841e-02,   8.51278057e-02,
         1.20471642e-01,   1.61906345e-02,   4.81512175e-03,
         1.39042846e-18,   2.60913463e-03,   6.63780103e-04,
         3.54551691e-03,   3.13096726e-03,   2.37396802e-02,
         2.05608203e-02,   4.88709984e-03,   4.60854944e-03,
         3.87331341e-03,   2.46284771e-04,   3.10087712e-03,
         2.61093759e-03,   3.94157260e-03,   3.15819144e-03,
         7.17143946e-03,   5.68248623e-03,   5.19881250e-03,
         1.46679037e-03,   1.75533877e-03,   1.07150775e-03]), array([  0.00000000e+00,   0.00000000e+00,   0.00000000e+00, ...,
         1.71427415e-17,   1.49141851e-15,   1.13142094e-15]), array([ 0.07582537,  0.01128947,  0.00499143, ...,  0.00259608,
        0.00437164,  0.00810198]), array([  1.24500730e-02,   2.06806908e-02,   1.13564239e-02, ...,
         1.38635639e-04,   3.59214729e-18,   6.05617914e-04]), array([  0.00000000e+00,   0.00000000e+00,   0.00000000e+00, ...,
         8.57137077e-18,  -2.35712696e-16,   2.82855236e-16]), array([  1.00419293e-02,   2.98379938e-02,   1.36988288e-02,
         1.53794787e-02,   3.69879149e-03,   1.05807322e-02,
         9.57733941e-03,   5.54598873e-03,   7.97046383e-03,
         7.60044150e-03,   5.62515915e-03,   7.95557523e-03,
         7.46200086e-03,   3.65604344e-03,   5.42450288e-03,
         2.20858881e-03,   3.38844348e-03,   5.92794738e-03,
         2.61374512e-03,   1.28500588e-03,   4.61032541e-03,
         1.02903157e-02,   3.16831046e-02,   1.04887391e-02,
         1.02502394e-03,   8.48660153e-04,   1.53897449e-03,
         8.85590869e-03,   5.28265061e-03,   6.79200375e-03,
         7.82124826e-03,   2.89332908e-03,   9.74789426e-03,
         3.87239291e-03,   2.31933686e-03,   1.83105418e-03,
         4.22846169e-02,   3.80646963e-02,   8.77437911e-03,
         9.38874018e-03,   1.80134080e-02,   1.89301145e-02,
         1.53909115e-02,   1.15075978e-03,   3.77233330e-02,
         3.63161322e-03,   5.42777212e-03,   1.98190016e-02,
         4.88949082e-02,   6.15634774e-02,   1.29291860e-02,
         3.65290683e-03,   0.00000000e+00,   1.82853950e-03,
         5.45654371e-03,   3.45406414e-03,   9.81383152e-04,
         9.81986326e-03,   1.00335739e-02,   1.13913061e-03,
         1.64660400e-03,   2.29052869e-03,   3.48408737e-03,
         1.05300589e-02,   8.56577546e-03,   2.05927210e-02,
         5.07037386e-02,   3.60376382e-02,   2.34924539e-02,
         1.16494367e-02,   6.43764584e-03,   1.50920581e-03,
         9.63808739e-03,   1.29422709e-02,   4.16020996e-02,
         4.95608744e-02,   3.41212016e-02,   1.36411126e-02,
         9.04121414e-03,   2.16982690e-03,   2.57533376e-03,
         6.74441900e-03,   4.99160875e-03,   7.05955473e-03,
         6.62157066e-03,   3.24427059e-03,   4.81355199e-03,
         1.95983988e-03,   3.00680988e-03,   5.26029454e-03,
         2.31936424e-03,   1.14027824e-03,   4.09107370e-03,
         9.13133807e-03,   2.81147000e-02,   9.30741340e-03,
         9.09577549e-04,   7.53077261e-04,   1.36564288e-03,
         1.58766010e-03,   3.37538242e-03,   9.05139802e-03,
         1.30465072e-02,   1.22976442e-02,   5.72141172e-03,
         2.61824066e-03,   2.77473727e-03,   3.12641022e-03,
         3.75221853e-02,   3.37775458e-02,   7.78613837e-03,
         8.33130518e-03,   1.59845939e-02,   1.67980537e-02,
         1.36574640e-02,   1.02115201e-03,   3.34746296e-02,
         3.22259190e-03,   4.81645302e-03,   1.75868272e-02,
         4.33879726e-02,   5.46297063e-02,   1.14729977e-02,
         3.24148726e-03,   0.00000000e+00,   1.62259476e-03,
         4.40925666e-03,   1.03080289e-02,   4.02471014e-02,
         7.95836008e-02,   3.21026971e-02,   5.08106355e-03,
         3.02090546e-03,   1.83154407e-03,   1.53160727e-18,
         9.34407943e-03,   7.60102933e-03,   1.82734041e-02,
         4.49930781e-02,   3.19787913e-02,   2.08465459e-02,
         1.03373840e-02,   5.71258669e-03,   1.33922699e-03,
         8.55256892e-03,   1.14846089e-02,   3.69165384e-02,
         4.39789324e-02,   3.02781990e-02,   1.21047414e-02,
         8.02292031e-03,   1.92544364e-03,   2.28527908e-03,
         1.76035133e-03,   4.85343099e-03,   1.12399077e-02,
         1.25868642e-02,   9.38685749e-03,   4.18635105e-03,
         4.85282866e-03,   3.55451240e-03,   2.22414751e-03,
         2.40131158e-03,   1.18056633e-03,   4.23561873e-03,
         9.45396476e-03,   2.91080432e-02,   9.63626115e-03,
         9.41714569e-04,   7.79684842e-04,   1.41389351e-03,
         1.64375501e-03,   3.49464079e-03,   9.37120028e-03,
         1.35074639e-02,   1.27321422e-02,   5.92355954e-03,
         2.71074784e-03,   2.87277376e-03,   3.23687194e-03,
         1.40457298e-03,   8.99593551e-04,   7.62588282e-03,
         1.34684775e-02,   2.54216120e-02,   1.86096110e-03,
         7.03846332e-04,   1.61466047e-03,   3.69902136e-04,
         3.33645190e-03,   4.98662701e-03,   1.82082016e-02,
         4.49209482e-02,   5.65598726e-02,   1.18783594e-02,
         3.35601486e-03,   0.00000000e+00,   1.67992396e-03,
         4.56504367e-03,   1.06722302e-02,   4.16691043e-02,
         8.23954334e-02,   3.32369435e-02,   5.26058671e-03,
         3.12763952e-03,   1.89625584e-03,   1.58572172e-18,
         3.91101883e-04,   1.09678620e-02,   3.11576218e-02,
         8.56000033e-02,   3.28877306e-02,   1.79750340e-02,
         8.84814967e-04,   2.52962957e-04,   1.15424434e-03,
         8.85474665e-03,   1.18903809e-02,   3.82208665e-02,
         4.55327876e-02,   3.13479825e-02,   1.25324239e-02,
         8.30638460e-03,   1.99347305e-03,   2.36602212e-03,
         1.82254772e-03,   5.02491148e-03,   1.16370339e-02,
         1.30315809e-02,   9.71851214e-03,   4.33426240e-03,
         5.02428788e-03,   3.68009975e-03,   2.30273066e-03,
         1.94769160e-03,   2.32858271e-03,   9.17937665e-03,
         2.98328989e-02,   3.58401781e-02,   1.56781620e-02,
         7.16552727e-03,   1.09781728e-03,   2.24428520e-03,
         1.89775397e-03,   4.03464531e-03,   1.08192720e-02,
         1.55946860e-02,   1.46995589e-02,   6.83888937e-03,
         3.12962239e-03,   3.31668514e-03,   3.73704510e-03,
         1.62161267e-03,   1.03860200e-03,   8.80426179e-03,
         1.55496754e-02,   2.93498514e-02,   2.14852354e-03,
         8.12607211e-04,   1.86416364e-03,   4.27060751e-04,
         4.84657013e-03,   1.50413908e-03,   7.25643510e-03,
         2.85078745e-02,   1.60210819e-02,   4.59817556e-03,
         2.63947815e-03,   4.60802212e-04,   1.03463157e-03,
         5.27045072e-03,   1.23213418e-02,   4.81079649e-02,
         9.51274736e-02,   3.83728361e-02,   6.07347159e-03,
         3.61093368e-03,   2.18927214e-03,   1.83075317e-18,
         4.51536360e-04,   1.26626556e-02,   3.59722102e-02,
         9.88272252e-02,   3.79696616e-02,   2.07526012e-02,
         1.02153977e-03,   2.92051708e-04,   1.33260234e-03,
         1.92050535e-03,   2.23247174e-02,   2.67249460e-02,
         2.39157657e-02,   1.80724196e-02,   7.79629904e-03,
         6.16250677e-03,   4.65559139e-03,   3.28074477e-03,
         2.10417438e-03,   5.80137896e-03,   1.34352305e-02,
         1.50452679e-02,   1.12202518e-02,   5.00400829e-03,
         5.80065900e-03,   4.24876206e-03,   2.65855693e-03,
         2.24865595e-03,   2.68840373e-03,   1.05978071e-02,
         3.44427862e-02,   4.13783319e-02,   1.81008083e-02,
         8.27277045e-03,   1.26745598e-03,   2.59108026e-03,
         7.38388826e-04,   1.13856145e-03,   9.09884318e-03,
         3.68504788e-02,   3.19515204e-02,   2.63534476e-03,
         1.89872227e-03,   6.80209027e-04,   2.98910598e-04]), array([ 0.,  0.,  0., ...,  0.,  0.,  0.]), array([ 0.00337501,  0.0038908 ,  0.03574201, ...,  0.00092693,
        0.01126366,  0.06343084]), array([  3.15868843e-02,   5.86536284e-03,   3.36624839e-02, ...,
         4.57612692e-03,   4.57756636e-17,  -1.06428418e-16]), array([ 0.00385122,  0.00432967,  0.00775764, ...,  0.00086161,
        0.00021709,  0.00049941]), array([ 0.011524  ,  0.02796046,  0.05111488, ...,  0.00238021,
        0.00383298,  0.00954071]), array([ 0.02315484,  0.05619522,  0.0831222 , ...,  0.00152502,
        0.00196837,  0.00498268]), array([  0.00000000e+00,   0.00000000e+00,   0.00000000e+00, ...,
         6.01456498e-18,   0.00000000e+00,   0.00000000e+00]), array([ 0.,  0.,  0., ...,  0.,  0.,  0.]), array([  2.47301895e-02,   0.00000000e+00,   0.00000000e+00, ...,
         2.10207273e-17,   1.68165818e-17,   0.00000000e+00]), array([  2.28415738e-03,   3.11069199e-03,   9.69120593e-03,
         6.21823490e-02,   3.06116400e-02,   5.71468930e-03,
         0.00000000e+00,   2.44883606e-03,   4.00213343e-03,
         7.91900433e-04,   5.67518439e-03,   6.99905611e-03,
         1.51616639e-02,   1.81533198e-02,   1.78809230e-03,
         3.10069103e-03,   3.09199858e-03,   2.26547450e-04,
         2.77915277e-03,   1.93588007e-03,   2.14478798e-03,
         6.01000390e-03,   6.97816680e-03,   2.21510312e-03,
         1.93697266e-03,   2.13921138e-03,   2.75535010e-04,
         3.88696919e-03,   5.37204816e-03,   2.32959376e-02,
         2.22736028e-02,   1.63706631e-02,   2.38665981e-02,
         5.24577019e-03,   9.67674620e-03,   9.37038726e-03,
         1.71869372e-02,   1.33406486e-02,   5.96379750e-03,
         2.57597087e-02,   8.62430123e-02,   5.30242817e-02,
         4.81373197e-02,   3.11718521e-02,   9.95122286e-03,
         5.80899602e-03,   4.96202221e-03,   7.53931346e-03,
         1.21684372e-02,   7.36059551e-02,   4.84238368e-02,
         3.85151738e-02,   1.00310586e-02,   1.02175972e-02,
         1.91651213e-03,   8.90685188e-04,   1.39337366e-03,
        -1.11916806e-18,   1.89730130e-03,   1.19910863e-18,
         5.12504843e-04,   7.32863480e-04,   1.13961005e-03,
         1.92927822e-03,   6.72659330e-03,   5.11359441e-03,
         1.05964553e-02,   2.69740236e-03,   1.01146086e-03,
         1.73974119e-03,   6.38973558e-04,   1.10564944e-03,
         3.32994863e-03,   1.33145831e-02,   8.41895006e-03,
         1.83728238e-02,   2.45025991e-02,   1.45865816e-02,
         2.44589211e-02,   1.90770028e-02,   1.09942338e-02,
         5.48865054e-04,   3.93346216e-03,   4.85103575e-03,
         1.05085275e-02,   1.25820399e-02,   1.23932421e-03,
         2.14908450e-03,   2.14305978e-03,   1.57019713e-04,
         1.92622680e-03,   1.34175570e-03,   1.48654947e-03,
         4.16552508e-03,   4.83655740e-03,   1.53528480e-03,
         1.34251297e-03,   1.48268434e-03,   1.90972920e-04,
         1.22943554e-02,   3.21757238e-02,   5.37967395e-02,
         1.73660119e-02,   1.02993688e-02,   9.51304536e-04,
         3.05121533e-03,   1.24018580e-03,   1.08432168e-03,
         1.19122415e-02,   9.24638437e-03,   4.13349949e-03,
         1.78540172e-02,   5.97749081e-02,   3.67510536e-02,
         3.33639072e-02,   2.16051660e-02,   6.89717829e-03,
         4.02620681e-03,   3.43917048e-03,   5.22548734e-03,
         8.43392635e-03,   5.10161819e-02,   3.35624918e-02,
         2.66948117e-02,   6.95251232e-03,   7.08180195e-03,
         2.00376306e-02,   2.35542622e-02,   4.09049076e-02,
         2.26962183e-02,   2.86014517e-02,   1.26147024e-02,
         1.37020116e-02,   4.97423439e-03,   3.29693232e-03,
         1.33717997e-03,   4.66219217e-03,   3.54422495e-03,
         7.34438798e-03,   1.86956571e-03,   7.01042073e-04,
         1.20581212e-03,   4.42871656e-04,   7.66324041e-04,
         2.30798262e-03,   9.22831842e-03,   5.83516221e-03,
         1.27341778e-02,   1.69827163e-02,   1.01099388e-02,
         1.69524431e-02,   1.32222433e-02,   7.62008769e-03,
         8.44157831e-03,   6.47360076e-03,   2.71822337e-03,
         1.64374192e-02,   4.02230016e-02,   4.17892681e-02,
         3.43222865e-02,   2.06433194e-02,   5.03072684e-03,
         1.81144156e-03,   1.26179951e-03,   1.39796492e-03,
         3.91729845e-03,   4.54834347e-03,   1.44379607e-03,
         1.26251166e-03,   1.39433012e-03,   1.79592707e-04,
         1.15617259e-02,   3.02583493e-02,   5.05909531e-02,
         1.63311588e-02,   9.68562206e-03,   8.94615616e-04,
         2.86939122e-03,   1.16628224e-03,   1.01970617e-03,
         1.54569263e-02,   2.93328964e-02,   3.65188854e-02,
         9.37014932e-03,   5.90287046e-03,   2.54989048e-03,
         4.16839785e-19,  -1.04209946e-19,   2.68138844e-03,
         3.78628225e-03,   3.23422784e-03,   4.91409680e-03,
         7.93134263e-03,   4.79760910e-02,   3.15624789e-02,
         2.51040487e-02,   6.53820712e-03,   6.65979229e-03,
         1.88435738e-02,   2.21506468e-02,   3.84673548e-02,
         2.13437344e-02,   2.68970707e-02,   1.18629832e-02,
         1.28854989e-02,   4.67781619e-03,   3.10046576e-03,
         6.57489339e-03,   5.89197646e-03,   1.65745939e-02,
         1.07850564e-02,   5.81424811e-03,   4.74631306e-03,
         1.44939189e-03,   4.07471847e-03,   2.60309030e-03,
         2.17044828e-03,   8.67839631e-03,   5.48744070e-03,
         1.19753390e-02,   1.59707041e-02,   9.50748026e-03,
         1.59422349e-02,   1.24343203e-02,   7.16600120e-03,
         7.93853860e-03,   6.08783425e-03,   2.55624249e-03,
         1.54579016e-02,   3.78260840e-02,   3.92990156e-02,
         3.22769968e-02,   1.94131692e-02,   4.73094221e-03,
         4.58748700e-03,   6.26731717e-04,   1.29942713e-02,
         1.66994897e-02,   5.23927693e-02,   3.47067518e-02,
         1.10702831e-02,   8.50793475e-03,   3.61883101e-03,
         1.05810863e-02,   2.76919042e-02,   4.62999423e-02,
         1.49459866e-02,   8.86410939e-03,   8.18736332e-04,
         2.62601591e-03,   1.06736081e-03,   9.33216990e-04,
         1.41459046e-02,   2.68449461e-02,   3.34214356e-02,
         8.57539433e-03,   5.40220226e-03,   2.33361451e-03,
         3.81484372e-19,  -9.53710931e-20,   2.45395910e-03,
         9.68689053e-03,   3.40046362e-02,   1.95740887e-02,

         7.29174901e-03,   5.59183013e-03,   2.34797355e-03,
         1.41984746e-02,   3.47442174e-02,   3.60971424e-02,
         2.96472400e-02,   1.78314882e-02,   4.34549039e-03,
         4.21372314e-03,   5.75668975e-04,   1.19355677e-02,
         1.53389047e-02,   4.81240872e-02,   3.18790316e-02,
         1.01683357e-02,   7.81475381e-03,   3.32398805e-03,
         7.15864511e-03,   2.23975294e-02,   2.11049569e-02,
         8.55663417e-03,   4.91762830e-02,   1.27232128e-02,
         6.83987122e-03,   2.27773723e-03,   6.16178451e-03,
         3.06646003e-03,   2.54343577e-03,   3.32853433e-03,
         9.19226880e-03,   1.76784394e-02,   7.13207851e-03,
         1.67260950e-03,   2.99755352e-04,   8.09506951e-04,
         6.40663319e-03,   4.38101779e-04,   4.33530978e-03,
         1.88219124e-02,   3.44139846e-02,   2.05521800e-02,
         3.00896494e-02,   9.82413146e-03,   4.36021231e-04,
         1.14912235e-03,   9.78694469e-04,   5.61239427e-03,
         1.83075913e-02,   3.52533146e-02,   3.67903406e-02,
         1.97564461e-02,   1.58691571e-03,   1.03836581e-03,
         5.50154356e-03,   4.93011266e-03,   1.38687953e-02,
         9.02439839e-03,   4.86507344e-03,   3.97147854e-03,
         1.21277899e-03,   3.40952162e-03,   2.17813641e-03,
         1.19303503e-02,   3.06836659e-02,   8.91770873e-03,
         7.52329949e-03,   7.70403177e-03,   2.85135831e-03,
         2.43832383e-03,   2.67502856e-03,   3.33053851e-03,
         1.34214958e-02,   2.96811483e-02,   8.12940941e-03,
         1.35628440e-02,   7.28220703e-03,   6.74775946e-03,
         1.35236822e-02,   1.59988944e-02,   2.23522779e-02,
         3.83858080e-03,   5.24417908e-04,   1.08729595e-02,
         1.39733018e-02,   4.38396618e-02,   2.90408825e-02,
         9.26306190e-03,   7.11901636e-03,   3.02805768e-03,
         6.52132016e-03,   2.04035062e-02,   1.92260098e-02,
         7.79484807e-03,   4.47981819e-02,   1.15904815e-02,
         6.23092631e-03,   2.07495322e-03,   5.61320878e-03,
         4.13679670e-02,   3.65996800e-02,   1.92106220e-02,
         1.19064817e-02,   6.68462712e-03,   8.04271192e-03,
         7.74439591e-04,   8.24640103e-03,   2.40608956e-02,
         5.83625890e-03,   3.99098143e-04,   3.94934274e-03,
         1.71462218e-02,   3.13501519e-02,   1.87224460e-02,
         2.74108068e-02,   8.94950170e-03,   3.97202823e-04,
         1.04681747e-03,   8.91562563e-04,   5.11273004e-03,
         1.66776901e-02,   3.21147574e-02,   3.35149440e-02,
         1.79975552e-02,   1.44563465e-03,   9.45921439e-04,
         8.81922587e-03,   1.96011987e-02,   2.74321704e-02,
         2.15755384e-02,   2.38825301e-02,   2.74034001e-03,
         4.47157331e-03,   9.27394918e-04,   6.26538308e-03]), array([  1.46869614e-02,   0.00000000e+00,   6.74961853e-03, ...,
         5.97372865e-18,  -5.79803075e-18,   1.05418741e-17]), array([ 0.,  0.,  0., ...,  0.,  0.,  0.]), array([  6.39907559e-02,   2.37185990e-03,   0.00000000e+00, ...,
        -3.39158065e-16,  -1.59881698e-16,  -1.16368016e-16]), array([ 0.01775981,  0.        ,  0.02125695, ...,  0.00725893,
        0.00505652,  0.11425592]), array([  8.36622684e-02,   0.00000000e+00,   5.12932939e-02, ...,
        -4.46473402e-18,   3.44422339e-17,  -2.55127658e-18]), array([  8.56730692e-02,   9.77617126e-03,   5.75159285e-03, ...,
         1.03040390e-02,   6.19005808e-17,  -6.44797717e-19]), array([ 0.,  0.,  0., ...,  0.,  0.,  0.]), array([  3.26515286e-02,   0.00000000e+00,   3.59276747e-02, ...,
         2.99950752e-16,  -1.81788334e-16,   9.08941672e-17]), array([  7.71669866e-02,   6.37272170e-03,   6.59405956e-03, ...,
         1.69042884e-02,  -9.23119768e-18,  -6.17032687e-17]), array([  0.00000000e+00,   0.00000000e+00,   0.00000000e+00, ...,
         0.00000000e+00,   0.00000000e+00,  -2.19427092e-15]), array([  0.00000000e+00,   0.00000000e+00,   0.00000000e+00, ...,
        -8.57137077e-17,  -1.54284674e-16,   3.42854831e-17]), array([  1.42126295e-03,   1.43564360e-02,   1.43729969e-02, ...,
         2.27698485e-03,   5.29720282e-19,   4.22702751e-03]), array([  2.61735012e-02,   2.53839045e-03,   1.07993726e-02, ...,
         4.13179682e-03,   8.73881700e-04,   1.39557418e-17]), array([ 0.01348336,  0.02011074,  0.01089088, ...,  0.00640271,
        0.00542313,  0.01164971]), array([ 0.,  0.,  0., ...,  0.,  0.,  0.]), array([  0.00000000e+00,   0.00000000e+00,   0.00000000e+00, ...,
         3.34283460e-16,  -4.79996763e-16,  -5.82853213e-16]), array([  0.00000000e+00,   0.00000000e+00,   0.00000000e+00, ...,
        -2.14284269e-18,   8.57137077e-18,  -1.07142135e-18]), array([  0.00000000e+00,   0.00000000e+00,   0.00000000e+00, ...,
        -9.42850785e-17,   5.54996258e-16,  -2.28427031e-15]), array([ 0.,  0.,  0., ...,  0.,  0.,  0.]), array([ 0.01736646,  0.02205019,  0.01496867, ...,  0.0007993 ,
        0.00236273,  0.00058242]), array([ 0.02973898,  0.02933299,  0.01211934, ...,  0.00509325,
        0.00236023,  0.00843372]), array([ 0.,  0.,  0., ...,  0.,  0.,  0.]), array([ 0.0118332 ,  0.00329815,  0.05391171, ...,  0.01341036,
        0.01036899,  0.00677799

有没有办法将上面的数组数组转换为单列向量或列矩阵。

1 个答案:

答案 0 :(得分:0)

最简单的解决方案似乎使用方法 np.hstack 。基本上它需要一系列数组并将它们水平堆叠以形成一个单独的数组(列式) 查看完整说明here