Question: I want to create a regex that can check user name in this terms:

* two first letters are in a-z (no numbers allowed).
* numbers after two letters are allowed.
* space is allowed - not in the beginning.
* after the space can be only a-z, but not number/special char (`john 2doe` )), but `john d2oe` is okay.
* those rules above is apply to every word in the string.
* no special characters allow such `~!@#$%^&*()`

This is what I have done so far:

```
 /^([A-Za-z]{2,})/.test('john#~ doe') // true. - not good. it should be false. 

```

the first and the second I solve it. but how to do the rest?

Answer: 
The reason so many examples out there are so different is because context trumps method. For example, if I'm running a physics experiment to verify a theoretical equation, then in essence the theoretical equation itself is the "test set" and I would want to use as much data as I could (i.e. use all the data) to reduce bias and variance in the estimate. So, if your ozone problem is very well supported by theoretical physical reasoning and you just want to solve for some coefficients (i.e. physical constants) then you want to use the entire dataset to nail down those coefficients as best as possible. In the statistical sense, the physical motivation acts as a "prior," and can be extremely well known (for more about this viewpoint I suggest Kruschke's Bayesian Analysis book).

On the other hand, if you have no idea what sort of effects could be driving the ozone measurements you're getting, and you want to solve for an unknown mapping (using a linear basis set that you assume will work to describe that mapping) then you should hold out some level of your actual measurements to see how well that mapping can generalize.

Lots of "machine learning" these days is primarily data driven because we're coming to the point where we have loads of accessible data, and as such when you take courses that describe methods of data fitting and descriptors (e.g. linear regression) they often come from the entirely data driven context. Whether physically driven or data driven, the methods are very similar and the way you use the methods can even blend together in the middle of either extreme.

More to your question and how to code it, if you take the data driven approach of dividing a train and test set then what you are really doing is saying you want to fit your model to some random sample of "training data" but since you have nothing to compare to later you need to see how well that fit generalizes to some more data, the "test data." So fit your "train data" and then predict or evaluate on your "test data" to see how well your model or mapping works on "unseen" data.
E.g. (expanding on your code)

```
X = data[['day']].values
y = data[['ozone']].values
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, shuffle=False)
model = make_pipeline(PolynomialFeatures(3), LinearRegression())  # If you think 3rd order poly basis ought to work
model.fit(X_train,y_train)

```
You fit your model on the `train` sets, so the features `X_train` and the target `y_train`. So in your case, it is option 1:

```
model.fit(X_train,y_train)

```

Once your model is trained, you can test your model on the `X_test`, and comparing the `y_pred` that results from running the model on the test set to the `y_test`.

The reason you get the 'best plots' for your metric while using option 3 is that you are essentially training on the **whole dataset**. If you then test on a subset of that, then naturally you will get a better score, as you then test your model on the data it had seen during training. You should never do that.