예측할 값 데이터를 df 컬럼의 순서대로 입력한 Numpy array 생성
생성한 데이터는 1차원 데이터, 때문에 2차원으로 변경 => reshape
인공지능 만들 때 기존에 만들었던 변수 ct에 transform() 함수를 사용해 문자열을 숫자로 변경
만들어두었던 regressor 변수에 predict() 함수를 이용해 값을 예측한다
>>> new_data = np.array([0, 1, 0, 130000, 150000, 400000])
>>> new_data = new_data.reshape(1, 6)
>>> regressor.predict(new_data)
array([165102.43212675])
# A 회사 운영비는 15만 달러, 마케팅비 40만 달러, 연구 개발비 13만 달러이고 회사 위치는 Florida
# B 회사 운영비는 11만 달러, 마케팅비 60만 달러, 연구 개발비 15만 달러이고 회사 위치는 New York
# 이 회사의 수익을 예측하세요.
>>> new_data2 = np.array([0,1,0,130000,150000,400000,0,0,1,150000,110000,600000])
>>> new_data2 = new_data2.reshape(2, 6)
>>> regressor.predict(new_data2)
array([165102.43212675, 184941.14856592])
'인공지능 > Machine Learning' 카테고리의 다른 글
[Machine Learning] 성능 측정 confusion_matrix(), accuracy_score(), classification_report() (1) | 2024.04.15 |
---|---|
[Machine Learning] 분류 예측 LogisticRegression (0) | 2024.04.15 |
[Machine Learning] LinearRegression 인공지능, 변수 파일로 저장 joblib.dump() (0) | 2024.04.15 |
[Machine Learning] LinearRegression 오차(error) 구하기 (1) | 2024.04.12 |
[Machine Learning] LinearRegression 수치 예측 (0) | 2024.04.12 |