Created
April 8, 2017 00:57
-
-
Save dineshvg/939e6099236300ed225803c60aabc939 to your computer and use it in GitHub Desktop.
Code picks every letter in the list and puts it in test and the rest in train. It does this for the entire list till the end.
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
## Code picks every letter in the list and puts it in test and the rest in train. It does this for the entire list till the end. | |
from collections import Counter | |
# a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | |
a = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'] | |
# Code for splitting training and testing | |
test = [] | |
train = [] | |
for i in range(0, len(a)): | |
if bool(test) is False: | |
test.insert(1, a[i]) | |
print('test inserted', test) | |
if test[0] == a[i]: | |
for ii in range(a.index(a[i]), len(a)): | |
check = Counter(a[ii]) == Counter(test[0]) | |
if check is False: | |
train.append(a[ii]) | |
train = list(train) + list(a[a.index(a[0]):a.index(test[0])]) | |
print('train', train) | |
test = [] | |
train = [] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment