September 2017
Beginner to intermediate
304 pages
7h 2m
English
Similar to our examples in the previous chapter, we need to split our data into a training and test set. We will once again use github.com/kniren/gota/dataframe to do this:
// Open the clean loan dataset file.f, err := os.Open("clean_loan_data.csv") if err != nil { log.Fatal(err)}defer f.Close() // Create a dataframe from the CSV file. // The types of the columns will be inferred. loanDF := dataframe.ReadCSV(f) // Calculate the number of elements in each set. trainingNum := (4 * loanDF.Nrow()) / 5 testNum := loanDF.Nrow() / 5 if trainingNum+testNum < loanDF.Nrow() { trainingNum++ } // Create the subset indices. trainingIdx := make([]int, trainingNum) testIdx := make([]int, testNum) // Enumerate the training ...Read now
Unlock full access