اذهب إلى المحتوى

السؤال

نشر (معدل)

السلام عليكم

ده الكوده

def handle_missing_values(data, save_path):

    numeric_features = data.select_dtypes(include=['number']).columns.tolist()
    text_features = data.select_dtypes(include=['object']).columns.tolist()

    preprocessor = ColumnTransformer(
        transformers=[
            ('num',IterativeImputer(),numeric_features),
            ('text', 'passthrough', text_features),
        ]
    )

    df_transformed = preprocessor.fit_transform(data)

    features_names =  text_features + numeric_features
    data = pd.DataFrame(df_transformed, columns=features_names)

    if save_path is not None:
        data.round(1).to_csv(save_path, index=False)

    return data

ودي النتجيه 


row_id	sequence_type	sequence_id	subject	orientation	behavior	phase	gesture	sequence_counter	acc_x	acc_y	acc_z	rot_w	rot_x	rot_y	rot_z	thm_1	thm_2	thm_3	thm_4	thm_5	tof_1_v0	tof_1_v1	tof_1_v2	tof_1_v3	tof_1_v4	tof_1_v5	tof_1_v6	tof_1_v7	tof_1_v8	tof_1_v9	tof_1_v10	tof_1_v11	tof_1_v12	tof_1_v13	tof_1_v14	tof_1_v15	tof_1_v16	tof_1_v17	tof_1_v18	tof_1_v19	tof_1_v20	tof_1_v21	tof_1_v22	tof_1_v23	tof_1_v24	tof_1_v25	tof_1_v26	tof_1_v27	tof_1_v28	tof_1_v29	tof_1_v30	tof_1_v31	tof_1_v32	tof_1_v33	tof_1_v34	tof_1_v35	tof_1_v36	tof_1_v37	tof_1_v38	tof_1_v39	tof_1_v40	tof_1_v41	tof_1_v42	tof_1_v43	tof_1_v44	tof_1_v45	tof_1_v46	tof_1_v47	tof_1_v48	tof_1_v49	tof_1_v50	tof_1_v51	tof_1_v52	tof_1_v53	tof_1_v54	tof_1_v55	tof_1_v56	tof_1_v57	tof_1_v58	tof_1_v59	tof_1_v60	tof_1_v61	tof_1_v62	tof_1_v63	tof_2_v0	tof_2_v1	tof_2_v2	tof_2_v3	tof_2_v4	tof_2_v5	tof_2_v6	tof_2_v7	tof_2_v8	tof_2_v9	tof_2_v10	tof_2_v11	tof_2_v12	tof_2_v13	tof_2_v14	tof_2_v15	tof_2_v16	tof_2_v17	tof_2_v18	tof_2_v19	tof_2_v20	tof_2_v21	tof_2_v22	tof_2_v23	tof_2_v24	tof_2_v25	tof_2_v26	tof_2_v27	tof_2_v28	tof_2_v29	tof_2_v30	tof_2_v31	tof_2_v32	tof_2_v33	tof_2_v34	tof_2_v35	tof_2_v36	tof_2_v37	tof_2_v38	tof_2_v39	tof_2_v40	tof_2_v41	tof_2_v42	tof_2_v43	tof_2_v44	tof_2_v45	tof_2_v46	tof_2_v47	tof_2_v48	tof_2_v49	tof_2_v50	tof_2_v51	tof_2_v52	tof_2_v53	tof_2_v54	tof_2_v55	tof_2_v56	tof_2_v57	tof_2_v58	tof_2_v59	tof_2_v60	tof_2_v61	tof_2_v62	tof_2_v63	tof_3_v0	tof_3_v1	tof_3_v2	tof_3_v3	tof_3_v4	tof_3_v5	tof_3_v6	tof_3_v7	tof_3_v8	tof_3_v9	tof_3_v10	tof_3_v11	tof_3_v12	tof_3_v13	tof_3_v14	tof_3_v15	tof_3_v16	tof_3_v17	tof_3_v18	tof_3_v19	tof_3_v20	tof_3_v21	tof_3_v22	tof_3_v23	tof_3_v24	tof_3_v25	tof_3_v26	tof_3_v27	tof_3_v28	tof_3_v29	tof_3_v30	tof_3_v31	tof_3_v32	tof_3_v33	tof_3_v34	tof_3_v35	tof_3_v36	tof_3_v37	tof_3_v38	tof_3_v39	tof_3_v40	tof_3_v41	tof_3_v42	tof_3_v43	tof_3_v44	tof_3_v45	tof_3_v46	tof_3_v47	tof_3_v48	tof_3_v49	tof_3_v50	tof_3_v51	tof_3_v52	tof_3_v53	tof_3_v54	tof_3_v55	tof_3_v56	tof_3_v57	tof_3_v58	tof_3_v59	tof_3_v60	tof_3_v61	tof_3_v62	tof_3_v63	tof_4_v0	tof_4_v1	tof_4_v2	tof_4_v3	tof_4_v4	tof_4_v5	tof_4_v6	tof_4_v7	tof_4_v8	tof_4_v9	tof_4_v10	tof_4_v11	tof_4_v12	tof_4_v13	tof_4_v14	tof_4_v15	tof_4_v16	tof_4_v17	tof_4_v18	tof_4_v19	tof_4_v20	tof_4_v21	tof_4_v22	tof_4_v23	tof_4_v24	tof_4_v25	tof_4_v26	tof_4_v27	tof_4_v28	tof_4_v29	tof_4_v30	tof_4_v31	tof_4_v32	tof_4_v33	tof_4_v34	tof_4_v35	tof_4_v36	tof_4_v37	tof_4_v38	tof_4_v39	tof_4_v40	tof_4_v41	tof_4_v42	tof_4_v43	tof_4_v44	tof_4_v45	tof_4_v46	tof_4_v47	tof_4_v48	tof_4_v49	tof_4_v50	tof_4_v51	tof_4_v52	tof_4_v53	tof_4_v54	tof_4_v55	tof_4_v56	tof_4_v57	tof_4_v58	tof_4_v59	tof_4_v60	tof_4_v61	tof_4_v62	tof_4_v63	tof_5_v0	tof_5_v1	tof_5_v2	tof_5_v3	tof_5_v4	tof_5_v5	tof_5_v6	tof_5_v7	tof_5_v8	tof_5_v9	tof_5_v10	tof_5_v11	tof_5_v12	tof_5_v13	tof_5_v14	tof_5_v15	tof_5_v16	tof_5_v17	tof_5_v18	tof_5_v19	tof_5_v20	tof_5_v21	tof_5_v22	tof_5_v23	tof_5_v24	tof_5_v25	tof_5_v26	tof_5_v27	tof_5_v28	tof_5_v29	tof_5_v30	tof_5_v31	tof_5_v32	tof_5_v33	tof_5_v34	tof_5_v35	tof_5_v36	tof_5_v37	tof_5_v38	tof_5_v39	tof_5_v40	tof_5_v41	tof_5_v42	tof_5_v43	tof_5_v44	tof_5_v45	tof_5_v46	tof_5_v47	tof_5_v48	tof_5_v49	tof_5_v50	tof_5_v51	tof_5_v52	tof_5_v53	tof_5_v54	tof_5_v55	tof_5_v56	tof_5_v57	tof_5_v58	tof_5_v59	tof_5_v60	tof_5_v61	tof_5_v62	tof_5_v63
0	0.0	6.683594	6.214844	3.355469	0.134399	-0.355164	-0.447327	-0.809753	28.943842	31.822186	29.553024	28.592863	28.310535	131.0	134.0	132.0	135.0	98.0	74.0	64.0	60.0	131.454790	145.657141	152.0	153.0	141.0	89.0	68.0	63.0	135.467597	152.104262	153.861681	156.120412	169.0	118.0	86.0	73.0	138.711645	159.764492	152.761021	164.048111	147.822192	147.0	110.0	87.0000	126.000000	149.476886	155.113513	151.275925	152.260774	147.932293	137.0	108.000000	115.000000	129.888552	131.201092	149.707000	138.898255	139.185316	146.351740	128.000000	110.000000	129.000000	140.000000	132.544241	126.0	131.0	136.057925	134.863071	99.310873	108.000000	122.000000	139.000000	113.000000	121.000000	130.600782	118.00000	96.0	123.805617	146.734649	120.873901	121.215319	165.0	124.0	100.0	102.000000	119.000000	125.093630	142.001177	115.0	130.0	127.023467	124.000000	107.000000	117.000000	132.000000	136.000000	116.000000	120.000000	135.473047	141.000000	118.000000	115.000000	122.000000	145.000000	128.00000	130.000000	137.00000	131.000000	110.467676	116.000000	117.000000	130.000000	115.000000	116.000000	117.000000	108.000000	105.884914	114.367459	119.000000	118.000000	110.000000	93.000000	90.000000	90.000000	93.944134	102.091707	110.199060	116.000000	103.000000	87.000000	82.000000	81.00000	85.094603	94.432552	100.284057	115.000000	91.000000	84.000000	80.000000	85.000000	58.000000	55.000000	59.000000	59.000000	63.000000	96.000000	93.000000	92.947718	57.0	59.000000	58.000000	64.000000	72.000000	103.000000	98.000000	99.798823	55.0	57.0	62.000000	63.000000	88.000000	103.000000	105.000000	108.000000	56.0	59.0	58.000000	77.000000	94.000000	106.000000	109.016493	113.000000	57.0	58.0	66.000000	78.000000	93.000000	107.732117	126.460592	124.405708	59.0	67.0	69.0	82.000000	104.000000	104.589979	117.947647	127.623995	63.0	70.0	79.0	96.0	122.324316	122.534585	116.651783	121.368658	79.0	83.0	105.362516	121.204226	123.201152	113.688824	102.0	100.000000	118.572314	132.830564	134.867072	132.266161	121.986660	86.404093	82.776684	74.0	130.0	137.527342	135.797786	135.044553	115.000166	90.187016	92.192533	69.0	134.0	137.0	136.0	145.0	131.0	126.0	83.0	60.0	141.533815	138.0	135.0	148.0	121.0	109.0	69.0	51.0	138.082783	143.0	139.0	148.0	113.0	91.0	67.0	52.0	137.554644	139.622297	142.510114	136.651294	101.0	81.0	62.0	54.000000	126.023113	145.287148	147.909906	133.661628	124.000000	78.0	68.000000	55.000000	126.789005	148.683545	145.540002	140.298945	119.880590	112.593238	66.00000	60.000000	128.0	130.0	147.00000	165.000000	139.052819	139.980524	131.048701	122.000000	121.0	140.000000	164.000000	151.465024	146.340148	135.815990	140.000000	119.000000	135.0	156.000000	166.000000	162.082069	146.991156	155.000000	137.000000	112.000000	148.0	163.000000	164.000000	153.000000	133.000000	131.000000	121.000000	118.000000	134.0	134.000000	128.0000	121.0	119.000000	121.000000	129.000000	116.169622	113.0	124.0	122.0	131.0	116.166902	114.204740	124.461351	113.388183	120.0	127.0	108.404816	114.035089	113.323002	116.115168	109.109969	106.762256	108.094775	95.918436	102.448744	104.576134	107.372933	107.158826	103.792840	100.846470	SEQ_000007_000000	Target	SEQ_000007	SUBJ_059520	Seated Lean Non Dom - FACE DOWN	Relaxes and moves hand to target location	Transition	Cheek - pinch skin
1	1.0	6.949219	6.214844	3.125000	0.143494	-0.340271	-0.428650	-0.824524	29.340816	31.874645	29.791740	28.663383	28.406172	130.0	138.0	131.0	135.0	101.0	76.0	66.0	61.0	124.687296	150.949742	156.0	155.0	141.0	93.0	74.0	64.0	143.234317	154.244816	155.973631	155.970192	165.0	116.0	86.0	75.0	130.000000	156.318525	153.739710	168.610863	144.968393	142.0	114.0	91.0000	127.000000	147.730756	155.006357	144.766547	151.622760	150.931932	145.0	114.000000	114.000000	131.110904	132.599664	148.013031	135.000000	141.599274	146.938702	132.000000	110.000000	121.000000	138.000000	142.000000	123.0	131.0	143.012076	135.099848	96.945829	106.000000	120.000000	139.000000	119.000000	124.000000	131.000000	117.00000	109.0	122.028173	153.890480	123.740361	120.692876	165.0	134.0	108.0	106.000000	123.000000	127.341160	153.330890	121.0	147.0	130.649517	131.000000	114.000000	114.000000	138.000000	145.000000	121.000000	141.000000	144.000000	138.000000	109.071362	120.000000	124.000000	147.000000	115.00000	141.000000	135.00000	125.000000	110.739894	118.571485	122.000000	122.000000	117.000000	103.000000	108.000000	108.000000	97.656240	116.187217	123.231573	129.000000	108.000000	100.000000	92.000000	93.000000	92.646835	102.477786	109.593839	116.000000	99.000000	93.000000	90.000000	91.00000	84.722324	93.106568	101.176005	113.000000	101.000000	94.000000	88.000000	95.000000	75.000000	67.000000	68.000000	71.000000	74.000000	102.000000	99.000000	99.548170	64.0	68.000000	67.000000	72.000000	88.000000	112.000000	103.000000	104.066007	65.0	68.0	69.000000	75.000000	105.000000	111.000000	109.000000	106.890080	66.0	71.0	72.000000	81.000000	109.000000	116.000000	121.000000	118.000000	61.0	67.0	75.000000	93.000000	116.000000	128.000000	130.000000	121.000000	62.0	72.0	80.0	92.000000	115.000000	116.005453	126.431795	126.631936	67.0	73.0	82.0	98.0	127.487897	128.961964	120.816699	126.017540	77.0	82.0	110.000000	119.172766	130.250687	119.047500	112.0	105.000000	134.000000	138.406254	150.713556	138.909709	131.758297	88.742848	91.000000	82.0	132.0	145.000000	148.000000	157.000000	143.000000	115.615679	117.000000	66.0	142.0	142.0	149.0	147.0	136.0	109.0	80.0	60.0	142.000000	142.0	143.0	135.0	126.0	92.0	73.0	61.0	141.788090	147.0	148.0	137.0	109.0	82.0	71.0	60.0	143.287494	141.888124	141.340736	136.041885	101.0	83.0	69.0	62.000000	133.718610	150.352982	150.035236	138.027874	109.000000	84.0	76.000000	64.000000	130.408407	145.905967	145.986555	139.516264	126.242425	93.000000	72.00000	74.000000	126.0	137.0	157.00000	174.000000	141.056187	146.988127	140.000000	130.000000	124.0	143.000000	168.000000	156.561742	149.076714	133.291922	142.000000	122.000000	138.0	157.000000	163.592701	160.932655	149.580486	155.000000	133.000000	117.000000	145.0	170.000000	163.000000	157.000000	139.000000	127.000000	126.000000	121.000000	136.0	142.000000	133.0000	127.0	123.000000	127.000000	134.000000	116.406496	116.0	122.0	123.0	126.0	119.099638	115.978955	129.670317	109.572659	122.0	129.0	113.122544	114.489459	110.868977	117.660513	106.755793	104.934400	108.331770	99.213386	103.846832	105.046063	107.756049	105.851694	102.043724	97.784309	SEQ_000007_000001	Target	SEQ_000007	SUBJ_059520	Seated Lean Non Dom - FACE DOWN	Relaxes and moves hand to target location	Transition	Cheek - pinch skin
2	2.0	5.722656	5.410156	5.421875	0.219055	-0.274231	-0.356934	-0.865662	30.339359	30.935045	30.090014	28.796087	28.529778	137.0	136.0	147.0	109.0	90.0	81.0	74.0	74.0	130.595131	164.000000	165.0	146.0	106.0	94.0	77.0	77.0	157.550854	163.199561	173.084324	180.000000	140.0	118.0	103.0	92.0	150.171293	174.904231	170.250214	174.994078	151.621500	155.0	119.0	122.0000	152.986242	164.361951	170.348181	173.681962	156.908033	157.228880	148.0	130.000000	123.000000	158.000000	151.169041	141.000000	147.000000	153.652201	157.000000	141.000000	113.000000	131.000000	152.000000	147.000000	146.0	157.0	144.000000	127.000000	103.604870	115.000000	127.000000	129.000000	119.000000	112.000000	117.000000	120.00000	119.0	153.228039	150.722993	125.000000	154.000000	165.0	145.0	122.0	111.000000	126.000000	143.000000	157.000000	143.0	166.0	149.000000	137.000000	116.000000	123.000000	149.000000	148.000000	136.000000	141.000000	143.000000	139.000000	113.674188	134.000000	133.000000	142.000000	123.00000	118.000000	116.00000	128.000000	115.229328	131.877948	140.991413	143.000000	123.000000	109.000000	112.000000	117.000000	113.545167	126.861018	136.275578	125.183772	119.000000	127.000000	114.000000	128.000000	109.226444	120.563476	129.575869	138.000000	136.000000	129.000000	125.000000	132.00000	104.631101	113.851280	119.696130	119.312122	120.574484	159.000000	150.000000	128.178228	73.000000	94.000000	109.000000	117.000000	126.000000	137.288737	134.294347	134.041364	94.0	119.000000	101.000000	123.000000	139.000000	145.535490	142.084978	137.184161	98.0	97.0	101.000000	128.000000	144.000000	137.461983	144.945042	137.833916	88.0	107.0	101.000000	154.000000	141.000000	148.384886	147.194217	131.862415	84.0	89.0	107.000000	140.000000	146.000000	149.000000	147.000000	131.000000	76.0	100.0	108.0	141.000000	147.967402	158.000000	143.000000	117.000000	77.0	89.0	105.0	133.0	151.675374	150.325212	141.000000	108.000000	79.0	99.0	114.000000	136.768044	145.322075	125.902283	130.0	118.000000	139.000000	149.000000	167.000000	162.000000	141.415431	107.000000	92.000000	81.0	135.0	140.000000	148.000000	151.000000	155.000000	111.000000	82.000000	94.0	132.0	139.0	147.0	138.0	120.0	97.0	78.0	85.0	140.000000	146.0	136.0	131.0	98.0	86.0	75.0	80.0	149.000000	156.0	147.0	113.0	97.0	84.0	81.0	71.0	134.245038	147.710988	174.000000	117.000000	96.0	89.0	80.0	78.000000	134.860897	156.183446	147.464909	145.000000	104.000000	92.0	88.000000	76.000000	135.033191	156.236893	140.387625	137.272935	131.641940	117.000000	98.00000	105.000000	92.0	110.0	157.00000	180.000000	150.753405	128.000000	123.000000	126.000000	142.0	165.000000	185.000000	167.168233	154.312369	159.328743	145.000000	139.000000	138.0	164.000000	174.394942	176.799898	166.615390	156.004197	145.000000	120.000000	151.0	165.000000	153.778248	167.978471	160.858673	151.000000	138.000000	127.000000	151.0	187.000000	161.2607	156.0	136.000000	135.000000	134.000000	123.834885	133.0	142.0	131.0	130.0	132.000000	136.000000	129.137690	117.893888	112.0	121.0	123.000000	125.000000	126.895699	126.942025	118.497915	105.038895	112.000000	119.000000	119.197958	117.245483	118.445205	113.081917	109.031713	93.889264	SEQ_000007_000002	Target	SEQ_000007	SUBJ_059520	Seated Lean Non Dom - FACE DOWN	Relaxes and moves hand to target location	Transition	Cheek - pinch skin
3	3.0	6.601562	3.531250	6.457031	0.297546	-0.264160	-0.238159	-0.885986	30.543730	27.044001	29.310717	29.018711	27.402010	143.0	147.0	170.0	127.0	109.0	98.0	95.0	95.0	130.916969	177.000000	189.0	177.0	136.0	121.0	107.0	104.0	148.967477	174.336319	186.082593	202.000000	171.0	160.0	141.0	135.0	143.126174	168.452284	170.805252	186.279694	174.725086	197.0	168.0	150.0000	131.000000	146.793798	162.571565	175.287576	170.000000	179.000000	174.0	164.000000	125.000000	140.000000	161.000000	175.000000	154.000000	174.000000	160.000000	159.000000	128.354415	126.000000	143.000000	167.000000	149.0	137.0	130.000000	131.000000	132.939173	145.501864	154.069515	141.000000	137.000000	129.000000	115.000000	124.00000	108.0	123.000000	146.000000	166.000000	152.000000	168.0	158.0	161.0	123.000000	133.000000	138.000000	155.000000	163.0	151.0	132.000000	151.000000	132.822623	216.000000	166.615295	185.890243	175.000000	157.000000	146.000000	140.000000	138.416651	172.106329	178.630542	191.156967	183.24330	173.000000	153.00000	164.000000	161.610629	186.084424	185.243865	210.378152	246.000000	189.000000	151.959537	189.010332	184.305956	183.768139	213.062090	206.719094	242.221483	210.162823	189.058164	225.000000	157.124768	183.313815	213.315288	232.926858	243.363639	243.000000	217.650224	220.00000	133.316458	183.058644	195.232341	192.104076	226.926868	232.814643	219.465103	210.052835	119.000000	132.000000	164.000000	181.591225	184.232519	187.364727	180.572281	170.756013	117.0	156.000000	176.000000	182.265338	190.596606	199.325453	182.768488	174.263140	144.0	151.0	187.000000	194.333026	202.261955	184.901148	185.367938	183.190219	126.0	162.0	184.000000	200.863849	207.090001	185.613447	190.339757	160.946661	128.0	158.0	180.000000	189.000000	202.000000	171.000000	168.000000	164.000000	117.0	153.0	183.0	197.000000	192.000000	164.000000	156.000000	160.000000	113.0	142.0	192.0	197.0	192.000000	157.000000	149.000000	146.000000	114.0	158.0	177.411602	173.000000	159.000000	156.000000	147.0	150.511857	139.000000	146.000000	153.000000	181.000000	161.000000	113.000000	112.000000	100.0	131.0	153.000000	148.000000	162.000000	138.000000	120.000000	106.000000	116.0	141.0	157.0	159.0	153.0	128.0	111.0	111.0	115.0	149.000000	173.0	162.0	141.0	120.0	117.0	108.0	120.0	181.000000	178.0	210.0	137.0	143.0	112.0	126.0	112.0	165.026598	184.311844	209.000000	202.000000	144.0	163.0	133.0	155.000000	146.589604	188.738022	191.500124	187.886049	156.586414	168.0	179.000000	155.000000	144.646203	177.743197	178.024482	162.898957	175.562566	166.414184	164.00000	175.000000	105.0	132.0	171.00000	179.590717	157.000000	167.000000	149.000000	131.000000	149.0	189.000000	203.000000	173.401712	163.513952	164.000000	133.000000	128.636071	162.0	181.000000	185.788617	177.198681	153.076490	152.000000	134.000000	159.684414	148.0	187.000000	167.478064	163.010831	149.000000	142.000000	135.000000	145.137588	159.0	181.000000	150.0000	135.0	129.000000	139.000000	124.068543	140.369897	141.0	136.0	120.0	122.0	132.000000	127.661183	117.292110	137.518299	107.0	112.0	115.000000	140.000000	116.652297	117.769643	122.493194	121.170972	101.000000	111.000000	124.146925	117.296945	118.454947	117.625673	111.701154	104.134512	SEQ_000007_000003	Target	SEQ_000007	SUBJ_059520	Seated Lean Non Dom - FACE DOWN	Relaxes and moves hand to target location	Transition	Cheek - pinch skin
4	4.0	5.566406	0.277344	9.632812	0.333557	-0.218628	-0.063538	-0.914856	29.317265	25.270855	26.808746	29.408604	27.357603	178.0	191.0	183.0	157.0	146.0	139.0	143.0	148.0	150.077259	203.148579	236.0	238.0	208.0	200.0	185.0	190.0	177.659808	213.135082	211.315037	210.000000	246.0	225.0	228.0	202.0	149.000000	206.000000	219.000000	219.000000	225.000000	218.0	214.0	215.2164	162.000000	177.000000	206.000000	219.000000	207.000000	182.000000	225.0	214.436866	157.483982	193.203538	189.248375	233.000000	195.000000	204.000000	190.000000	222.580261	133.923144	168.470355	180.538333	192.498116	209.0	210.0	218.783817	196.374494	130.509881	152.347422	168.369731	178.389563	200.349243	199.074457	199.215690	198.17379	138.0	155.000000	173.000000	188.000000	180.000000	176.0	211.0	235.0	134.148375	158.995423	182.021666	187.822366	210.0	210.0	223.000000	203.893476	149.533902	158.111147	178.131489	186.112023	204.899776	209.537064	216.821304	218.948079	144.762741	168.764244	178.268473	188.322641	202.52079	214.275621	213.45173	208.088882	155.236446	164.566805	175.410975	182.825058	195.058206	204.143275	179.415014	186.663912	134.151287	158.595025	166.928447	176.144651	180.393757	180.529678	184.777655	176.366763	128.510586	148.648705	156.840590	164.071622	170.729788	173.086959	174.076253	179.31159	111.942372	134.645260	143.088425	149.082720	158.346136	160.345012	159.906463	165.097687	156.196067	174.525497	192.715645	202.170747	207.784695	211.743686	206.274856	202.357613	161.0	181.960756	209.902705	223.913276	231.156769	226.368625	211.907173	207.412364	165.0	207.0	230.419644	235.642870	244.717878	242.955945	230.119987	215.492344	178.0	221.0	240.166037	244.333060	247.686972	239.381537	236.052691	221.751206	184.0	216.0	235.508231	245.929137	250.475396	252.361527	224.636676	216.557923	162.0	212.0	237.0	236.102281	234.207829	231.997909	244.172237	208.502202	152.0	198.0	221.0	213.0	204.000000	211.000000	235.000000	191.909438	143.0	205.0	213.000000	189.000000	191.000000	194.000000	198.0	180.329924	139.000000	138.000000	159.000000	145.000000	120.000000	121.000000	118.000000	116.0	149.0	143.000000	152.000000	136.000000	127.000000	138.000000	125.000000	125.0	163.0	161.0	148.0	135.0	127.0	137.0	153.0	129.0	184.000000	197.0	155.0	146.0	140.0	149.0	154.0	164.0	191.548303	229.0	200.0	176.0	169.0	166.0	169.0	171.0	170.918752	204.187970	198.068271	209.612300	219.0	208.0	202.0	179.637634	166.778567	198.125967	202.000000	196.269783	224.000000	211.0	200.665117	200.007196	146.000000	179.000000	193.363234	191.000000	192.000000	194.000000	205.00301	207.942249	127.0	185.0	204.61118	199.000000	187.000000	186.000000	194.419582	163.265832	143.0	206.798457	191.864983	216.000000	205.000000	183.417508	170.734244	152.810432	197.0	201.310672	211.385956	219.000000	192.000000	178.674548	164.541178	159.372794	204.0	211.930889	188.136017	212.000000	181.000000	171.187299	156.843985	147.468786	184.0	178.106618	179.0000	162.0	185.734839	143.181967	140.524225	137.732175	169.0	171.0	145.0	140.0	142.203812	135.413014	138.141280	123.485780	132.0	125.0	131.000000	125.073435	131.056345	136.177854	124.964418	111.995740	101.000000	109.000000	125.000000	111.154944	114.489472	112.633721	107.652456	92.454487	SEQ_000007_000004	Target	SEQ_000007	SUBJ_059520	Seated Lean Non Dom - FACE DOWN	Relaxes and moves hand to target location	Transition	Cheek - pinch skin

 

تم التعديل في بواسطة Ali Ahmed55

Recommended Posts

  • 0
نشر

المشكلة في عدم التطابق في ترتيب الأعمدة بعد تحويلها بواسطة ColumnTransformer مع ترتيب أسماء الأعمدة التي تقوم بإنشائها يدويًا، أسهل حل هو عكس ترتيب دمج قوائم الأسماء لتصبح الأعمدة الرقمية أولاً.

features_names =  numeric_features + text_features

لكن الأفضل بدلاً من إدارة ترتيب الأعمدة يدويًا، الإعتماد على scikit-learn لتوليد أسماء الأعمدة الناتجة تلقائيًا من خلال get_feature_names_out()، بالتالي ستتجنب الأخطاء في حال قمت بتغيير ترتيب المحولات فيما بعد.

    df_transformed_array = preprocessor.fit_transform(data)

    new_columns = preprocessor.get_feature_names_out()

وللعلم get_feature_names_out()  تضيف بادئات مثل num__ و text__ وبإمكانك إزالتها لو أردت كالتالي:

data_processed.columns = [col.split('__')[-1] for col in data_processed.columns]

 

  • 0
نشر

طيب هو ال انا عملو ده صح

def handle_missing_values(data, save_path):

    original_data = data.columns.tolist()

    numeric_features = data.select_dtypes(include=['number']).columns.tolist()
    text_features = data.select_dtypes(include=['object']).columns.tolist()

    preprocessor = ColumnTransformer(
        transformers=[
            ('num',IterativeImputer(),numeric_features),
            ('text', 'passthrough', text_features),
        ]
    )

    df_transformed = preprocessor.fit_transform(data)

    features_names =  text_features + numeric_features
    data = pd.DataFrame(df_transformed, columns=features_names)

    
    if save_path is not None:
        data.to_csv(save_path, index=False)

    return data[original_data]

 

انضم إلى النقاش

يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.

زائر
أجب على هذا السؤال...

×   لقد أضفت محتوى بخط أو تنسيق مختلف.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   جرى استعادة المحتوى السابق..   امسح المحرر

×   You cannot paste images directly. Upload or insert images from URL.

  • إعلانات

  • تابعنا على



×
×
  • أضف...