안녕하세요 테스트 코드 사용 중 오류가 잡히지 않아서 문의 드립니다. 강의에서 설명해주신 것처럼 아래와 같이 코드를 작성했지만 오류가 발생합니다. 어떻게 해야 할까요? from fastapi.testclient import TestClient from main import app # api들이 있는 app을 검증할 클라이언트 생성 client = TestClient(app=app) def test_health_check(): # api 요청 response = client.get("/") # 반환 값 검증 assert response.status_code == 200 assert response.json() == {"ping": "pong"} 아래는 오류 내용 입니다. (fastapi_orm) C:\Users\User\Desktop\Fast_API(ORM)\code\src>pytest ============================================================================= test session starts ============================================================================= platform win32 -- Python 3.10.16, pytest-8.3.5, pluggy-1.5.0 rootdir: C:\Users\User\Desktop\Fast_API(ORM)\code\src plugins: anyio-4.8.0 collected 0 items / 1 error =================================================================================== ERRORS ==================================================================================== _____________________________________________________________________ ERROR collecting tests/test_main.py _____________________________________________________________________ tests\test_main.py:5: in <module> client = TestClient(app) ..\..\..\..\anaconda3\envs\fastapi_orm\lib\site-packages\starlette\testclient.py:399: in __init__ super().__init__( E TypeError: Client.__init__() got an unexpected keyword argument 'app' =========================================================================== short test summary info =========================================================================== ERROR tests/test_main.py - TypeError: Client.__init__() got an unexpected keyword argument 'app' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ============================================================================== 1 error in 0.86s ===============
학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! 질문과 관련된 영상 위치를 알려주면 더 빠르게 답변할 수 있어요 먼저 유사한 질문이 있었는지 검색해보세요 모델링및평가(분류) 17:30초 지점에서 검증용 데이터 분리를 설명하기에 앞서 그 위에 문제2가 있는데 문제2가 검증용 데이터분리와 연관되나요. 즉, 검증용 데이터분리는 문제1에 연장인지 문제2에 해당하는지를 묻습니다.
미리 문자로 정의한 내용들이 다 정의되지 않는다고 뜨네요 아래처럼요! 수업자료와 함께 답변 부탁드립니다 ㅠ dpdltmee@gmail.com [디버깅시 오류 내용 ] NameError: name 'ex1' is not defined >>> print(ex2) Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'ex2' is not defined >>> print(ex3) [입력 함수] x = 50 y = 100 text = 308276567 n = 'Lee' #출력1 ex1 = 'n = %s, s = %s, sum=%d' % (n, text, (x + y)) #%는 찰 쓰지 않는다 print(ex1) #출력2 ex2 = 'n = {n}, s = {s}, sum={sum}'.format(n=n, s=text, sum=x+y) print(ex2)
안녕하세요? 좋은 강의 감사 드립니다. 처음 장고 프로젝트를 만들었는데, first 폴더를 만들어 놓았는데 폴더 안에 admin.py, apps.py 등등의 파일이 있는데 파일을 더블클릭을 해서 소스를 보았는데 admin.py 파일 같은 경우에는 from django.contrib import admin 문장이 있는데 django 글자와 admin 글자에 빨간줄이 나타납니다. 답변 부탁 드립니다. 감사합니다.
안녕하세요! 강사님! 처음으로 fastAPI를 접하는데 강사님 수업을 통해 배움을 얻어 가게되어 우선 감사 말씀드립니다. DB Connect 세팅 시 create_engine 함수를 이용하여 엔진 객체만 생성하여 DB에 연결을 하는데 다른 참고 자료들과 비교하면 모델 클래스 생성은 ORM을 사용하지 않으니 생성을 할필요가 없을테고, sessionmaker 함수를 통한 세션 클래스는 따로 생성하지 않더군요. 혹시 sessionmake를 통해 생성된 세션 클래스의 역할과 지금 강의에서는 사용하지 않은 이유를 알 수 있을까요?
sqlalchemy.exc.InvalidRequestError: When initializing mapper Mapper[ScheduleEntity(schedules)], expression 'CountryEntity' failed to locate a name ('CountryEntity'). If this is a class name, consider adding this relationship() to the <class 'src.models.schedule.ScheduleEntity'> class after both dependent classes have been defined. cities = relationship("src.models.city.CityEntity", back_populates="country", cascade="all, delete-orphan", lazy="joined") schedules = relationship("src.models.schedule.ScheduleEntity", back_populates="country", cascade="all, delete-orphan", lazy="joined") 이미 이렇게 다 해놨는데 말이죠...
XGBClassifier 를 사용해서 target을 분류하려고 하는데, 아래와 같은 에러가 나타납니다 : ValueError : Invalid classes inferred from unique values of y . Expected: [0 1 2 3], got [1 2 3 4] LabelEncoder를 사용해서 processing 도 다 했고, LGBMClassifier랑 RandomForestClassifier는 다 잘 돌아가는데 XGBClassifier만 저런 오류가 나타나네요;;; 참고를 위해 지금까지 작성한 코드 하기로 공유 드립니다 : import pandas as pd train=pd.read_csv('train.csv') test=pd.read_csv('test.csv') train=train.drop('ID', axis=1) test_id=test.pop('ID') print(train.shape, test.shape) print(train.head()) print(test.head()) print(train.info()) print(test.info()) print(train.isnull().sum()) print(test.isnull().sum()) y=train.pop('Segmentation') y=y.astype('object') y=y.astype('category') print(y.info(), y.shape) int_cols=train.select_dtypes(exclude='object').columns train[int_cols].corr() cat_cols=train.select_dtypes(include='object').columns print(train[cat_cols].describe(include='object')) print(test[cat_cols].describe(include='object')) for i in cat_cols: train[i]=train[i].astype('object') test[i]=test[i].astype('object') for i in cat_cols: print(train[i].value_counts()) print(test[i].value_counts()) from sklearn.preprocessing import RobustScaler scaler=RobustScaler() for i in int_cols : train[i]=scaler.fit_transform(train[[i]]) test[i]=scaler.transform(test[[i]]) from sklearn.preprocessing import LabelEncoder le=LabelEncoder() for i in cat_cols: train[i]=le.fit_transform(train[i]) test[i]=le.transform(test[i]) print(train.head()) print(test.head()) from sklearn.model_selection import train_test_split X_tr, X_val, y_tr, y_val=train_test_split(train, y, test_size=0.2, random_state=2025) print(X_tr.shape, X_val.shape, y_tr.shape, y_val.shape) y_val=y_val.astype('category') y_tr=y_tr.astype('category') from sklearn.ensemble import RandomForestClassifier rf=RandomForestClassifier(n_estimators=100, max_depth=5, random_state=2025) rf.fit(X_tr, y_tr) y_pred_rf=rf.predict(X_val) from lightgbm import LGBMClassifier lgbm=LGBMClassifier() lgbm.fit(X_tr, y_tr) y_pred_lgbm=lgbm.predict(X_val) from sklearn.metrics import f1_score print(f1_score(y_val, y_pred_rf, average='weighted')) print(f1_score(y_val, y_pred_lgbm, average='weighted')) from xgboost import XGBClassifier xgb=XGBClassifier() xgb.fit(X_tr, y_tr) y_pred_xgb=xgb.predict(X_val)
모두를 위한 파이썬 : 필수 문법 배우기 Feat. 오픈소스 패키지 배포 (Inflearn Original)
_ 를 변수에 사용하는데 있어 질문이 있습니다. 'Property(1) - Underscore' 강의에서 _가 하나를 사용할때는 PROTECTED 변수로, 상속받는 하위 클래스에 이용한다고 하셨습니다. 강사님의 다른 Python 강의에서 (정확히 어느 강의 인지는 기억이 안나네요) 가 붙은 변수를 클래스 변수로 사용하셨거든요. 혹시 두 의미가 상충되는것일까요 아니면 를 하나 사용할때는 두가지 경우 모두 사용가능할까요?
안녕하세요 강사님! 강사님의 강의를 듣고 현재 yolo를 이용해 간단한 프로젝트를 하나 진행해보려고 하는데 몇가지 질문 사항이 생겨 글을 적습니다. 전체적인 프로젝트 개요는 식물앞에 카메라를 두고 식물에 해충 및 질병 발생을 detect하는 모델을 만드려고 합니다. 이때 카메라에 라즈베리파이 같은 소형 컴퓨터를 달아 모델을 운용하려는 계획이라 yolo의 높은 버전보다 yolo v5 간소화 버전들을 사용해야 겠다고 결정했는데 괜찮은 선택인지 궁금합니다. 해충과 식물의 질병 부위 이미지 데이터셋으로 모델을 학습 시키려고 하는데 이때 coco dataset으로 pretrained된 모델을 사용해야 하는지 아니면 모델 구성부터 새로 한 후 원하는 해충/질병 이미지만 학습 시켜야 하는건지 궁금합니다. 감사합니다!!