제2유형에서 시작전에 train.info() test.info()하잖아요. 이후에 타입유형(int / float /object) 을 확인 한 후에 어떤 부분을 바꿔줘야하는건가요? 어차피 원핫인코딩 pd.get_dummies와 train, test = train.align(test, join ='left', axis=1, fill_value=0) 해주면 어느정도 형식이 정리되는거 아닌가요? 별도로 처리해줘야 할 게있는지 문의드립니다.
import pandas as pd from statsmodels.formula.api import logit from sklearn.metrics import accuracy_score # 1. 로지스틱 회귀 모델 적합 (test로 직접 학습 — 실전에서는 train 사용 권장) model = logit('target ~ age + sex + cp + trestbps + chol + fbs + restecg + thalach + exang + oldpeak + slope + ca + thal', data=test).fit() # 2. 예측 수행 (test 그대로 사용) pred_probs = model.predict(test) pred = (pred_probs > 0.5).astype(int) # 3. 정확도 → 오류율 계산 error_rate = 1 - accuracy_score(test['target'], pred) print(f'오류율: {error_rate:.4f}') Optimization terminated successfully. Current function value: 0.310865 Iterations 8 오류율: 0.1034 # model = logit('target~age+sex+cp+trestbps+chol+fbs+restecg+thalach+exang+oldpeak+slope+ca+thal',test).fit() import statsmodels.api as sm X2 = test.drop(columns = ['target']) X2 = sm.add_constant(X2) pred = model.predict(X2) pred = (pred>0.5).astype(int) pred from sklearn.metrics import accuracy_score 1-accuracy_score(test['target'],pred) 0.1954022988505747 문제는 test데이터의 독립변수로 target 예측 후 오류율을 구하여라 입니다. 근데 로짓이랑 sm이랑 차이가 좀 심하게 나는데 원래 로지스틱 회귀분석할때 sm으로 해야하나요..?
아래와 같이 train과 test를 합해서 스케일링과 인코딩을 모두 진행할 경우, 각각 진행하는 것과 차이가 있나요? 그리고 스케일링과 인코딩에 추천하는 함수가 있으신가요? df= pd.concat([x_train, x_test], axis=0) num = df.select _dtypes(exclude='object').columns from sklearn.preprocessing import RobustScaler scaler = RobustScaler() df[num] = scaler.fit _transform(df[num]) objs = df.select _dtypes(include='object').columns from sklearn.preprocessing import LabelEncoder for obj in objs : encoder = LabelEncoder() df[obj] = encoder.fit _transform(df[obj]) x_train2 = df[:len(x_train)] x_test2 = df[len(x_train):]
학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! 질문과 관련된 영상 위치를 알려주면 더 빠르게 답변할 수 있어요 먼저 유사한 질문이 있었는지 검색해보세요 아래처럼 코드 짜도 되는지? m = df.loc[2000] > df.loc[2000].mean() print(sum(m))
따라하기로 강의를 수강중에 있습니다. 강의 환경을 구성하려고 하는데, ova 등 관련링크가 모두 옛날자료라서 유효하지가 않아 다운로드가 불가능합니다. 보유하고 있는 파일 공유 또는 다운로드 사이트를 업데이트 하면 좋을것 같습니다. 강의 내용 구성이 좋아서 끝까지 수강해야 하는데, 중간에 관련자료 확보 불가로 따라하기가 어려워 수강에 어려움을 겪고 있습니다. 이점 충분히 검토 바랍니다.
Junit4 org.junt.Test 어노테이션을 사용하면 작동하지 않는 것 같습니다. 아래는 에러입니다. No matching tests found in any candidate test task. Requested tests: Test pattern jpabook.jpashop.service.MemberServiceTest in task :test * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. > Get more help at https://help.gradle.org. Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0. You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins. For more on this, please refer to https://docs.gradle.org/8.11.1/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation. BUILD FAILED in 493ms 5 actionable tasks: 1 executed, 4 up-to-date
학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! 질문과 관련된 영상 위치를 알려주면 더 빠르게 답변할 수 있어요 먼저 유사한 질문이 있었는지 검색해보세요 실기체험하는대서 아래처럼 쓰고 실행했더니 import pandas as pd df = pd.DataFrame({ '키': [150, 160, 170, 175, 165, 155, 172, 168, 174, 158, 162, 173, 156, 159, 167, 163, 171, 169, 176, 161], '몸무게': [74, 50, 70, 64, 56, 48, 68, 60, 65, 52, 54, 67, 49, 51, 58, 55, 69, 61, 66, 53] }) from statsmodels.formula.api import ols model = ols('키 ~ 몸무게', data=df).fit() print(model.summary()) 아래처럼 나오는데, 왜 그런건가요? Notes: [1] Standard Errors assume that the covariance matrix of the errors is correctly specified.
37강 5분 11초에서 "처음에는 null로 되어있지만 값을 한 번 세팅할 수 있게 해주고 싶다."라고 하셨는데 처음부터 null을 할당하지 않으면 lateinit을 사용 안 할 수도 있는 거 아닌가요? 테스트코드에 대한 이해가 하나도 없어서 고른 강의인지라 질문의 깊이가 너무 없지만 답변주시면 감사합니다!!
학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! 질문과 관련된 영상 위치를 알려주면 더 빠르게 답변할 수 있어요 먼저 유사한 질문이 있었는지 검색해보세요 아래 예시로 적혀있는 코드들도 시험 때 주어지는지 아니면 암기해야하는지 문의드립니다. from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score, roc_auc_score # 정확도 print(accuracy_score(y_test, pred)) # 정밀도 print(precision_score(y_test, pred)) # 재현율 (민감도) print(recall_score(y_test, pred)) # F1 print(f1_score(y_test , pred)) # roc-auc print(roc_auc_score(y_test, pred_proba))
해당 코드의 실패 예시가 결과 값이 5 999999999 1000000000 가 출력 되야 되는데 5만 출력 됩니다. 위의 코드에서 flist, slist를 ArrayList로 선언 했는데 이를 int[]로 변경 후 동작을 하면 정상적으로 동작이 됩니다. int[]로 선언 했을 때랑 ArrayList로 선언 했을때 차이가 있는건지 제가 while문안에 비교를 잘못한건지 모르겠어서 질문드립니다..