두뇌와 몸무게에 대한 정보를 담고있는 훈련 및 테스트 데이터 세트가 있습니다. 훈련 데이터 세트를 통해 학습 한 후 테스트 데이터 세트에서 체중이 주어지면 테스트 데이터 세트의 뇌 체중을 예측합니다. 나는 linear regression
을 완료했으나 데이터가 원활하게 분배되지 않았기 때문에 데이터가 만족스러운 결과를 제공하지 못했습니다.신체 - 뇌 예측 데이터 세트에 대한 학습
테스트 데이터 세트의 단일 열을 예측하기 위해 scikit-learn
을 사용하여 "교육 데이터 세트"를 어떻게 훈련 할 수 있습니까? 아래의 배열은 데모 용입니다.
Training['Brain'] = [3.385, .480, 1.350, 465.00,36.330, 27.660, 14.830, 1.040, 4.190, 0.425, 0.101, 0.920, 1.000, 0.005, 0.060, 3.500 ]
Training['Body'] = [44.500, 15.5, 8.1, 423, 119.5, 115, 98.2, 5.5,58, 6.40, 4, 5.7,6.6, 140,1, 10.8]
Test['Brain'] = [192.000,3.000,160.000,0.900,1.620,0.104,4.235]
Test['Body'] = [180.000,25.000,169.000,2.600,11.400,2.500,50.400]
import pandas as pd
import matplotlib.pyplot as plt
from scipy import stats
training = pd.read_csv('C:\\training.csv', index_col='Index')
test = pd.read_csv('C:\\test.csv', index_col='Index')
train_x = training['Brain']
train_y = training['Body']
slope, intercept, r_value, p_value, std_err = stats.linregress(train_x, train_y)
fig, ax = plt.subplots(figsize=(20,10))
plt.axis([-10, 600, -10, 700])
plt.plot(train_x, train_y, 'ro', color='blue')
plt.ylabel('Body')
plt.xlabel('Brain')
plt.plot(train_x, train_x*slope+intercept, 'black')
plt.plot()
plt.show()
newX = test['Body']
newY = newX * slope+intercept
print(newX)
print(newY)
print(std_err)
없이 당신이 시도 것을보고, 우리가 당신을 도울 수있는 시작점을 제공하기 위해, 질문에 코드를 추가합니다. – Nic3500
질문이 편집되었습니다. @ Nic3500 –