Machine learning 线性测试列的值误差
完成Python基础知识后,我就开始学习机器学习。我知道我没有经验,但喜欢尝试和学习新东西 另外,我应该继续使用机器学习,还是对于没有太多编码经验的人来说太高级了Machine learning 线性测试列的值误差,machine-learning,google-colaboratory,valueerror,Machine Learning,Google Colaboratory,Valueerror,完成Python基础知识后,我就开始学习机器学习。我知道我没有经验,但喜欢尝试和学习新东西 另外,我应该继续使用机器学习,还是对于没有太多编码经验的人来说太高级了 def make_input_fn(data_df, label_df, num_epochs=10, shuffle=True, batch_size=32): #All the stuff that the model needs def input_funcion(): #inner function, th
def make_input_fn(data_df, label_df, num_epochs=10, shuffle=True, batch_size=32):
#All the stuff that the model needs
def input_funcion(): #inner function, this will be returned
ds = tf.data.Dataset.from_tensor_slices((dict(data_df),label_df)) #create a tf.Data.Dataset object with the data and its label
if shuffle:
ds = ds.shuffle(1000) #randomize order of data
ds = ds.batch(batch_size).repeat(num_epochs) #split the dataset into batches of 32 and repeat process for number of epoches
return ds #return a batch of dataset
return input_funcion #return a funcion object for use
train_input_fn = make_input_fn(dftrain, y_train) #here will call the input_function that was returned to as and get a dataset
eval_input_fn = make_input_fn(dfeval, y_eval, num_epochs=1, shuffle=False)
linear_est = tf.estimator.LinearClassifier(feature_columns=feature_columns)
linear_est.train(train_input_fn)
result = linear_est.evaluate(eval_input_fn) #get the model metrics/stats by testing on testing data
clear_output() #clears the console output
print(result["accuracy"]) #the result variable is simply a dictionary of stats about our model