2017-02-28 32 views
0

我一直在玩弄CNTK,並發現模型只能使用numpy數組進行訓練。它是否正確?Dataframes,csv和CNTK

這是有道理的,圖像識別等

我怎麼會變成我的整潔數據集(讀如使用熊貓一個數據幀)轉換爲可以鍛鍊邏輯迴歸與格式?我曾試圖把它讀成numpy的陣列

np.genfromtxt(「My.csv",delimiter=',' , dtype=float) 

,我也試圖與

np.array.MyVeriable.astype('float32') 

包裹變量,但我沒有得到我想要能夠養活一個模型結果。

我也找不到教程中有關如何在CNTK中的表格數據框上執行ML的任何內容。

不支持?

回答

1

感謝您使用這些鏈接。這是我最後讀的CSV它似乎工作,但薩彥請糾正需要:

def generate_data_from_csv(): 

# try to find the data file local. If it doesn't report "file does not exists" if it does report "using loacl file" 
data_path = os.path.join("MyPath") 
csv_file = os.path.join(data_path, "My.csv") 
if not os.path.exists(data_path): 
    os.makedirs(data_path) 
if not os.path.exists(data_file): 
    print("file does not exists") 
else: 
    print("using loacl file") 

df = pd.read_csv(csy_file, usecols = ["predictor1", "predictor2", 
"predictor3", "predictor4", "dependent_variable"], dtype=np.float32) 

return df 

然後我保存的數據幀作爲training_data

training_data = generate_data_from_csv() 

然後我打開那個數據幀到numpy的陣列如下

training_features = np.asarray(training_data[[["predictor1",  
"predictor2", "predictor3", "predictor4",]], dtype = "float32") 
training_labels = np.asarray(training_data[["dependent_variable"]], 
dtype="float32") 

的訓練我用這個代碼的模型:

features, labels = training_features[:,[0,1,2,3]], training_labels