Ali Ahmed55 نشر الثلاثاء في 21:08 أرسل تقرير نشر الثلاثاء في 21:08 السلام عليكم ده الكود col = ['D1','D2','D3','D4','D5','D6','D7','D8','D9','E1','E10','E11','E12','E13','E14', 'E15','E16','E17','E18','E19','E2','E20','E3','E4','E5','E6','E7','E8','E9','I1', 'I2','I3','I4','I5','I6','I7','I8','I9','M1','M10','M11','M12','M13','M14','M15', 'M16','M17','M18','M2','M3','M4','M5','M6','M7','M8','M9','P1','P10','P11','P12', 'P13','P2','P3','P4','P5','P6','P7','P8','P9','S1','S10','S11','S12','S2','S3', 'S4','S5','S6','S7','S8','S9','V1','V10','V11','V12','V13','V2','V3','V4','V5', 'V6','V7','V8','V9','is_scored','lagged_risk_free_rate', 'lagged_market_forward_excess_returns'] model = tf.keras.models.load_model('AlphaPulse.keras') def predict(test: pd.DataFrame) -> float: df = test df_copy = data_test_copy x_test = df[col] preds = model.predict(x_test) allocation = preds.clip(0, 2).reshape(-1) return pd.DataFrame({"date_id": df_copy["date_id"].values,"prediction": allocation}) inference_server = kaggle_evaluation.default_inference_server.DefaultInferenceServer(predict) if os.getenv('KAGGLE_IS_COMPETITION_RERUN'): inference_server.serve() else: inference_server.run_local_gateway(('/kaggle/input/hull-tactical-market-prediction/',)) ودي المشكله الناتج عن الكود ده --------------------------------------------------------------------------- GatewayRuntimeError Traceback (most recent call last) /tmp/ipykernel_39/3513852296.py in <cell line: 0>() 38 inference_server.serve() 39 else: ---> 40 inference_server.run_local_gateway(('/kaggle/input/hull-tactical-market-prediction/',)) /kaggle/input/hull-tactical-market-prediction/kaggle_evaluation/core/templates.py in run_local_gateway(self, data_paths, file_share_dir, *args, **kwargs) 106 self.gateway.run() 107 except Exception as err: --> 108 raise err from None 109 finally: 110 self.server.stop(0) /kaggle/input/hull-tactical-market-prediction/kaggle_evaluation/core/templates.py in run_local_gateway(self, data_paths, file_share_dir, *args, **kwargs) 104 try: 105 self.gateway = self._get_gateway_for_test(data_paths, file_share_dir, *args, **kwargs) --> 106 self.gateway.run() 107 except Exception as err: 108 raise err from None /kaggle/input/hull-tactical-market-prediction/kaggle_evaluation/core/base_gateway.py in run(self) 149 elif error: 150 # For local testing --> 151 raise error 152 153 @final /kaggle/input/hull-tactical-market-prediction/kaggle_evaluation/core/base_gateway.py in run(self) 130 try: 131 self.unpack_data_paths() --> 132 predictions, row_ids = self.get_all_predictions() 133 self.write_submission(predictions, row_ids) 134 except GatewayRuntimeError as gre: /kaggle/input/hull-tactical-market-prediction/kaggle_evaluation/core/base_gateway.py in get_all_predictions(self) 106 self.data_batch_counter = 0 107 for data_batch, row_ids in self.generate_data_batches(): --> 108 predictions = self.predict(*data_batch) 109 self.competition_agnostic_validation(predictions, row_ids) 110 self.competition_specific_validation(predictions, row_ids, data_batch) /kaggle/input/hull-tactical-market-prediction/kaggle_evaluation/core/base_gateway.py in predict(self, *args, **kwargs) 124 return self.client.send('predict', *args, **kwargs) 125 except Exception as e: --> 126 self.handle_server_error(e, 'predict') 127 128 def run(self) -> None: /kaggle/input/hull-tactical-market-prediction/kaggle_evaluation/core/base_gateway.py in handle_server_error(self, exception, endpoint) 429 message_match = re.search('"Exception calling application: (.*)"', exception_str, re.IGNORECASE) 430 message = message_match.group(1) if message_match else exception_str --> 431 raise GatewayRuntimeError(GatewayRuntimeErrorType.SERVER_RAISED_EXCEPTION, message) from None 432 if isinstance(exception, grpc._channel._InactiveRpcError): 433 raise GatewayRuntimeError(GatewayRuntimeErrorType.SERVER_CONNECTION_FAILED, exception_str) from None GatewayRuntimeError: (<GatewayRuntimeErrorType.SERVER_RAISED_EXCEPTION: 3>, 'All arrays must be of the same length') 1 اقتباس
0 Mustafa Suleiman نشر أمس الساعة 13:23 أرسل تقرير نشر أمس الساعة 13:23 لديك مشكلة في عدم تطابق طول البيانات عند إنشاء إطار البيانات النهائي، بسبب استخدام متغير غير معرف data_test_copy بدلاً من استخدام نفس إطار البيانات الذي يحتوي على الميزات أي استخدم df أو test لاستخراج date_id وليس data_test_copy. أيضًا الدالة حددت لها بأن تُعيد float لكن النتيجة هي pd.DataFrame، يجب تصحيح ذلك إلى pd.DataFrame import pandas as pd import tensorflow as tf import kaggle_evaluation import os col = ['D1','D2','D3','D4','D5','D6','D7','D8','D9','E1','E10','E11','E12','E13','E14', 'E15','E16','E17','E18','E19','E2','E20','E3','E4','E5','E6','E7','E8','E9','I1', 'I2','I3','I4','I5','I6','I7','I8','I9','M1','M10','M11','M12','M13','M14','M15', 'M16','M17','M18','M2','M3','M4','M5','M6','M7','M8','M9','P1','P10','P11','P12', 'P13','P2','P3','P4','P5','P6','P7','P8','P9','S1','S10','S11','S12','S2','S3', 'S4','S5','S6','S7','S8','S9','V1','V10','V11','V12','V13','V2','V3','V4','V5', 'V6','V7','V8','V9','is_scored','lagged_risk_free_rate', 'lagged_market_forward_excess_returns'] model_path = 'AlphaPulse.keras' if not os.path.exists(model_path): model_path = '/kaggle/working/AlphaPulse.keras' model = tf.keras.models.load_model(model_path) def predict(test: pd.DataFrame) -> pd.DataFrame: df = test.copy() missing_cols = set(col) - set(df.columns) if missing_cols: raise ValueError(f"missing columns: {missing_cols}") x_test = df[col] preds = model.predict(x_test, verbose=0) allocation = preds.clip(0, 2).reshape(-1) if len(allocation) != len(df): raise ValueError(f"prediction length ({len(allocation)}) doesn't match data length ({len(df)})") return pd.DataFrame({ "date_id": df["date_id"].values, "prediction": allocation }) inference_server = kaggle_evaluation.default_inference_server.DefaultInferenceServer(predict) if os.getenv('KAGGLE_IS_COMPETITION_RERUN'): inference_server.serve() else: inference_server.run_local_gateway(('/kaggle/input/hull-tactical-market-prediction/',)) 1 اقتباس
0 Ali Ahmed55 نشر منذ 22 ساعة الكاتب أرسل تقرير نشر منذ 22 ساعة بتاريخ 2 ساعة قال Mustafa Suleiman: لديك مشكلة في عدم تطابق طول البيانات عند إنشاء إطار البيانات النهائي، بسبب استخدام متغير غير معرف data_test_copy بدلاً من استخدام نفس إطار البيانات الذي يحتوي على الميزات أي استخدم df أو test لاستخراج date_id وليس data_test_copy. ايوه بس اطار البيانات ده انا مسح منو العمود ده في بيانات التدريب وكمان الاختبار عشان كده عملت copy البيانات ؟ 1 اقتباس
0 Mustafa Suleiman نشر منذ 22 ساعة أرسل تقرير نشر منذ 22 ساعة حذفت date_id من test نفسه؟ إذن يجب تمرير إطار بيانات يحتوي على date_id. import pandas as pd import tensorflow as tf import kaggle_evaluation import os col = ['D1','D2','D3','D4','D5','D6','D7','D8','D9','E1','E10','E11','E12','E13','E14', 'E15','E16','E17','E18','E19','E2','E20','E3','E4','E5','E6','E7','E8','E9','I1', 'I2','I3','I4','I5','I6','I7','I8','I9','M1','M10','M11','M12','M13','M14','M15', 'M16','M17','M18','M2','M3','M4','M5','M6','M7','M8','M9','P1','P10','P11','P12', 'P13','P2','P3','P4','P5','P6','P7','P8','P9','S1','S10','S11','S12','S2','S3', 'S4','S5','S6','S7','S8','S9','V1','V10','V11','V12','V13','V2','V3','V4','V5', 'V6','V7','V8','V9','is_scored','lagged_risk_free_rate', 'lagged_market_forward_excess_returns'] model_path = 'AlphaPulse.keras' if not os.path.exists(model_path): model_path = '/kaggle/working/AlphaPulse.keras' model = tf.keras.models.load_model(model_path) def predict(test: pd.DataFrame, test_with_dates: pd.DataFrame) -> pd.DataFrame: df = test.copy() x_test = df[col] preds = model.predict(x_test, verbose=0) allocation = preds.clip(0, 2).reshape(-1) return pd.DataFrame({ "date_id": test_with_dates["date_id"].values, "prediction": allocation }) inference_server = kaggle_evaluation.default_inference_server.DefaultInferenceServer(predict) if os.getenv('KAGGLE_IS_COMPETITION_RERUN'): inference_server.serve() else: inference_server.run_local_gateway(('/kaggle/input/hull-tactical-market-prediction/',)) 1 اقتباس
0 Ali Ahmed55 نشر منذ 22 ساعة الكاتب أرسل تقرير نشر منذ 22 ساعة بس بتحصل بقا المشكله دي /kaggle/input/hull-tactical-market-prediction/kaggle_evaluation/core/templates.py:95: RuntimeWarning: 1889 seconds elapsed before server startup. This exceeds the startup time limit of 900 seconds that the gateway will enforce during the rerun on the hidden test set. Start the server before performing any time consuming steps. warnings.warn( --------------------------------------------------------------------------- GatewayRuntimeError Traceback (most recent call last) /tmp/ipykernel_39/2380296845.py in <cell line: 0>() 38 inference_server.serve() 39 else: ---> 40 inference_server.run_local_gateway(('/kaggle/input/hull-tactical-market-prediction/',)) /kaggle/input/hull-tactical-market-prediction/kaggle_evaluation/core/templates.py in run_local_gateway(self, data_paths, file_share_dir, *args, **kwargs) 106 self.gateway.run() 107 except Exception as err: --> 108 raise err from None 109 finally: 110 self.server.stop(0) /kaggle/input/hull-tactical-market-prediction/kaggle_evaluation/core/templates.py in run_local_gateway(self, data_paths, file_share_dir, *args, **kwargs) 104 try: 105 self.gateway = self._get_gateway_for_test(data_paths, file_share_dir, *args, **kwargs) --> 106 self.gateway.run() 107 except Exception as err: 108 raise err from None /kaggle/input/hull-tactical-market-prediction/kaggle_evaluation/core/base_gateway.py in run(self) 149 elif error: 150 # For local testing --> 151 raise error 152 153 @final /kaggle/input/hull-tactical-market-prediction/kaggle_evaluation/core/base_gateway.py in run(self) 130 try: 131 self.unpack_data_paths() --> 132 predictions, row_ids = self.get_all_predictions() 133 self.write_submission(predictions, row_ids) 134 except GatewayRuntimeError as gre: /kaggle/input/hull-tactical-market-prediction/kaggle_evaluation/core/base_gateway.py in get_all_predictions(self) 106 self.data_batch_counter = 0 107 for data_batch, row_ids in self.generate_data_batches(): --> 108 predictions = self.predict(*data_batch) 109 self.competition_agnostic_validation(predictions, row_ids) 110 self.competition_specific_validation(predictions, row_ids, data_batch) /kaggle/input/hull-tactical-market-prediction/kaggle_evaluation/core/base_gateway.py in predict(self, *args, **kwargs) 124 return self.client.send('predict', *args, **kwargs) 125 except Exception as e: --> 126 self.handle_server_error(e, 'predict') 127 128 def run(self) -> None: /kaggle/input/hull-tactical-market-prediction/kaggle_evaluation/core/base_gateway.py in handle_server_error(self, exception, endpoint) 429 message_match = re.search('"Exception calling application: (.*)"', exception_str, re.IGNORECASE) 430 message = message_match.group(1) if message_match else exception_str --> 431 raise GatewayRuntimeError(GatewayRuntimeErrorType.SERVER_RAISED_EXCEPTION, message) from None 432 if isinstance(exception, grpc._channel._InactiveRpcError): 433 raise GatewayRuntimeError(GatewayRuntimeErrorType.SERVER_CONNECTION_FAILED, exception_str) from None GatewayRuntimeError: (<GatewayRuntimeErrorType.SERVER_RAISED_EXCEPTION: 3>, "predict() missing 1 required positional argument: 'test_with_dates'") اقتباس
السؤال
Ali Ahmed55
السلام عليكم
ده الكود
ودي المشكله الناتج عن الكود ده
4 أجوبة على هذا السؤال
Recommended Posts
انضم إلى النقاش
يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.