如何對數據進行分區,然後對其中的一部分進行建模(例如驗證)以進行名義邏輯回歸?
JMP Pro絕對讓這一點毫不費力,但這裡有一種模仿JMP Pro創建分區功能的方法。 使用分區仍然是非常手動的。 您可以隱藏/排除val和測試集以使模型適合訓練數據,然後使用從您使用的任何平台保存的預測公式,使用val和測試集上的訓練模型進行預測。
dt = Current Data Table();
n_rows = N Row(dt);
//determine proportions for training and validation sets (test is whatever is left over)
train_prop = 0.7;
val_prop = 0.15;
test_prop = 1-train_prop-val_prop;
//randomly shuffle row numbers
rows_shuffled = random shuffle(1::n_rows);
//determine precise number of data points for each partition
n_train = floor(train_prop*n_rows);
n_val = ceiling(val_prop*n_rows);
n_test = n_rows - n_train - n_val;
//obtain the desired data points for the partitions
train_rows = rows_shuffled[1::n_train];
val_rows = rows_shuffled[(n_train+1)::(n_train+1+n_val)];
test_rows = rows_shuffled[(n_rows-n_test)::n_rows];
//Create the partition column
partition_col = dt << New Column("Partition", numeric, nominal); //use partition_col just in case a Partition column already exists and the new column gets a name like "Partition 2"
//mimic JMP Prop underlying numeric values
partition_col[train_rows] = 1;
partition_col[val_rows] = 2;
partition_col[test_rows] = 3;
//Add value labels
partition_col << Add Column Properties({Value Labels( {"." = "Other", 1 = "Training", 2 = "Validation", 3 = "Test"} ),
Use Value Labels( 1 )});我只是把它一起鞭打了,但你可以輕鬆地將它變成一個帶有對話框的應用程序,詢問培訓和驗證的比例。 您可以通過“視圖”>“自定義”>“菜單”和“工具欄”將該應用程序的腳本添加到菜單或工具欄中,從而使其變得非常方便。
阻力最小的路徑是使用JMP Pro和Make Validation Column實用程序。考慮可能使用分層隨機選項來分區響應變量集。然後,當您實際啟動平台時,請確保將列名放在Fit Model平台啟動窗口的Validation窗口中。