위의 코드를 그대로 입력하고 baseline 코드까지 문제가 없다가 label에서 다음과 같은 에러가 발생했습니다. KeyError Traceback (most recent call last) /usr/local/lib/python3.10/dist-packages/pandas/core/indexes/base.py in get_loc(self, key) 3804 try: -> 3805 return self._engine.get_loc(casted_key) 3806 except KeyError as err: index.pyx in pandas._libs.index.IndexEngine.get_loc() index.pyx in pandas._libs.index.IndexEngine.get_loc() pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item() pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item() KeyError: 'Gender' The above exception was the direct cause of the following exception: 아래는 입력한 코드입니다. 어떤 부분이 문제일까요? ㅠㅠ #label from sklearn.preprocessing import LabelEncoder for col in cols : le = LabelEncoder() train[col] = le.fit_transform(train[col]) test[col] = le.transform(test[col]) train[cols].head()
안녕하세요. dir 이나 __all 관련해서,,, print(sklearn.__all__) 은 알겠는데요. 그 다음,,, from sklearn.ensemble import RandomForestClassifier 여기서,, randaomforestclassifier 이게 생각이 나지 않을때 이걸 찾을 수 있는 방법은 없는지요?
안녕하세요, 작업형3을 공부하던 중 궁금한 점이 생겨 문의드립니다. 어떤 상황에서 T검정, 카이제곱 검정, 회귀분석, 분산분석(ANOVA)를 수행하는건지 명확히 분류가 잘 안 되는데 위와 같이 T검정, 카이제곱 검정, 회귀분석, 분산분석 중 어떤 것을 수행할지는 문제에서 주어지는 사항일까요? 감사합니다!
안녕하세요. 저는 전공자고, 자바는 학교에서 배운 상태입니다. 백엔드 공부하려고 김영한 선생님 로드맵 따라가고 있고, 현재 스프링 입문 강의까지 맞춘 상태입니다. 스프링에 처음 접하는데 스프링 입문 강의를 듣고 기능적인 부분은 대충 이해를 하였는데, 문법적인 것들은 처음 접해서 어려움을 느끼고 있습니다. 혹시 스프링에 대해 따로 공부하고 로드맵을 진행해야 할까요? 아니면 따로 스프링 공부 없이 로드맵을 따라가도 괜찮을까요..?
train = pd.read_csv('/kaggle/input/working8-2/churn_train.csv') test = pd.read_csv('/kaggle/input/working8-2/churn_test.csv') target = train.pop('TotalCharges') train = pd.get_dummies(train) test = pd.get_dummies(test) from sklearn.model_selection import train_test_split X_tr,X_val,y_tr,y_val = train_test_split(train, target, test_size=0.2, random_state=2022) from sklearn.metrics import mean_absolute_error from sklearn.ensemble import RandomForestRegressor rf = RandomForestRegressor(random_state=2022, max_depth=7, n_estimators=600) rf.fit(X_tr,y_tr) pred = rf.predict(X_val) answer = rf.predict(test) rf.predict(X_val)까지는 잘 예측이 되어, 866.4986350062683의 값을 얻었습니다. 그리하여 마지막으로 본 test파일을 예측하여 제출하려고 하는데, 계속해서 오류가 발생하네요 ㅠㅠㅠ 아래는 에러 코드입니다. ValueError Traceback (most recent call last) Cell In[97], line 14 12 rf.fit(X_tr,y_tr) 13 pred = rf.predict(X_val) ---> 14 answer = rf.predict(test) File /opt/conda/lib/python3.10/site-packages/sklearn/ensemble/_forest.py:981, in ForestRegressor.predict(self, X) 979 check_is_fitted(self) 980 # Check data --> 981 X = self._validate_X_predict(X) 983 # Assign chunk of trees to jobs 984 n_jobs, _, _ = _partition_estimators(self.n_estimators, self.n_jobs) File /opt/conda/lib/python3.10/site-packages/sklearn/ensemble/_forest.py:602, in BaseForest._validate_X_predict(self, X) 599 """ 600 Validate X whenever one tries to predict, apply, predict_proba.""" 601 check_is_fitted(self) --> 602 X = self._validate_data(X, dtype=DTYPE, accept_sparse="csr", reset=False) 603 if issparse(X) and (X.indices.dtype != np.intc or X.indptr.dtype != np.intc): 604 raise ValueError("No support for np.int64 index based sparse matrices") File /opt/conda/lib/python3.10/site-packages/sklearn/base.py:548, in BaseEstimator._validate_data(self, X, y, reset, validate_separately, **check_params) 483 def _validate_data( 484 self, 485 X="no_validation", (...) 489 **check_params, 490 ): 491 """Validate input data and set or check the `n_features_in_` attribute. 492 493 Parameters (...) 546 validated. 547 """ --> 548 self._check_feature_names(X, reset=reset) 550 if y is None and self._get_tags()["requires_y"]: 551 raise ValueError( 552 f"This {self.__class__.__name__} estimator " 553 "requires y to be passed, but the target y is None." 554 ) File /opt/conda/lib/python3.10/site-packages/sklearn/base.py:481, in BaseEstimator._check_feature_names(self, X, reset) 476 if not missing_names and not unexpected_names: 477 message += ( 478 "Feature names must be in the same order as they were in fit.\n" 479 ) --> 481 raise ValueError(message) ValueError: The feature names should match those that were passed during fit. Feature names unseen at fit time: - customerID_CUST0001 - customerID_CUST0002 - customerID_CUST0006 - customerID_CUST0007 - customerID_CUST0008 - ... Feature names seen at fit time, yet now missing: - customerID_CUST0000 - customerID_CUST0003 - customerID_CUST0004 - customerID_CUST0005 - customerID_CUST0009 - ...
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요. 1. 강의 내용과 관련된 질문을 남겨주세요. 2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요. (자주 하는 질문 링크: https://bit.ly/3fX6ygx) 3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요. (질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG) 질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요. ========================================= [질문 템플릿] 1. 강의 내용과 관련된 질문인가요? (예) 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가 요? (예) transacional어노테이션을 추가했는데 빨간불이 나오느데 어떻게 해야하나요? 3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오) [질문 내용] 여기에 질문 내용을 남겨주세요.
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요. 1. 강의 내용과 관련된 질문을 남겨주세요. 2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요. (자주 하는 질문 링크: https://bit.ly/3fX6ygx) 3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요. (질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG) 질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요. ========================================= [질문 템플릿] 1. 강의 내용과 관련된 질문인가요? (예/아니오) 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오) 3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오) [질문 내용] 안녕하세요. entry에 대해서, 뭔가 꺼림직한게 있어서 질문을 드립니다. entry에 대해서 더 자세히 설명해 주실 수 있으신가요? entry가 key와 value의 집합 이라고 이해가 되는데? 뭔가 애매해서 질문을 드립니다. 꺼림직하고 애매한데, 어떻게 설명해야 할지 어렵네요. 그래서 그냥 저가 느낌(생각) 그대로 질문을 올리는것입니다. 답변 부탁 드립니다.
>> views 컬럼에 결측치가 있는 데이터(행)을 삭제하고, f3 컬럼의 결측치는 0, silver는 1, gold는 2, vip는 3 으로 변환한 후 총 합을 정수형으로 출력하시오<< 이 문제를 풀이할 때, 강사님이 말씀해주신 것처럼 문제를 풀었는데 답 밑에 이런 문구들이 표기됩니다. 133 <ipython-input-34-9be3d2c84afd>:11: FutureWarning: Downcasting behavior in `replace` is deprecated and will be removed in a future version. To retain the old behavior, explicitly call `result.infer_objects(copy=False)`. To opt-in to the future behavior, set `pd.set_option('future.no_silent_downcasting', True)` df['f3'] = df['f3'].replace('silver',1).replace('gold',2).replace('vip',3) 이렇게 표기되어도 정답 인정은 되는 것인지 궁금합니다.
학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! 질문과 관련된 영상 위치를 알려주면 더 빠르게 답변할 수 있어요 먼저 유사한 질문이 있었는지 검색해보세요 안녕하세요! 열심히 한강의씩 듣고있는 수강생입니다. 항상 너무 자세히 설명도 너무 잘 해주셔서 감사합니다. 일원분산분석 수강중 melt를 진행하고 이렇게 나온것까지는 이해가 됐습니다! 혹시 분산분석테이블에서 ols를 할 때 종속, 독립을 넣어야하는데 어떻게 구분해야할지가 문득 궁금해져서 질문을 남기게 되었습니다..! 보통은 맨 우측에있는 부분을 종속변수로 알면 될까요?
#text= text.replace("파이썬", "머신러닝").replace("분석기사", "분석을 위한") 에서 여러단어 변경 시 유의사항으로 앞에서 부터 실행돼서 파이썬부터 머신러닝으로 바꿔야 한다고 말씀하셨는데 앞에서 부터 실행되면 분석기사부터 바꿔야되는 거 아닌가요? 왜냐면 text = 빅데이터 분석기사 파이썬 공부 순이라서. 앞에서 부터 실행된다는게 분석기사부터 바뀌는게 아닌가 하는 생각이 들어서 여쭤봅니다. #text= text.replace("분석기사", "분석을 위한").replace("파이썬", "머신러닝") 으로 바꿔서 실행해보니 '빅데이터 분석을 위한 머신러닝 공부' 라는 값이 도출됩니다.
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. 여기에서 public static void main(String[] args) { Scanner in = new Scanner(System.in); String input1 = in.nextLine(); Integer size = Integer.valueOf(input1); int[][] input2 = new int[Integer.valueOf(input1) ][Integer.valueOf(input1) ]; for (int i = 0; i < Integer.valueOf(input1); i++) { String[] temp = in.nextLine().split(" "); for (int j = 0; j < temp.length; j++) { input2[i ][j] = Integer.valueOf(temp[j]); } } int[] count = new int[size]; // 학생 번호 -> [V][] // 학년 -> [][V] // 자기자신 번호를 추가해도 문제X for (int i = 0; i < size; i++) { boolean[] matched = new boolean[size]; // 학년 for (int j = 0; j < size; j++) { int now = input2[i][j]; // 학생 for (int k = 0; k < size; k++) { int another = input2[k][j]; if (now == another){ matched[k] = true; } } } int matchedCount = 0; for (int j = 0; j < size; j++) { if (matched[j]){ matchedCount++; } } count[i] = matchedCount; } int max = 0; int maxStu = 0; for (int i = 0; i < size; i++) { if (count[i] > max){ maxStu = i; } } System.out.println(maxStu); } 어차피 자기자신은 항상 포함되어 기본값이 1이게될텐데, boolean[] matched = new boolean[size]; 에서 체크하는걸로 처리하였습니다. 이접근법이 틀린이유를 모르겠습니다. 1. 자기자신을 같이처리 (기본카운트는 항상 1부터) 2. 리스트에 매치된 학생들을 계산 후 마지막에 더함
이유는 모르겠습니다만 제 컴퓨터에서는 DELIMITER 로 지정한 문자 "|" 가 split 메서드에서 작동하지 않더라구요. window를 사용하는데 그 때문인지는 모르겠습니다. 그래서 저는 DELIMITER = "\\|" 로 지정해 동작시켰습니다. 강사님과 split 메서드가 다르게 작동하는 이유는 뭘까요?