Netflix Stock Price Predictions#

Author: Courtney Rena Vasquez

Course Project, UC Irvine, Math 10, F23

Introduction#

I created a project examining Netflix’s stocks. While my dataset is a very clean and well produced dataset, the stock market is not clean or very predictable in the long run. however, using machine learning we can define and produce trends throughout the data we are given and studied.

Cleaning The Data#

import pandas as pd
import seaborn as sns
import altair as alt
import numpy as np
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error
from sklearn.model_selection import train_test_split
from sklearn.neighbors import KNeighborsClassifier
import matplotlib.pyplot as plt
from sklearn.neighbors import NearestNeighbors

dropping any possible missing data and setting the dataset up.

df = pd.read_csv("NFLX.csv")
df = df.dropna()
df.head()
Date Open High Low Close Adj Close Volume
0 2018-02-05 262.000000 267.899994 250.029999 254.259995 254.259995 11896100
1 2018-02-06 247.699997 266.700012 245.000000 265.720001 265.720001 12595800
2 2018-02-07 266.579987 272.450012 264.329987 264.559998 264.559998 8981500
3 2018-02-08 267.079987 267.619995 250.000000 250.100006 250.100006 9306700
4 2018-02-09 253.850006 255.800003 236.110001 249.470001 249.470001 16906900

Now I want to be able to categorize the data by the specific days and years.

df["Date"] = pd.to_datetime(df["Date"])
df["Year"] = df["Date"].dt.year

calculate the differences between the high/low and open prices

df["Dif_L"]=df["Open"]-df["Low"]
df["Dif_h"]=df["High"]-df["Open"]

calculate the difference between the open and close market price of stocks so that we can understand if they are worth trading or not.

df["Value"]=df["Close"]-df["Open"]

a simpler numerical value to if its worth trading of not

df["Worth"]= 0 
for n in df.index:
    if df.loc[n,"Value"]>=0:
        df.loc[n,"Worth"]=1 

Part 1: Graphs and Analyzing Trend Visually#

I’m going to start off making a graph of all data points from February 2018 to February 2022, so that we can see the overarching trend of Netflix’s stock price.

all_data = alt.Chart(df).mark_line().encode(
    x =alt.X("Date:T", title="Date"),
    y =alt.Y("Close:Q", title = "Price"),
    tooltip=["Date","Close"]
)
all_data

Looking at the graph, we see that overall the price of stock went on an upwards overall trend until around the end of 2021, beginning of 2022. Seeing this, lets look into this specific price drop.

end_dates = df.tail(70)
end = alt.Chart(end_dates).mark_line().encode(
    x =alt.X("Date:T", title="Date"),
    y =alt.Y("Close:Q", title = "Price"),
    tooltip=["Date","Close"]
)
end

While this doesn’t look like a big drop, in reality if we think about it netflix lost almost 40% of its price of stock.

Part 2: Linear Regression#

In this section we are going to build a linear Regression model to predict the future trend of Netflix Stock using the train-test method. First we’ll predict the trends of data we know from 2018-2019.

create a data frame with just 2018 and 2019 values

df_18 = df[(df['Year'] == 2018)]
df_19 = df[(df['Year'] == 2019)]
df1819 = pd.concat([df_18, df_19], ignore_index=True)

create a training and test set

X_train, X_test, y_train, y_test = train_test_split(df1819[['Open','High','Low']], df1819['Close'], test_size=0.2, random_state=42)

fit it to the linear regression model

reg = LinearRegression()
reg.fit(X_train, y_train)
LinearRegression()
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.

get the predicted values for the training and test sets and then add them to the 2018-2019 data set

y_train_pred = reg.predict(X_train)
y_test_pred = reg.predict(X_test)
df1819.loc[X_train.index, 'pred'] = y_train_pred
df1819.loc[X_test.index, 'pred'] = y_test_pred

create a graph of the real close market values of the netflix stock from 2018-2019

real = alt.Chart(df1819).mark_line().encode(
    x = 'Date',
    y = 'Close',
    color = alt.value('darkgreen'),
    tooltip=["Date","Close"]
)
real

create a graph of the predicted close market values of the netflix stock from 2018-2019

predicted = alt.Chart(df1819).mark_line().encode(
    x = 'Date',
    y = 'pred',
    color = alt.value('cyan'),
    tooltip=["Date","pred"]
)
predicted

Overlay the graphs in order to see the difference between the real and predicted values. You can tell here that the regression model was able to predict the values very well.

pred_real = real+predicted
pred_real

I pulled the score values of the training and test sets to show that the training set is not overfitting and that the model is accurate. The test set is very important so that we can see if the model is ready for use with unseen data and since we got such similar scores we can successfully conclude that.

reg.score(X_train, y_train)
0.9944507908768838
reg.score(X_test, y_test)
0.993643810934093

Part 3: k-NN Classifier to Find Outliers#

After using this I found out that my data actually had no outliers, but decided to leave it in because I believe it is an important piece of data found.

I prepared my data by removing anything that was not a value related to stock price

dfd = df.drop('Date', axis = 1)
dfd = dfd.drop('Year', axis = 1)
dfd = dfd.drop('Volume', axis = 1)
X = dfd.values

Here I trained the k-NN model, I changed the value of k a lot and couldn’t see a difference so I left it at 20

k = 20
knn_model = NearestNeighbors(n_neighbors=k)
knn_model.fit(X)
NearestNeighbors(n_neighbors=20)
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.

Then I calculated the distance between each data point and their neighbors

distances, indices = knn_model.kneighbors(X)

I defined what is considered an outlier here

threshold = 500
outliers = np.where(distances > threshold)[0]
outliers
array([], dtype=int64)

I decided to use plt to plot the data and make it easier to see and understand

plt.scatter(X[:, 0], X[:, 1], c='blue', label='Inliers')
plt.scatter(X[outliers, 0], X[outliers, 1], c='red', label='Outliers')
plt.legend()
plt.show()
../../_images/5c9e48e9223ab97ed4abd1f96dbce2d0e5cc7ea5e50dbd2bd5c55962f2d3d41d.png

Overall, this seemed to fail because the data set has no missing values and no crazy values, it is very precise and accurate.

Part 4: k-NN Classification#

This seemed to work better for me. I decided to use the values I found earlier while cleaning the dataset to creat training and test sets between the years 2018 and 2019 to find what stocks were worth trading on what day/time.

here i defined the training set

X_train2=df_18[["Dif_h","Dif_L"]]
y_train2=df_18["Worth"]

then I fit the k-NN classifier

classifier = KNeighborsClassifier(n_neighbors = 5, metric = 'minkowski', p = 2)
classifier.fit(X_train2, y_train2)
KNeighborsClassifier()
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.

Next I had to drop the year category because it is very unnecessary to this particular set of data and made parts of the table light up that didn’t mean anything

df_18 = df_18.drop('Year', axis = 1)
df_19 = df_19.drop('Year', axis = 1)

I defined the test set next

X_test2=df_19[["Dif_h","Dif_L"]]
y_test2=df_19["Worth"]
df_19.head()
Date Open High Low Close Adj Close Volume Dif_L Dif_h Value Worth
228 2019-01-02 259.279999 269.750000 256.579987 267.660004 267.660004 11679500 2.700012 10.470001 8.380005 1
229 2019-01-03 270.200012 275.790009 264.429993 271.200012 271.200012 14969600 5.770019 5.589997 1.000000 1
230 2019-01-04 281.880005 297.799988 278.540009 297.570007 297.570007 19330100 3.339996 15.919983 15.690002 1
231 2019-01-07 302.100006 316.799988 301.649994 315.339996 315.339996 18620100 0.450012 14.699982 13.239990 1
232 2019-01-08 319.980011 320.589996 308.010010 320.269989 320.269989 15359200 11.970001 0.609985 0.289978 1

I used the classsifier to make a prediction on the test set

df_19["Pred2"] = classifier.predict(X_test2)

In order to better visualize whether the stock is worth trading, I hightlight the value that is 1, which means worth trading.

df_19.style.highlight_max(color = 'lightgreen', axis = 0)
Date Open High Low Close Adj Close Volume Dif_L Dif_h Value Worth Pred2
228 2019-01-02 00:00:00 259.279999 269.750000 256.579987 267.660004 267.660004 11679500 2.700012 10.470001 8.380005 1 1
229 2019-01-03 00:00:00 270.200012 275.790009 264.429993 271.200012 271.200012 14969600 5.770019 5.589997 1.000000 1 0
230 2019-01-04 00:00:00 281.880005 297.799988 278.540009 297.570007 297.570007 19330100 3.339996 15.919983 15.690002 1 1
231 2019-01-07 00:00:00 302.100006 316.799988 301.649994 315.339996 315.339996 18620100 0.450012 14.699982 13.239990 1 1
232 2019-01-08 00:00:00 319.980011 320.589996 308.010010 320.269989 320.269989 15359200 11.970001 0.609985 0.289978 1 0
233 2019-01-09 00:00:00 317.709991 323.350006 313.500000 319.959991 319.959991 13343200 4.209991 5.640015 2.250000 1 0
234 2019-01-10 00:00:00 314.570007 325.369995 312.500000 324.660004 324.660004 13472500 2.070007 10.799988 10.089997 1 1
235 2019-01-11 00:00:00 330.959991 341.089996 328.519989 337.589996 337.589996 19500400 2.440002 10.130005 6.630005 1 1
236 2019-01-14 00:00:00 334.239990 335.480011 329.130005 332.940002 332.940002 10499600 5.109985 1.240021 -1.299988 0 0
237 2019-01-15 00:00:00 349.600006 357.220001 347.000000 354.640015 354.640015 21181200 2.600006 7.619995 5.040009 1 1
238 2019-01-16 00:00:00 354.000000 358.850006 348.109985 351.390015 351.390015 15385500 5.890015 4.850006 -2.609985 0 0
239 2019-01-17 00:00:00 349.500000 355.790009 346.410004 353.190002 353.190002 18871200 3.089996 6.290009 3.690002 1 1
240 2019-01-18 00:00:00 351.970001 353.000000 336.730011 339.100006 339.100006 26621000 15.239990 1.029999 -12.869995 0 0
241 2019-01-22 00:00:00 334.890015 336.880005 321.029999 325.160004 325.160004 17941400 13.860016 1.989990 -9.730011 0 0
242 2019-01-23 00:00:00 328.250000 331.750000 318.600006 321.989990 321.989990 13480100 9.649994 3.500000 -6.260010 0 0
243 2019-01-24 00:00:00 320.600006 331.799988 319.000000 326.670013 326.670013 11131600 1.600006 11.199982 6.070007 1 1
244 2019-01-25 00:00:00 328.720001 340.000000 328.510010 338.049988 338.049988 11152900 0.209991 11.279999 9.329987 1 1
245 2019-01-28 00:00:00 334.700012 336.299988 328.880005 335.660004 335.660004 8652100 5.820007 1.599976 0.959992 1 0
246 2019-01-29 00:00:00 335.869995 338.220001 328.149994 328.899994 328.899994 7655200 7.720001 2.350006 -6.970001 0 0
247 2019-01-30 00:00:00 332.750000 341.779999 330.799988 340.660004 340.660004 9234500 1.950012 9.029999 7.910004 1 1
248 2019-01-31 00:00:00 339.679993 345.989990 338.089996 339.500000 339.500000 8535500 1.589997 6.309997 -0.179993 0 1
249 2019-02-01 00:00:00 337.179993 346.839996 336.500000 339.850006 339.850006 9827800 0.679993 9.660003 2.670013 1 1
250 2019-02-04 00:00:00 342.600006 352.000000 341.299988 351.339996 351.339996 9051400 1.300018 9.399994 8.739990 1 1
251 2019-02-05 00:00:00 353.200012 360.000000 352.899994 355.809998 355.809998 9046600 0.300018 6.799988 2.609986 1 1
252 2019-02-06 00:00:00 357.000000 357.040009 347.190002 352.190002 352.190002 6717700 9.809998 0.040009 -4.809998 0 0
253 2019-02-07 00:00:00 347.899994 348.750000 339.019989 344.709991 344.709991 7864500 8.880005 0.850006 -3.190003 0 0
254 2019-02-08 00:00:00 338.000000 348.000000 338.000000 347.570007 347.570007 7561400 0.000000 10.000000 9.570007 1 1
255 2019-02-11 00:00:00 350.000000 352.869995 344.809998 345.730011 345.730011 5454900 5.190002 2.869995 -4.269989 0 0
256 2019-02-12 00:00:00 348.089996 360.000000 346.519989 359.970001 359.970001 10429400 1.570007 11.910004 11.880005 1 1
257 2019-02-13 00:00:00 357.299988 359.600006 350.279999 351.769989 351.769989 10559100 7.019989 2.300018 -5.529999 0 0
258 2019-02-14 00:00:00 351.750000 360.450012 348.329987 359.070007 359.070007 9295300 3.420013 8.700012 7.320007 1 1
259 2019-02-15 00:00:00 358.470001 364.399994 355.500000 356.869995 356.869995 9230000 2.970001 5.929993 -1.600006 0 0
260 2019-02-19 00:00:00 355.799988 365.000000 355.320007 361.920013 361.920013 7396600 0.479981 9.200012 6.120025 1 1
261 2019-02-20 00:00:00 364.850006 366.709991 356.700012 359.910004 359.910004 8110700 8.149994 1.859985 -4.940002 0 0
262 2019-02-21 00:00:00 360.029999 362.850006 353.880005 356.970001 356.970001 6227900 6.149994 2.820007 -3.059998 0 0
263 2019-02-22 00:00:00 360.339996 366.130005 360.049988 363.019989 363.019989 7088200 0.290008 5.790009 2.679993 1 1
264 2019-02-25 00:00:00 367.010010 371.489990 363.790009 363.910004 363.910004 7569300 3.220001 4.479980 -3.100006 0 1
265 2019-02-26 00:00:00 362.980011 365.700012 359.329987 364.970001 364.970001 4944600 3.650024 2.720001 1.989990 1 0
266 2019-02-27 00:00:00 363.500000 368.029999 359.799988 362.869995 362.869995 5629900 3.700012 4.529999 -0.630005 0 0
267 2019-02-28 00:00:00 362.470001 366.390015 357.709991 358.100006 358.100006 6186800 4.760010 3.920014 -4.369995 0 1
268 2019-03-01 00:00:00 362.260010 362.869995 354.690002 357.320007 357.320007 5526500 7.570008 0.609985 -4.940003 0 0
269 2019-03-04 00:00:00 359.720001 362.250000 348.040009 351.040009 351.040009 7487000 11.679992 2.529999 -8.679992 0 0
270 2019-03-05 00:00:00 351.459991 356.170013 348.250000 354.299988 354.299988 5937800 3.209991 4.710022 2.839997 1 1
271 2019-03-06 00:00:00 353.600006 359.880005 351.700012 359.609985 359.609985 6211900 1.899994 6.279999 6.009979 1 1
272 2019-03-07 00:00:00 360.160004 362.859985 350.500000 352.600006 352.600006 6151300 9.660004 2.699981 -7.559998 0 0
273 2019-03-08 00:00:00 345.750000 349.920013 342.470001 349.600006 349.600006 6898800 3.279999 4.170013 3.850006 1 1
274 2019-03-11 00:00:00 352.000000 358.980011 350.029999 358.859985 358.859985 5387300 1.970001 6.980011 6.859985 1 1
275 2019-03-12 00:00:00 359.369995 360.130005 353.799988 356.269989 356.269989 5164600 5.570007 0.760010 -3.100006 0 0
276 2019-03-13 00:00:00 355.809998 362.480011 352.769989 361.209991 361.209991 6444100 3.040009 6.670013 5.399993 1 1
277 2019-03-14 00:00:00 360.500000 363.839996 358.100006 358.820007 358.820007 5271400 2.399994 3.339996 -1.679993 0 0
278 2019-03-15 00:00:00 361.019989 364.000000 358.890015 361.459991 361.459991 8444500 2.129974 2.980011 0.440002 1 0
279 2019-03-18 00:00:00 362.470001 370.970001 361.859985 363.440002 363.440002 7194700 0.610016 8.500000 0.970001 1 1
280 2019-03-19 00:00:00 366.399994 366.959991 356.799988 358.779999 358.779999 7541400 9.600006 0.559997 -7.619995 0 0
281 2019-03-20 00:00:00 358.910004 375.899994 357.010010 375.220001 375.220001 10917200 1.899994 16.989990 16.309997 1 1
282 2019-03-21 00:00:00 374.000000 379.000000 370.609985 377.869995 377.869995 8544000 3.390015 5.000000 3.869995 1 1
283 2019-03-22 00:00:00 375.950012 376.429993 360.040009 361.010010 361.010010 8661300 15.910003 0.479981 -14.940002 0 0
284 2019-03-25 00:00:00 359.000000 367.040009 357.440002 366.230011 366.230011 8473800 1.559998 8.040009 7.230011 1 1
285 2019-03-26 00:00:00 367.869995 368.380005 358.019989 359.970001 359.970001 7666500 9.850006 0.510010 -7.899994 0 0
286 2019-03-27 00:00:00 361.000000 362.470001 350.369995 353.369995 353.369995 7852400 10.630005 1.470001 -7.630005 0 0
287 2019-03-28 00:00:00 354.489990 355.940002 349.200012 354.609985 354.609985 4361000 5.289978 1.450012 0.119995 1 0
288 2019-03-29 00:00:00 357.160004 358.250000 353.709991 356.559998 356.559998 4705600 3.450013 1.089996 -0.600006 0 1
289 2019-04-01 00:00:00 359.000000 368.329987 358.510010 366.959991 366.959991 7036100 0.489990 9.329987 7.959991 1 1
290 2019-04-02 00:00:00 366.250000 368.420013 362.220001 367.720001 367.720001 5158700 4.029999 2.170013 1.470001 1 0
291 2019-04-03 00:00:00 369.260010 373.410004 366.190002 369.750000 369.750000 5368900 3.070008 4.149994 0.489990 1 1
292 2019-04-04 00:00:00 370.070007 372.049988 362.399994 367.880005 367.880005 4627300 7.670013 1.979981 -2.190002 0 0
293 2019-04-05 00:00:00 369.000000 369.799988 364.660004 365.489990 365.489990 3905500 4.339996 0.799988 -3.510010 0 0
294 2019-04-08 00:00:00 365.109985 365.940002 359.929993 361.410004 361.410004 4653800 5.179992 0.830017 -3.699981 0 0
295 2019-04-09 00:00:00 360.540009 366.739990 359.000000 364.709991 364.709991 5439200 1.540009 6.199981 4.169982 1 1
296 2019-04-10 00:00:00 365.790009 368.850006 362.250000 363.920013 363.920013 4545600 3.540009 3.059997 -1.869996 0 0
297 2019-04-11 00:00:00 365.000000 370.119995 360.809998 367.649994 367.649994 6526900 4.190002 5.119995 2.649994 1 0
298 2019-04-12 00:00:00 360.690002 361.750000 349.359985 351.140015 351.140015 15646200 11.330017 1.059998 -9.549987 0 0
299 2019-04-15 00:00:00 350.709991 352.209991 342.269989 348.869995 348.869995 8842300 8.440002 1.500000 -1.839996 0 0
300 2019-04-16 00:00:00 355.000000 364.480011 352.720001 359.459991 359.459991 18740200 2.279999 9.480011 4.459991 1 1
301 2019-04-17 00:00:00 365.049988 368.760010 350.600006 354.739990 354.739990 18054100 14.449982 3.710022 -10.309998 0 0
302 2019-04-18 00:00:00 355.000000 360.410004 351.640015 360.350006 360.350006 8353200 3.359985 5.410004 5.350006 1 1
303 2019-04-22 00:00:00 359.700012 377.690002 359.000000 377.339996 377.339996 11980500 0.700012 17.989990 17.639984 1 1
304 2019-04-23 00:00:00 375.450012 384.799988 374.709991 381.890015 381.890015 10089800 0.740021 9.349976 6.440003 1 1
305 2019-04-24 00:00:00 381.070007 381.899994 373.269989 374.230011 374.230011 6541900 7.800018 0.829987 -6.839996 0 0
306 2019-04-25 00:00:00 374.489990 374.760010 365.700012 368.329987 368.329987 6255500 8.789978 0.270020 -6.160003 0 0
307 2019-04-26 00:00:00 368.350006 375.140015 366.239990 374.850006 374.850006 5621900 2.110016 6.790009 6.500000 1 1
308 2019-04-29 00:00:00 373.679993 374.579987 369.119995 371.829987 371.829987 3821700 4.559998 0.899994 -1.850006 0 0
309 2019-04-30 00:00:00 369.559998 374.500000 368.350006 370.540009 370.540009 3870100 1.209992 4.940002 0.980011 1 1
310 2019-05-01 00:00:00 374.000000 385.989990 373.170013 378.809998 378.809998 9257300 0.829987 11.989990 4.809998 1 1
311 2019-05-02 00:00:00 378.000000 383.500000 374.510010 379.059998 379.059998 5398200 3.489990 5.500000 1.059998 1 1
312 2019-05-03 00:00:00 381.529999 385.029999 378.269989 385.029999 385.029999 5130300 3.260010 3.500000 3.500000 1 1
313 2019-05-06 00:00:00 377.690002 381.350006 376.000000 378.670013 378.670013 5793100 1.690002 3.660004 0.980011 1 1
314 2019-05-07 00:00:00 377.000000 379.910004 365.809998 370.459991 370.459991 6974900 11.190002 2.910004 -6.540009 0 0
315 2019-05-08 00:00:00 367.920013 369.000000 361.359985 364.369995 364.369995 6572000 6.560028 1.079987 -3.550018 0 0
316 2019-05-09 00:00:00 360.899994 364.200012 352.750000 362.750000 362.750000 5882600 8.149994 3.300018 1.850006 1 0
317 2019-05-10 00:00:00 361.619995 365.260010 353.059998 361.040009 361.040009 5657100 8.559997 3.640015 -0.579986 0 0
318 2019-05-13 00:00:00 352.290009 354.260010 343.100006 345.260010 345.260010 8026700 9.190003 1.970001 -7.029999 0 0
319 2019-05-14 00:00:00 348.709991 349.950012 342.500000 345.609985 345.609985 5353000 6.209991 1.240021 -3.100006 0 0
320 2019-05-15 00:00:00 343.339996 356.500000 341.390015 354.989990 354.989990 6340100 1.949981 13.160004 11.649994 1 1
321 2019-05-16 00:00:00 356.369995 364.000000 353.940002 359.309998 359.309998 6441500 2.429993 7.630005 2.940003 1 1
322 2019-05-17 00:00:00 356.390015 359.619995 353.790009 354.450012 354.450012 4725400 2.600006 3.229980 -1.940003 0 0
323 2019-05-20 00:00:00 351.230011 352.420013 345.399994 348.109985 348.109985 4621500 5.830017 1.190002 -3.120026 0 0
324 2019-05-21 00:00:00 350.950012 356.429993 349.929993 354.269989 354.269989 4026400 1.020019 5.479981 3.319977 1 1
325 2019-05-22 00:00:00 358.010010 370.459991 357.299988 359.730011 359.730011 6229400 0.710022 12.449981 1.720001 1 1
326 2019-05-23 00:00:00 355.500000 357.420013 347.700012 352.209991 352.209991 5630400 7.799988 1.920013 -3.290009 0 0
327 2019-05-24 00:00:00 355.410004 359.440002 353.790009 354.390015 354.390015 3831000 1.619995 4.029998 -1.019989 0 1
328 2019-05-28 00:00:00 354.390015 361.200012 353.649994 355.059998 355.059998 4717100 0.740021 6.809997 0.669983 1 1
329 2019-05-29 00:00:00 353.600006 353.850006 345.899994 349.190002 349.190002 5658900 7.700012 0.250000 -4.410004 0 0
330 2019-05-30 00:00:00 350.549988 354.209991 348.299988 351.850006 351.850006 4008000 2.250000 3.660003 1.300018 1 1
331 2019-05-31 00:00:00 347.220001 349.339996 342.920013 343.279999 343.279999 5023400 4.299988 2.119995 -3.940002 0 0
332 2019-06-03 00:00:00 343.559998 347.660004 332.649994 336.630005 336.630005 7849600 10.910004 4.100006 -6.929993 0 0
333 2019-06-04 00:00:00 345.000000 353.609985 343.250000 353.399994 353.399994 7891600 1.750000 8.609985 8.399994 1 1
334 2019-06-05 00:00:00 354.380005 357.880005 348.709991 355.730011 355.730011 5020100 5.670014 3.500000 1.350006 1 1
335 2019-06-06 00:00:00 354.839996 358.209991 352.089996 357.130005 357.130005 3710000 2.750000 3.369995 2.290009 1 0
336 2019-06-07 00:00:00 357.390015 365.149994 355.690002 360.869995 360.869995 4777300 1.700013 7.759979 3.479980 1 1
337 2019-06-10 00:00:00 363.649994 367.100006 349.290009 352.010010 352.010010 7810300 14.359985 3.450012 -11.639984 0 0
338 2019-06-11 00:00:00 355.000000 357.579987 348.500000 351.269989 351.269989 5396700 6.500000 2.579987 -3.730011 0 0
339 2019-06-12 00:00:00 351.820007 353.609985 343.230011 345.559998 345.559998 4584700 8.589996 1.789978 -6.260009 0 0
340 2019-06-13 00:00:00 347.230011 348.500000 339.250000 343.429993 343.429993 6209300 7.980011 1.269989 -3.800018 0 0
341 2019-06-14 00:00:00 341.630005 343.399994 336.160004 339.730011 339.730011 5019000 5.470001 1.769989 -1.899994 0 0
342 2019-06-17 00:00:00 342.690002 351.769989 342.059998 350.619995 350.619995 5358200 0.630004 9.079987 7.929993 1 1
343 2019-06-18 00:00:00 355.570007 361.500000 353.750000 357.119995 357.119995 5428500 1.820007 5.929993 1.549988 1 1
344 2019-06-19 00:00:00 361.720001 364.739990 356.119995 363.519989 363.519989 5667200 5.600006 3.019989 1.799988 1 0
345 2019-06-20 00:00:00 365.910004 370.119995 361.220001 365.209991 365.209991 5899500 4.690003 4.209991 -0.700013 0 1
346 2019-06-21 00:00:00 365.000000 371.450012 365.000000 369.209991 369.209991 7448400 0.000000 6.450012 4.209991 1 1
347 2019-06-24 00:00:00 370.269989 375.000000 370.200012 371.040009 371.040009 4830200 0.069977 4.730011 0.770020 1 1
348 2019-06-25 00:00:00 370.750000 371.000000 358.290009 360.299988 360.299988 5750400 12.459991 0.250000 -10.450012 0 0
349 2019-06-26 00:00:00 361.600006 366.790009 361.600006 362.200012 362.200012 3669700 0.000000 5.190003 0.600006 1 1
350 2019-06-27 00:00:00 363.200012 370.850006 363.200012 370.019989 370.019989 4138600 0.000000 7.649994 6.819977 1 1
351 2019-06-28 00:00:00 370.260010 371.540009 364.869995 367.320007 367.320007 4592700 5.390015 1.279999 -2.940003 0 0
352 2019-07-01 00:00:00 373.500000 376.660004 372.000000 374.600006 374.600006 4992600 1.500000 3.160004 1.100006 1 1
353 2019-07-02 00:00:00 374.890015 376.000000 370.309998 375.429993 375.429993 3625000 4.580017 1.109985 0.539978 1 0
354 2019-07-03 00:00:00 376.690002 381.989990 375.839996 381.720001 381.720001 3799000 0.850006 5.299988 5.029999 1 1
355 2019-07-05 00:00:00 378.290009 381.399994 375.559998 380.549988 380.549988 3732200 2.730011 3.109985 2.259979 1 0
356 2019-07-08 00:00:00 378.190002 378.250000 375.359985 376.160004 376.160004 3113400 2.830017 0.059998 -2.029998 0 1
357 2019-07-09 00:00:00 379.059998 384.760010 377.500000 379.929993 379.929993 6932800 1.559998 5.700012 0.869995 1 1
358 2019-07-10 00:00:00 382.769989 384.339996 362.679993 381.000000 381.000000 5878800 20.089996 1.570007 -1.769989 0 0
359 2019-07-11 00:00:00 381.100006 384.540009 378.799988 379.500000 379.500000 4336300 2.300018 3.440003 -1.600006 0 1
360 2019-07-12 00:00:00 378.679993 379.739990 372.790009 373.250000 373.250000 6636900 5.889984 1.059997 -5.429993 0 0
361 2019-07-15 00:00:00 372.940002 373.679993 362.299988 366.600006 366.600006 7944700 10.640014 0.739991 -6.339996 0 0
362 2019-07-16 00:00:00 370.089996 371.339996 364.920013 365.989990 365.989990 5863200 5.169983 1.250000 -4.100006 0 0
363 2019-07-17 00:00:00 366.250000 366.500000 361.750000 362.440002 362.440002 13639500 4.500000 0.250000 -3.809998 0 0
364 2019-07-18 00:00:00 323.760010 329.850006 320.299988 325.209991 325.209991 31287100 3.460022 6.089996 1.449981 1 1
365 2019-07-19 00:00:00 323.399994 325.850006 314.230011 315.100006 315.100006 16302500 9.169983 2.450012 -8.299988 0 0
366 2019-07-22 00:00:00 312.000000 314.540009 305.809998 310.619995 310.619995 17718000 6.190002 2.540009 -1.380005 0 0
367 2019-07-23 00:00:00 311.440002 313.500000 306.000000 307.299988 307.299988 9171100 5.440002 2.059998 -4.140014 0 0
368 2019-07-24 00:00:00 310.510010 319.989990 307.250000 317.940002 317.940002 11961800 3.260010 9.479980 7.429992 1 1
369 2019-07-25 00:00:00 318.859985 327.690002 316.299988 326.459991 326.459991 10798500 2.559997 8.830017 7.600006 1 1
370 2019-07-26 00:00:00 328.790009 336.000000 327.500000 335.779999 335.779999 10847500 1.290009 7.209991 6.989990 1 1
371 2019-07-29 00:00:00 335.980011 336.399994 328.769989 332.700012 332.700012 5782800 7.210022 0.419983 -3.279999 0 0
372 2019-07-30 00:00:00 329.200012 329.649994 323.230011 325.929993 325.929993 6029300 5.970001 0.449982 -3.270019 0 0
373 2019-07-31 00:00:00 325.160004 331.769989 318.529999 322.989990 322.989990 6259500 6.630005 6.609985 -2.170014 0 0
374 2019-08-01 00:00:00 324.250000 328.579987 318.739990 319.500000 319.500000 6563200 5.510010 4.329987 -4.750000 0 1
375 2019-08-02 00:00:00 317.489990 319.410004 311.799988 318.829987 318.829987 6280300 5.690002 1.920014 1.339997 1 0
376 2019-08-05 00:00:00 310.959991 313.420013 304.679993 307.630005 307.630005 8692500 6.279998 2.460022 -3.329986 0 0
377 2019-08-06 00:00:00 310.579987 311.880005 305.299988 310.100006 310.100006 6179100 5.279999 1.300018 -0.479981 0 0
378 2019-08-07 00:00:00 302.559998 305.000000 296.809998 304.290009 304.290009 9322400 5.750000 2.440002 1.730011 1 0
379 2019-08-08 00:00:00 311.029999 316.359985 306.630005 315.899994 315.899994 5905900 4.399994 5.329986 4.869995 1 0
380 2019-08-09 00:00:00 313.739990 316.640015 305.679993 308.929993 308.929993 5349100 8.059997 2.900025 -4.809997 0 0
381 2019-08-12 00:00:00 305.459991 312.890015 303.239990 310.829987 310.829987 6531700 2.220001 7.430024 5.369996 1 1
382 2019-08-13 00:00:00 309.769989 316.429993 308.160004 312.279999 312.279999 5289400 1.609985 6.660004 2.510010 1 1
383 2019-08-14 00:00:00 308.010010 308.410004 298.010010 299.109985 299.109985 7355800 10.000000 0.399994 -8.900025 0 0
384 2019-08-15 00:00:00 299.500000 300.630005 288.000000 295.760010 295.760010 9629200 11.500000 1.130005 -3.739990 0 0
385 2019-08-16 00:00:00 298.859985 303.549988 296.269989 302.799988 302.799988 6905800 2.589996 4.690003 3.940003 1 1
386 2019-08-19 00:00:00 306.250000 311.750000 304.750000 309.380005 309.380005 4942200 1.500000 5.500000 3.130005 1 1
387 2019-08-20 00:00:00 304.570007 305.000000 297.679993 298.989990 298.989990 7349900 6.890014 0.429993 -5.580017 0 0
388 2019-08-21 00:00:00 301.609985 302.880005 296.200012 297.809998 297.809998 5685400 5.409973 1.270020 -3.799987 0 0
389 2019-08-22 00:00:00 298.649994 300.329987 293.149994 296.929993 296.929993 4974200 5.500000 1.679993 -1.720001 0 0
390 2019-08-23 00:00:00 295.000000 299.010010 290.320007 291.440002 291.440002 6324900 4.679993 4.010010 -3.559998 0 1
391 2019-08-26 00:00:00 295.239990 296.950012 292.500000 294.980011 294.980011 4695700 2.739990 1.710022 -0.259979 0 0
392 2019-08-27 00:00:00 294.540009 296.769989 287.200012 291.029999 291.029999 6309400 7.339997 2.229980 -3.510010 0 0
393 2019-08-28 00:00:00 289.470001 292.820007 287.750000 291.769989 291.769989 3955700 1.720001 3.350006 2.299988 1 1
394 2019-08-29 00:00:00 295.000000 299.929993 294.989990 296.779999 296.779999 4388500 0.010010 4.929993 1.779999 1 1
395 2019-08-30 00:00:00 298.779999 298.940002 290.850006 293.750000 293.750000 4446400 7.929993 0.160003 -5.029999 0 0
396 2019-09-03 00:00:00 290.820007 293.899994 288.059998 289.290009 289.290009 3682800 2.760009 3.079987 -1.529998 0 0
397 2019-09-04 00:00:00 291.250000 292.380005 286.510010 291.519989 291.519989 4652500 4.739990 1.130005 0.269989 1 0
398 2019-09-05 00:00:00 285.320007 293.970001 282.790009 293.250000 293.250000 8966800 2.529998 8.649994 7.929993 1 1
399 2019-09-06 00:00:00 293.350006 293.350006 287.029999 290.170013 290.170013 5166600 6.320007 0.000000 -3.179993 0 0
400 2019-09-09 00:00:00 294.809998 301.549988 290.600006 294.339996 294.339996 8232700 4.209992 6.739990 -0.470002 0 1
401 2019-09-10 00:00:00 291.160004 297.170013 282.660004 287.989990 287.989990 12320200 8.500000 6.010009 -3.170014 0 0
402 2019-09-11 00:00:00 285.700012 292.649994 284.609985 288.269989 288.269989 7405900 1.090027 6.949982 2.569977 1 1
403 2019-09-12 00:00:00 288.100006 292.730011 286.600006 288.859985 288.859985 5010900 1.500000 4.630005 0.759979 1 1
404 2019-09-13 00:00:00 290.609985 296.619995 290.040009 294.149994 294.149994 6583100 0.569976 6.010010 3.540009 1 1
405 2019-09-16 00:00:00 294.230011 297.429993 289.779999 294.290009 294.290009 5307400 4.450012 3.199982 0.059998 1 1
406 2019-09-17 00:00:00 294.500000 299.149994 291.790009 298.600006 298.600006 4777100 2.709991 4.649994 4.100006 1 1
407 2019-09-18 00:00:00 294.989990 296.049988 287.450012 291.559998 291.559998 7811100 7.539978 1.059998 -3.429992 0 0
408 2019-09-19 00:00:00 291.559998 293.809998 283.399994 286.600006 286.600006 8461300 8.160004 2.250000 -4.959992 0 0
409 2019-09-20 00:00:00 280.260010 282.500000 266.000000 270.750000 270.750000 23832800 14.260010 2.239990 -9.510010 0 0
410 2019-09-23 00:00:00 268.350006 273.390015 261.890015 265.920013 265.920013 13478600 6.459991 5.040009 -2.429993 0 0
411 2019-09-24 00:00:00 262.500000 265.000000 252.279999 254.589996 254.589996 16338200 10.220001 2.500000 -7.910004 0 0
412 2019-09-25 00:00:00 255.710007 266.600006 253.699997 264.750000 264.750000 11643800 2.010010 10.889999 9.039993 1 1
413 2019-09-26 00:00:00 266.420013 268.049988 260.200012 263.309998 263.309998 7684000 6.220001 1.629975 -3.110015 0 0
414 2019-09-27 00:00:00 266.179993 267.440002 260.390015 263.079987 263.079987 7328300 5.789978 1.260009 -3.100006 0 0
415 2019-09-30 00:00:00 264.000000 268.880005 262.779999 267.619995 267.619995 6727200 1.220001 4.880005 3.619995 1 1
416 2019-10-01 00:00:00 267.350006 272.200012 264.029999 269.579987 269.579987 8650300 3.320007 4.850006 2.229981 1 1
417 2019-10-02 00:00:00 263.609985 269.350006 262.190002 268.029999 268.029999 7659100 1.419983 5.740021 4.420014 1 1
418 2019-10-03 00:00:00 267.779999 268.839996 257.010010 268.149994 268.149994 8951000 10.769989 1.059997 0.369995 1 0
419 2019-10-04 00:00:00 268.200012 275.480011 266.470001 272.790009 272.790009 9890400 1.730011 7.279999 4.589997 1 1
420 2019-10-07 00:00:00 271.989990 276.679993 271.279999 274.459991 274.459991 6525600 0.709991 4.690003 2.470001 1 1
421 2019-10-08 00:00:00 273.029999 275.529999 270.640015 270.720001 270.720001 6276400 2.389984 2.500000 -2.309998 0 0
422 2019-10-09 00:00:00 270.019989 271.000000 264.570007 267.529999 267.529999 6794400 5.449982 0.980011 -2.489990 0 0
423 2019-10-10 00:00:00 265.970001 280.529999 265.029999 280.480011 280.480011 10809100 0.940002 14.559998 14.510010 1 1
424 2019-10-11 00:00:00 284.799988 287.869995 282.339996 282.929993 282.929993 8786100 2.459992 3.070007 -1.869995 0 0
425 2019-10-14 00:00:00 283.929993 286.929993 282.000000 285.529999 285.529999 5513200 1.929993 3.000000 1.600006 1 1
426 2019-10-15 00:00:00 283.820007 285.869995 279.399994 284.250000 284.250000 7685600 4.420013 2.049988 0.429993 1 0
427 2019-10-16 00:00:00 283.119995 288.170013 280.739990 286.279999 286.279999 16175900 2.380005 5.050018 3.160004 1 1
428 2019-10-17 00:00:00 304.489990 308.750000 288.299988 293.350006 293.350006 38258900 16.190002 4.260010 -11.139984 0 0
429 2019-10-18 00:00:00 289.359985 290.899994 273.359985 275.299988 275.299988 23429900 16.000000 1.540009 -14.059997 0 0
430 2019-10-21 00:00:00 272.890015 279.940002 269.000000 278.049988 278.049988 12599200 3.890015 7.049987 5.159973 1 1
431 2019-10-22 00:00:00 271.160004 275.410004 265.799988 266.690002 266.690002 11802400 5.360016 4.250000 -4.470002 0 1
432 2019-10-23 00:00:00 268.059998 273.920013 266.630005 271.269989 271.269989 7133500 1.429993 5.860015 3.209991 1 1
433 2019-10-24 00:00:00 271.809998 274.019989 268.799988 271.500000 271.500000 4827400 3.010010 2.209991 -0.309998 0 0
434 2019-10-25 00:00:00 270.679993 277.769989 270.179993 276.820007 276.820007 4747800 0.500000 7.089996 6.140014 1 1
435 2019-10-28 00:00:00 278.049988 285.750000 277.350006 281.859985 281.859985 6248400 0.699982 7.700012 3.809997 1 1
436 2019-10-29 00:00:00 281.869995 284.410004 277.549988 281.209991 281.209991 4356200 4.320007 2.540009 -0.660004 0 0
437 2019-10-30 00:00:00 284.339996 293.489990 283.000000 291.450012 291.450012 9345600 1.339996 9.149994 7.110016 1 1
438 2019-10-31 00:00:00 291.000000 291.450012 284.779999 287.410004 287.410004 5090000 6.220001 0.450012 -3.589996 0 0
439 2019-11-01 00:00:00 288.700012 289.119995 283.019989 286.809998 286.809998 5594300 5.680023 0.419983 -1.890014 0 0
440 2019-11-04 00:00:00 288.000000 295.390015 287.160004 292.859985 292.859985 5566200 0.839996 7.390015 4.859985 1 1
441 2019-11-05 00:00:00 289.989990 291.190002 286.309998 288.029999 288.029999 4062400 3.679992 1.200012 -1.959991 0 0
442 2019-11-06 00:00:00 288.190002 290.559998 285.839996 288.589996 288.589996 3438300 2.350006 2.369996 0.399994 1 0
443 2019-11-07 00:00:00 290.700012 298.190002 288.269989 289.570007 289.570007 5928500 2.430023 7.489990 -1.130005 0 1
444 2019-11-08 00:00:00 288.730011 293.989990 287.510010 291.570007 291.570007 4509000 1.220001 5.259979 2.839996 1 1
445 2019-11-11 00:00:00 289.160004 296.359985 288.500000 294.179993 294.179993 3944300 0.660004 7.199981 5.019989 1 1
446 2019-11-12 00:00:00 295.320007 295.350006 288.700012 292.010010 292.010010 5772800 6.619995 0.029999 -3.309997 0 0
447 2019-11-13 00:00:00 291.029999 293.410004 281.140015 283.109985 283.109985 9158900 9.889984 2.380005 -7.920014 0 0
448 2019-11-14 00:00:00 283.250000 290.630005 283.220001 289.619995 289.619995 6529000 0.029999 7.380005 6.369995 1 1
449 2019-11-15 00:00:00 290.589996 295.820007 287.570007 295.029999 295.029999 6333800 3.019989 5.230011 4.440003 1 1
450 2019-11-18 00:00:00 296.000000 304.989990 293.279999 302.570007 302.570007 8616600 2.720001 8.989990 6.570007 1 1
451 2019-11-19 00:00:00 304.010010 305.670013 298.519989 302.600006 302.600006 5918000 5.490021 1.660003 -1.410004 0 0
452 2019-11-20 00:00:00 301.010010 308.250000 301.000000 305.160004 305.160004 5111800 0.010010 7.239990 4.149994 1 1
453 2019-11-21 00:00:00 306.000000 312.690002 304.260010 311.690002 311.690002 7488400 1.739990 6.690002 5.690002 1 1
454 2019-11-22 00:00:00 309.100006 311.399994 304.410004 310.480011 310.480011 5970100 4.690002 2.299988 1.380005 1 0
455 2019-11-25 00:00:00 308.829987 315.730011 305.250000 315.549988 315.549988 7873900 3.579987 6.900024 6.720001 1 1
456 2019-11-26 00:00:00 315.000000 316.500000 311.690002 312.489990 312.489990 5321000 3.309998 1.500000 -2.510010 0 1
457 2019-11-27 00:00:00 313.929993 316.820007 312.750000 315.929993 315.929993 4096900 1.179993 2.890014 2.000000 1 1
458 2019-11-29 00:00:00 315.779999 316.619995 313.339996 314.660004 314.660004 2411700 2.440003 0.839996 -1.119995 0 1
459 2019-12-02 00:00:00 314.390015 314.390015 303.750000 309.989990 309.989990 6218800 10.640015 0.000000 -4.400025 0 0
460 2019-12-03 00:00:00 302.220001 307.359985 301.880005 306.160004 306.160004 4992800 0.339996 5.139984 3.940003 1 1
461 2019-12-04 00:00:00 308.429993 308.429993 303.269989 304.320007 304.320007 3512100 5.160004 0.000000 -4.109986 0 0
462 2019-12-05 00:00:00 305.269989 306.480011 298.809998 302.859985 302.859985 4615500 6.459991 1.210022 -2.410004 0 0
463 2019-12-06 00:00:00 304.700012 307.850006 302.600006 307.350006 307.350006 4457800 2.100006 3.149994 2.649994 1 1
464 2019-12-09 00:00:00 307.350006 311.489990 302.440002 302.500000 302.500000 5748400 4.910004 4.139984 -4.850006 0 1
465 2019-12-10 00:00:00 296.119995 298.940002 292.019989 293.119995 293.119995 10476100 4.100006 2.820007 -3.000000 0 1
466 2019-12-11 00:00:00 294.489990 299.429993 294.200012 298.929993 298.929993 5589800 0.289978 4.940003 4.440003 1 1
467 2019-12-12 00:00:00 295.670013 299.170013 295.059998 298.440002 298.440002 4766600 0.610015 3.500000 2.769989 1 1
468 2019-12-13 00:00:00 298.500000 301.799988 297.250000 298.500000 298.500000 3879700 1.250000 3.299988 0.000000 1 1
469 2019-12-16 00:00:00 300.850006 305.709991 298.630005 304.209991 304.209991 4658900 2.220001 4.859985 3.359985 1 1
470 2019-12-17 00:00:00 307.359985 316.799988 306.600006 315.480011 315.480011 10427100 0.759979 9.440003 8.120026 1 1
471 2019-12-18 00:00:00 316.260010 325.359985 315.600006 320.799988 320.799988 11207400 0.660004 9.099975 4.539978 1 1
472 2019-12-19 00:00:00 324.500000 332.829987 324.179993 332.220001 332.220001 9822300 0.320007 8.329987 7.720001 1 1
473 2019-12-20 00:00:00 335.000000 338.000000 330.600006 336.899994 336.899994 9914900 4.399994 3.000000 1.899994 1 0
474 2019-12-23 00:00:00 337.760010 337.950012 331.019989 333.100006 333.100006 5765300 6.740021 0.190002 -4.660004 0 0
475 2019-12-24 00:00:00 334.010010 335.700012 331.600006 333.200012 333.200012 2019300 2.410004 1.690002 -0.809998 0 0
476 2019-12-26 00:00:00 334.600006 336.459991 332.010010 332.630005 332.630005 3589900 2.589996 1.859985 -1.970001 0 0
477 2019-12-27 00:00:00 332.959991 333.820007 326.010010 329.089996 329.089996 5036100 6.949981 0.860016 -3.869995 0 0
478 2019-12-30 00:00:00 329.079987 329.190002 322.859985 323.309998 323.309998 4311500 6.220002 0.110015 -5.769989 0 0
479 2019-12-31 00:00:00 322.000000 324.920013 321.089996 323.570007 323.570007 3713300 0.910004 2.920013 1.570007 1 1

Summary#

Overall, throughout this project I created an examination of Netflix’s stocks. I built a linear Regression model to predict the future trend of Netflix Stock using the train-test method. Then I created a K - Nearest Neighbor (KNN) Classification in order to classify which stocks were worth trading.

References#

Your code above should include references. Here is some additional space for references.

  • What is the source of your dataset(s)?

Kaggle: https://www.kaggle.com/datasets/jainilcoder/netflix-stock-price-prediction

  • List any other references that you found helpful.

I used this website to learn about K - nearest neighbor classification and how to produce the codes to further my project https://www.ibm.com/topics/knn#:~:text=The k-nearest neighbors algorithm%2C also known as KNN or,of an individual data point.