2016-02-04 78 views
0

編輯:我意識到,我可以使用dput()功能設定輸出SVM圖書館e1071(預測功能總是返回一個類)中的R

> dput(lc_train) 
structure(list(int_rate = structure(c(0.327601699000463, -1.90117708704328, 
-1.06167801512506, -1.24645906084619, -0.849521999667472, 0.327601699000463, 
-0.511897372917754, -1.47458380865006, -0.286053872591929, 0.21582057257657, 
-0.0145854227053318, 0.345851678824772, 0.777007452174074, 0.954944755461087, 
-1.07080300503722, 1.17622576083083, 1.22185071039161, -0.286053872591929, 
0.954944755461087, -1.766583485839, -0.286053872591929, -1.24645906084619, 
1.54806909975113, 0.21582057257657, 0.941257270592855, -1.16661539911484, 
1.06900712936302, 0.439382825424356, -0.73545962576554, 1.22185071039161, 
-0.959021878613326, 1.51385038758055, -0.00774168027121609, -1.47458380865006, 
-0.511897372917754, 0.0652582390260203, -0.73545962576554, -1.766583485839, 
2.35791195445485, -1.06167801512506, -0.826709524887085, -1.53845873803514, 
0.427976588034162, -1.53845873803514, -0.541553590132256, -0.158304013821766, 
-0.511897372917754, -1.90117708704328, -0.511897372917754, -0.511897372917754, 
-1.16661539911484, -0.849521999667472, -0.158304013821766, 1.51385038758055, 
-0.0624916197441433, 0.21582057257657, 0.551163951848249, 0.0241957844213249, 
0.774726204696035, 0.345851678824772, 2.42406813131797, -1.47458380865006, 
-0.459428680922866, -0.158304013821766, -0.511897372917754, -1.68673982410765, 
-0.0624916197441433, -0.158304013821766, 1.06900712936302, 0.21582057257657, 
0.345851678824772, -1.53845873803514, -0.511897372917754, -0.511897372917754, 
0.662945078272142, 0.327601699000463, 0.327601699000463, 0.327601699000463, 
-0.0145854227053318, -0.826709524887085, -1.53845873803514, -0.00774168027121609, 
-0.0145854227053318, -0.00774168027121609, 2.62938040434144, 
0.0241957844213249, -0.0853040945245296, 0.941257270592855, -0.511897372917754, 
-0.541553590132256, 0.777007452174074, -0.156022766343727, -1.24645906084619, 
-0.959021878613326, -0.313428842328393, 1.83322503450596, 0.329882946478502, 
1.35644431159589, -1.47458380865006, 0.21582057257657, -0.826709524887085, 
1.39978801367862, 0.21582057257657, -1.47458380865006, -0.541553590132256, 
-1.766583485839, -0.459428680922866, -0.511897372917754, 2.12978720665098, 
-1.90117708704328, -1.47458380865006, -1.06167801512506, 1.51385038758055, 
0.345851678824772, 0.327601699000463, 0.329882946478502, -0.511897372917754, 
-1.47458380865006, -1.47458380865006, 2.31228700489407, 0.284257996917729, 
0.195289345274222, -1.24645906084619, 0.439382825424356, -0.641928479165956, 
0.195289345274222, -0.73545962576554, 0.167914375537759, -1.24645906084619, 
0.439382825424356, -0.158304013821766, 0.624163871145486, 1.06900712936302, 
-0.313428842328393, -0.76967833793612, -0.76967833793612, 0.886507331119928, 
0.662945078272142, -1.53845873803514, -0.00774168027121609, -0.76967833793612, 
0.777007452174074, 0.662945078272142, 1.10778833648968, -0.313428842328393, 
-1.68673982410765, 0.345851678824772, 0.167914375537759, -0.959021878613326, 
-1.47458380865006, 0.327601699000463, -0.286053872591929, -0.73545962576554, 
0.327601699000463, -1.47458380865006, 1.65072523626287, 0.439382825424356, 
-0.511897372917754, -1.47458380865006, -0.73545962576554, -1.47458380865006, 
2.06134978230982, -0.286053872591929, 1.84919376685223, -1.24645906084619, 
-0.511897372917754, -1.90117708704328, -0.73545962576554, -1.24645906084619, 
-0.511897372917754, -0.0624916197441433, -0.605428519517338, 
-1.06167801512506, 0.327601699000463, -0.158304013821766, -0.00774168027121609, 
-0.459428680922866, -0.849521999667472, -1.24645906084619, -0.76967833793612, 
-1.24645906084619, -0.286053872591929, 0.195289345274222, 0.886507331119928, 
0.662945078272142, -0.286053872591929, -1.47458380865006, -0.0624916197441433, 
-1.766583485839, 0.345851678824772, 0.418851598122008, 0.662945078272142, 
0.167914375537759, -0.73545962576554, -0.73545962576554, 0.954944755461087, 
-1.766583485839, -0.0145854227053318, 0.418851598122008, 0.624163871145486, 
1.06900712936302, 0.21582057257657, 0.439382825424356, 0.327601699000463, 
-0.00774168027121609, -1.47458380865006, 0.418851598122008, -1.47458380865006, 
-0.0145854227053318, -1.24645906084619, -0.443459948576595, 0.327601699000463, 
1.06900712936302, 1.84463127189615, 0.662945078272142, 0.439382825424356, 
0.551163951848249, 1.99975610040278, -1.90117708704328, -0.76967833793612, 
0.941257270592855, -1.24645906084619, -1.90117708704328, -0.849521999667472, 
-0.156022766343727, -1.05027177773487, 1.1032258415336, 1.83322503450596, 
-0.959021878613326, 0.345851678824772, -1.766583485839, 0.439382825424356, 
0.777007452174074, 1.78760008494519, 1.00056970502186, -0.541553590132256, 
0.345851678824772, 0.774726204696035, 1.51385038758055, 0.777007452174074, 
-0.0624916197441433, -0.00774168027121609, -0.459428680922866, 
-0.73545962576554, 1.62335026652641, 1.02338217980225, -1.47458380865006, 
1.00056970502186, -1.47458380865006, -0.0145854227053318, 0.941257270592855, 
0.206695582664415, -1.68673982410765, 0.345851678824772, 0.327601699000463, 
-1.53845873803514, 0.954944755461087, -0.0145854227053318, 0.0652582390260203, 
0.777007452174074, -0.541553590132256, -0.959021878613326, -0.00774168027121609, 
2.11381847430471, -1.05027177773487, -0.00774168027121609, -0.0624916197441433, 
-1.07080300503722, 1.06900712936302, 1.90166245884712, 0.345851678824772, 
0.662945078272142, 1.06900712936302, 0.140539405801295, 1.28344439229865, 
-1.24645906084619, -1.24645906084619, 0.439382825424356, -0.641928479165956, 
-1.24645906084619, -0.849521999667472, -1.53845873803514, -1.06167801512506, 
-0.286053872591929, -1.06167801512506, -0.286053872591929, -0.541553590132256, 
-0.158304013821766, -0.73545962576554, 0.0652582390260203, 0.777007452174074, 
-1.90117708704328, 0.941257270592855, 0.284257996917729, 0.551163951848249, 
1.62563151400445, -0.345366307020934, 0.21582057257657, 1.84919376685223, 
-0.00774168027121609, 0.439382825424356, 1.35644431159589, -0.00774168027121609, 
0.439382825424356, -0.158304013821766, 1.00056970502186, 0.827194896690923, 
1.39750676620058, -0.605428519517338, 0.195289345274222, -1.24645906084619, 
0.777007452174074, -0.511897372917754, -0.156022766343727, 1.17622576083083, 
0.167914375537759, -0.511897372917754, -0.76967833793612, 0.327601699000463, 
0.729101255135262, 1.73741264042834, 1.00056970502186, 2.40125565653758, 
0.662945078272142, 0.624163871145486, 1.94728740840789, 1.28344439229865, 
-0.997803085739983, 1.02338217980225, 0.624163871145486, 0.439382825424356, 
0.284257996917729, 0.439382825424356, -0.76967833793612, -0.313428842328393, 
0.418851598122008, -0.00774168027121609, 0.941257270592855, 0.774726204696035, 
0.662945078272142, 0.418851598122008, 0.729101255135262, -1.53845873803514, 
-0.511897372917754, -0.286053872591929, 1.62563151400445, 1.02338217980225, 
-0.73545962576554, 0.327601699000463, 0.774726204696035, 1.27888189734257, 
-0.0145854227053318, -1.53845873803514, 1.1032258415336, -0.00774168027121609, 
-0.286053872591929, 0.327601699000463, 1.06900712936302, 0.624163871145486, 
-0.286053872591929, -0.73545962576554, 0.329882946478502, 0.345851678824772, 
-1.766583485839, 0.21582057257657, 1.62563151400445, 1.22185071039161, 
-0.847240752189433, -1.31489648518735, -0.849521999667472, 2.40125565653758, 
0.21582057257657, -1.24645906084619, -0.286053872591929, -0.00774168027121609, 
-0.849521999667472, -0.299741357460161, -0.511897372917754, 0.21582057257657, 
1.35644431159589, 0.954944755461087, 1.35416306411785, -1.47458380865006, 
-0.73545962576554, 0.327601699000463, 0.439382825424356, 0.327601699000463, 
-0.286053872591929, -1.24645906084619, 1.95869364579809, -0.849521999667472, 
-0.849521999667472, -0.00774168027121609, -1.16661539911484, 
-1.24645906084619, 0.624163871145486, 1.33135058933746, 1.62335026652641, 
0.886507331119928, 0.21582057257657, -0.0145854227053318, -0.459428680922866, 
-0.511897372917754, 1.51385038758055, 1.02338217980225, 0.662945078272142, 
0.345851678824772, -0.00774168027121609, -0.156022766343727, 
-0.511897372917754, -0.156022766343727, 0.418851598122008, 0.195289345274222, 
-0.0624916197441433, -1.16661539911484, -1.53845873803514, 0.21582057257657, 
2.08416225709021, -1.06167801512506, 0.662945078272142, 2.12978720665098, 
1.17622576083083, 0.439382825424356, -0.541553590132256, 1.06900712936302, 
0.327601699000463, -0.158304013821766, 0.774726204696035, -1.47458380865006, 
-0.0624916197441433, 0.941257270592855, 0.774726204696035, 1.17622576083083, 
0.195289345274222, 0.662945078272142, -1.24645906084619, -1.766583485839, 
-0.0853040945245296, -0.459428680922866, -0.459428680922866, 
1.67353771104326, -0.00774168027121609, 0.195289345274222, 2.21647461081645, 
0.418851598122008, -1.766583485839, 0.662945078272142, -0.0145854227053318, 
-0.73545962576554, -0.511897372917754, -1.24645906084619), "`scaled:center`" = 14.3639361702128, "`scaled:scale`" = 4.38356648994426), 
    revol_util = structure(c(-1.1664699090807, -0.264229209519369, 
    1.34913716457307, -0.482011447344519, 0.598010670849592, 
    0.149112588801834, 0.491341819669927, 0.362450291161165, 
    -0.962021277653013, 0.620233348178689, -1.6687024167183, 
    1.81136885301828, 1.65581011171461, -1.99759804118893, 0.309115865571332, 
    -0.197561177532078, -0.530901337468532, 1.36691530643635, 
    -0.0775587199549547, -0.797573465417696, 0.913572688922769, 
    -0.0508915071600383, 0.495786355135746, -0.33089724150666, 
    1.50469590587675, -1.40203028876913, 1.18024481687193, 1.65136557624879, 
    0.793570231345645, 0.438007394080094, -1.08202373523014, 
    0.61578881271287, -0.25978467405355, 0.402451110353539, -2.04648793131294, 
    -1.21980433467054, 1.07357596569227, -1.16202537361489, 0.242447833584041, 
    -1.26869422479455, -0.628681117716559, -0.935354064858097, 
    0.495786355135746, 0.8291265150722, 0.909128153456949, -2.19315760168498, 
    0.633566954576147, -2.58872125814291, -1.3709185405084, 0.0646664149512655, 
    -1.00646663231121, -0.490900518276158, -0.0020016170360253, 
    1.21135656513267, 1.19802295873521, 0.953573508115143, 1.05135328836317, 
    0.589121599917953, -1.09535734162759, -0.0464469716942192, 
    1.49136229947929, -0.317563635109202, -2.28649284646719, 
    -0.935354064858097, 0.0379992021563494, -1.11313548349087, 
    -0.668681936908933, -2.68205650292512, 0.860238263332936, 
    0.598010670849592, -0.846463355541709, -0.930909529392277, 
    -0.0642251135574967, -0.673126472374753, -1.19758165734144, 
    -0.153115822873884, 0.553565316191398, -0.11311500368151, 
    -0.308674564177563, 1.06913143022645, 0.291337723708055, 
    -0.206450248463717, 0.206891549857486, -0.962021277653013, 
    1.24691284885922, -0.406454344425589, 0.0646664149512655, 
    0.993574327307518, 0.793570231345645, -0.32645270604084, 
    -0.153115822873884, 0.0868890922803625, -0.650903795045656, 
    0.478008213272468, 0.233558762652402, 0.68690138016598, -0.495345053741977, 
    1.53136311867166, -1.24202701199963, -0.597569369455823, 
    -0.926464993926458, -1.06869012883268, 1.17580028140611, 
    1.04690875289735, -0.0908923263524131, 0.651345096439425, 
    0.429118323148455, 0.918017224388588, 0.962462579046782, 
    -1.53092181727789, -0.464233305481242, -0.76646171715696, 
    1.03801968196571, -0.428677021754686, 1.71803360823608, 1.63803196985133, 
    0.46467460687501, -0.784239859020237, 1.18913388780357, 0.402451110353539, 
    -0.833129749144251, 1.14468853314538, -0.459788770015422, 
    0.642456025507786, 0.678, -2.04648793131294, 
    0.269115046378958, 0.562454387123037, -0.868686032870806, 
    -0.25978467405355, 1.15357760407702, -0.410898879891409, 
    0.962462579046782, 0.882460940662033, 0.118000840541098, 
    0.255781439981499, -0.18422757113462, 1.57136393786404, -0.135337681010607, 
    -0.419787950823048, -0.726460897964585, -0.0242242943651222, 
    1.22469017153013, 0.273559581844777, -1.233137941068, 0.478008213272468, 
    1.36247077097053, 0.362450291161165, 0.749124876687451, -1.3264731858502, 
    1.45580601575273, 1.42913880295782, 0.171335266130931, -0.170893964737162, 
    0.0068874538956136, 1.39358251923126, 0.944684437183504, 
    0.753569412153271, -0.802018000883515, -1.73092591323977, 
    0.224669691720764, 0.193557943460028, -2.68205650292512, 
    0.54023170979394, 0.366894826626984, -2.23315842087736, -1.42425296609823, 
    1.35802623550471, -0.76646171715696, -0.00644615250184443, 
    -0.0242242943651222, 1.39802705469708, 0.371339362092803, 
    -0.206450248463717, 0.855793727867116, 0.424673787682636, 
    -0.842018820075889, -0.406454344425589, 0.211336085323305, 
    -0.948687671255555, -0.646459259579837, 0.442451929545913, 
    -0.824240678212612, 1.2869136680516, -0.793128929951876, 
    -0.530901337468532, 0.802459302277284, -0.69534914970385, 
    -1.84203929988525, -0.962021277653013, 0.602455206315412, 
    1.42913880295782, -0.842018820075889, 0.931350830786046, 
    -1.21535979920472, -0.486455982810338, -1.43314203702987, 
    -0.206450248463717, -1.11313548349087, 0.584677064452134, 
    0.731346734824174, 0.891350011593672, 0.642456025507786, 
    -0.588680298524184, 1.00690793370498, -0.922020458460638, 
    -0.646459259579837, -0.76646171715696, -0.753128110759502, 
    -2.06426607317622, -0.215339319395356, 0.669123238302703, 
    0.122445376006918, 1.61136475705641, -0.646459259579837, 
    0.678, -0.593124833990004, 1.26913552618832, 
    -1.73092591323977, 0.0513328085538075, 1.22024563606431, 
    -0.802018000883515, -1.87759558361181, -1.86426197721435, 
    1.70914453730444, 0.215780620789125, 1.06913143022645, 0.873571869730394, 
    -0.344230847904118, 1.2646909907225, -1.97537536385983, -1.08646827069596, 
    -0.162004893805523, 0.0868890922803625, 1.34469262910725, 
    -0.188672106600439, 1.04246421743153, -1.01535570324285, 
    0.478008213272468, 1.5402521896033, 1.26024645525668, 1.06024235929481, 
    1.19357842326939, -0.299785493245924, -0.237561996724453, 
    0.100222698677821, -1.0509119869694, -1.15313630268325, 0.402451110353539, 
    -0.633125653182378, 0.0513328085538075, 1.52691858320584, 
    -2.0598215377104, -0.11311500368151, 0.0424437376221686, 
    -1.35758493411094, 0.429118323148455, 1.55803033146658, 1.00246339823916, 
    0.349116684763707, 1.43358333842364, 0.691345915631799, 0.273559581844777, 
    0.442451929545913, -0.0820032554207741, 1.46913962215019, 
    -0.108670468215691, -1.09535734162759, 0.100222698677821, 
    0.642456025507786, 1.05135328836317, -0.148671287408065, 
    1.3802489128338, 0.113556305075279, 0.184668872528389, -1.09980187709341, 
    -1.65981334578666, -1.00202209684539, 0.998018862773337, 
    -0.504234124673616, -1.46869832075642, -0.362008989767395, 
    -1.27313876026037, -0.770906252622779, -0.304230028711744, 
    1.62469836345387, 0.993574327307518, -0.562013085729268, 
    -0.197561177532078, 0.722457663892535, 1.50469590587675, 
    -2.27760377553555, 0.229114227186583, 1.45580601575273, 1.31802541631233, 
    1.55358579600076, 1.07802050115809, 1.10024317848718, 0.842460121469658, 
    0.135778982404376, -0.144226751942246, 0.273559581844777, 
    1.32691448724397, 1.1491330686112, -1.09535734162759, 1.04246421743153, 
    -1.233137941068, -2.01093164758639, -0.637570188648198, 0.144668053336015, 
    -1.56647810100445, 1.13135492674792, -1.233137941068, 0.446896465011733, 
    0.126889911472737, 0.455785535943371, 0.669123238302703, 
    0.0957781632120013, 1.3802489128338, 0.531342638862301, -0.424232486288867, 
    0.602455206315412, 0.678, 0.655789631905244, 
    -0.153115822873884, -1.59314531379937, 0.0735554858829044, 
    -1.04202291603776, 0.366894826626984, 1.6780327890437, -0.0553360426258578, 
    1.46025055121855, 0.486897284204107, -1.4642537852906, 0.118000840541098, 
    -1.63314613299174, -0.433121557220506, -0.562013085729268, 
    -0.277562815916827, 0.0113319893614331, 0.606899741781231, 
    -1.09535734162759, -0.784239859020237, -0.108670468215691, 
    -0.815351607280973, 1.28246913258578, -0.610902975853281, 
    0.660234167371064, -0.210894783929536, 0.424673787682636, 
    -0.842018820075889, -0.273118280451008, -1.27313876026037, 
    -0.299785493245924, -0.975354884050471, 0.0157765248272525, 
    0.90468361799113, 0.922461759854407, -1.03313384510612, 0.713568592960896, 
    1.15357760407702, 0.0113319893614331, 1.2869136680516, 0.664678702836883, 
    -1.85537290628271, 0.700234986563438, 0.544676245259759, 
    -2.43760705230505, -1.45536471435896, -0.579791227592546, 
    1.5624748669324, -0.433121557220506, -2.68205650292512, -1.45980924982478, 
    0.211336085323305, -0.295340957780105, 1.02468607556825, 
    -1.41091935970077, 0.215780620789125, 0.584677064452134, 
    0.984685256375879, 1.69136639544116, 0.811348373208923, 0.571343458054676, 
    -0.130893145544787, 0.0202210602930716, 0.713568592960896, 
    1.30024727444906, 0.286893188242235, 0.433562858614275, 1.34024809364143, 
    -2.06426607317622, -0.415343415357228, -0.393120738028131, 
    -0.637570188648198, 0.211336085323305, 0.513564496999024, 
    1.36691530643635, -0.153115822873884, -0.642014724114017, 
    -0.0242242943651222, 0.069110950417085, -0.166449429271342, 
    -2.20649120808244, -0.775350788088599, -0.104225932749871, 
    1.2424683133934, 0.642456025507786, -0.904242316597361, -0.677571007840572, 
    1.25135738432504, 1.27358006165414, 0.286893188242235, 1.20691202966685, 
    1.09579864302136, -0.69090461423803, 1.2646909907225, 1.7002554663728, 
    -1.33980679224766, 0.771347554016548, -0.975354884050471, 
    -2.32649366565956, 1.49136229947929, -1.08646827069596, 0.118000840541098, 
    0.304671330105513, -1.7842603388296, 1.2646909907225, -0.370898060699034, 
    -1.24647154746545, 1.31358088084651, 0.998018862773337, -1.71314777137649, 
    1.09579864302136, 1.27802459711996, 1.07802050115809, -1.8064830161587, 
    -0.308674564177563, -1.28647236665783, 0.304671330105513, 
    0.331338542900429, 1.02024154010243, -0.0908923263524131, 
    1.2869136680516, -0.0197797588993028, -1.17091444454652, 
    1.22913470699595, -0.0997813972840516, 0.646900560973606, 
    -0.224228390326995, -0.277562815916827), "`scaled:center`" = 60.3450354609929, "`scaled:scale`" = 22.4995392137262), 
    default = structure(c(1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 
    1L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 
    1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 
    1L, 2L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 
    1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 2L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 
    1L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("-1", "1"), class = "factor")), .Names = c("int_rate", 
"revol_util", "default"), class = c("data.table", "data.frame" 
), row.names = c(NA, -451L), .internal.selfref = <pointer: 0x101822d78>, index = integer(0)) 

我訓練的一部分,我從e1071運行svm包。

> svmfit = svm(default ~., data = lc_train, kernel = "linear", cost = 10, scale = FALSE) 
> summary(svmfit) 

Call: 
svm(formula = default ~ ., data = lc_train, kernel = "linear", cost = 10, scale = FALSE) 


Parameters: 
    SVM-Type: C-classification 
SVM-Kernel: linear 
     cost: 10 
     gamma: 0.3333333 

Number of Support Vectors: 1941 

(996 945) 


Number of Classes: 2 

Levels: 
-1 1 



> 
> ypred = predict(svmfit, lc_train) 
> unique(ypred) 
[1] -1 
Levels: -1 1 

正如你可以從svmfit訓練數據彙總看出,SVM實際上並分成兩個班。看起來在一個類中有996個支持向量,在另一個類中有945個支持向量。

但是,當我在相同的訓練數據集lc_train上使用predict函數時,它告訴我所有的預測都是一個類(-1)。

我真的很困惑,因爲summary(svmfit)清楚地顯示了兩個類,我在每種情況下都使用相同的訓練數據集。

我正在使用數據表,特別是lc_train是一個數據表。我不確定這是否會搞砸了。

謝謝!

+1

我不能與虛擬數據重現您的問題。因此我懷疑它可能與數據的拓撲結構有關,儘管我無法真正想到可能導致這種奇怪行爲的事情。 您是否很樂意給我們簡要描述您使用的數據? (維數,原始不平衡等) – Vongo

+0

如果更改內核,是否仍然存在相同的問題? – Vongo

+0

我在更改內核時仍然遇到同樣的問題。另外,我意識到我可以使用dput()來導出一部分數據集。所以我適當地編輯了我原來的帖子! – Vincent

回答

0

這裏是再現您的問題代碼:

library("data.table") 
library("e1071") 

set.seed(10) 

lc_train <- data.table(default = as.factor(sample(c(-1, 1), size = 200, replace = TRUE)), x1=rnorm(100), x2=rnorm(100)) 
svmfit <- svm(default ~., data = lc_train, kernel = "linear", cost = 10, scale = FALSE) 
summary(svmfit) 
ypred <- predict(svmfit, lc_train) 
table(ypred) 

摘要顯示,你在你的數據有兩個類,這是真的。但svm僅預測一個類。這可能是因爲數據而發生的,您可能想要更改模型參數,如@Vongo建議的(kernel = "radial")。

(一旦你改變隨機種子100 set.seed(100)在上面的代碼中,你會看到在預測兩班)。

+0

我發現如此奇怪,因爲在上述的例子中,摘要輸出是 '>摘要(svmfit) 呼叫: SVM(式=默認〜,數據= lc_train,內核=「線性」,成本= 10 ,標度= FALSE) 參數: SVM-類型:C-分類 SVM-內核:線性 成本:10 伽瑪:0.5 支持向量的數量:192 (92 100) 數類別:2 級別: -1 1'。總結輸出是否意味着有192個支持向量,其中一個類有92個,另一個有100個?爲什麼預測同一個'lc_train'預測全部在一個類中? – Vincent

+1

據我所知,支持向量定義了一個餘量。這並不意味着它們是相應類的元素。在這裏他們定義了一個邊界,將數據集中的所有元素分配給一個類。 'plot(svmfit,lc_train)'可以幫助你看到結果。順便說一下,如此大量的支持向量是一個不好的跡象(http://stackoverflow.com/a/9485280/4973476)。 –