Last active
September 29, 2016 06:06
-
-
Save ramnov/4eaa0d8a30e2796efeac41691f5b0bdd to your computer and use it in GitHub Desktop.
Stored Procedure to split the data into train(75%) and test(25%)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE PROCEDURE [dbo].[SplitLoans] | |
AS | |
BEGIN | |
SET NOCOUNT ON; | |
-- 75% Training data | |
DROP TABLE IF EXISTS [dbo].[LoanStatsTrain] | |
SELECT * INTO [dbo].[LoanStatsTrain] FROM (SELECT * FROM [dbo].[LoanStats] WHERE (ABS(CAST((BINARY_CHECKSUM(id, NEWID())) as int)) % 100) < 75)a | |
-- 25% Test data | |
DROP TABLE IF EXISTS [dbo].[LoanStatsTest] | |
SELECT * INTO [dbo].[LoanStatsTest] FROM (SELECT * FROM [dbo].[LoanStats] WHERE [id] NOT IN (SELECT [id] FROM [dbo].[LoanStatsTrain]))a | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment