Python 使用终端用户的输入,使用TensorFlow模型评估癌症是恶性还是良性

Python 使用终端用户的输入,使用TensorFlow模型评估癌症是恶性还是良性,python,tensorflow,machine-learning,keras,Python,Tensorflow,Machine Learning,Keras,我的代码如下所示。我如何使用从代码用户处获取的输入,并使用科学家用来收集癌症数据的常用指标来评估癌症是恶性还是良性?简单地说,我希望能够输入我在real()函数中列出的度量,并使用TF模型来评估它是1=m(恶性)还是0=b(良性),因此我希望代码使用用户提供的信息来判断它是1还是0。我希望这是可能的 代码: cancer.csv文件: import pandas as pd from sklearn.model_selection import train_test_split import t

我的代码如下所示。我如何使用从代码用户处获取的输入,并使用科学家用来收集癌症数据的常用指标来评估癌症是恶性还是良性?简单地说,我希望能够输入我在real()函数中列出的度量,并使用TF模型来评估它是1=m(恶性)还是0=b(良性),因此我希望代码使用用户提供的信息来判断它是1还是0。我希望这是可能的

代码:

cancer.csv文件:

import pandas as pd
from sklearn.model_selection import train_test_split
import tensorflow as tf
dataset = pd.read_csv("cancer.csv")
model = tf.keras.models.Sequential()
x = dataset.drop(columns=["diagnosis(1=m, 0=b)"])
y = dataset["diagnosis(1=m, 0=b)"]
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2)
def cancer():
    model.add(tf.keras.layers.Dense(256, input_shape=x_train.shape, activation='sigmoid'))
    model.add(tf.keras.layers.Dense(256, activation='sigmoid'))
    model.add(tf.keras.layers.Dense(1, activation='sigmoid'))

    model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'])

    model.fit(x_train, y_train, epochs=10)
    test()
def test():
    model.evaluate(x_test, y_test)
    real()
def real():
    a = input("Mean Radius(6.00-29): ")
    b = input('Mean Texture(9.00-40.00): ')
    c = input('Mean Perimeter(43.00-189.0): ')
    d = input('Mean Area(143.0-2501): ')
    e = input('Mean Smoothness(0.05-0.17): ')
    f = input('Mean Compactness(0.02-0.35): ')
    g = input('Mean Concavity(0.00-0.43): ')
    h = input('Mean Concave Points(0.00-0.20): ')
    i = input('Mean Symmetry(0.10-0.30): ')
    j = input('Mean Fractal Dimension (0.048-0.098): ')
    ok = [a,b,c,d,e,f,g,h,i,j]


cancer()