![]() ![]() Since R2 is a function I can't simply use the legend or text code. The red is my line of regression, which I will label later. It gives something like the graph attached, and the R2 varies everytime I change the epochs, or number of layers, or type of data etc. Y_test, y_predicted = y_test.reshape(-1,1), y_predicted.reshape(-1,1)Īx.plot(y_test, LinearRegression().fit(y_test, y_predicted).predict(y_test)) This is how i calculate R2: # Using sklearnĪnd this is my graph: fig, ax = plt.subplots()Īx.plot(,, 'k-', lw=4) ![]() This is my end code for that: y_predicted = model.predict(X_test) My NN uses at least 4 different inputs, and gives one output. I am able to calculate r-squared, and plot my data, but now I want to combine the value on the graph itself, which changes with every new run. I'm using Matplotlib to graphically present my predicted data vs actual data via a neural network. Plt.I am a Python beginner so this may be more obvious than what I'm thinking. What's the label? predict_y = (m*predict_x)+b If the x-values increase as the y-values increase, the scatter plot represents a positive correlation. We will be doing it by applying the vectorization concept of linear algebra. In this video, you will learn that a scatter plot is a graph in which the data is plotted as points on a coordinate grid, and note that a 'best-fit line' can be drawn to determine the trend in the data. First, we need to find the parameters of the line that makes it the best fit. We have our input data, our "feature" so to speak. We can plot a line that fits best to the scatter data points in matplotlib. For example, let's predict out a couple of points: predict_x = 7 If you're not familiar with, you can check out the Data Visualization with Python and Matplotlib tutorial series.Ĭongratulations for making it this far! So, how might you go about actually making a prediction based on this model you just made? Simple enough, right? You have your model, you just fill in x. Now at the end: plt.scatter(xs,ys,color='#003F72')įirst we plot a scatter plot of the existing data, then we graph our regression line, then finally show it. This will allow us to make graphs, and make them not so ugly. Great, let's reap the fruits of our labor finally! Add the following imports: import matplotlib.pyplot as plt The above 1-liner for loop is the same as doing: regression_line = or just knock it out in a single 1-liner for loop: regression_line = ![]() It is an output of regression analysis and can be used as a prediction tool for indicators.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |