def format_and_show_graph(self, dates_list): """Formats and shows the graph.""" plt.yaxis() plt.xticks(rotation=30, size=10) plt.show()
def plot_scatter_of_body(dataframe, feature_1="Body", feature_2="Score"): fig, ax = plt.subplots(1, figsize=(30, 6)) dataframe["Title_len"] = dataframe[feature_1].str.split().str.len() dataframe = dataframe.groupby("Title_len")[feature_2].mean().reset_index() x = dataframe["Title_len"] y = dataframe["Score"] sns.scatterplot(x=x, y=y, data=dataframe, legend="brief", ax=ax) plt.title("Average Upvote by Question Body Length") plt.yaxis("Average Upvote") plt.xaxis("Question Body Length") plt.plot()
rangeN = range(1, numberSubIntervalls) t, w = np.polynomial.legendre.leggauss( order) # t in [-1,1], w weight, ordre 50 plt.figure() for epsilon in [1, 2, 3]: print epsilon a1 = np.array([-epsilon, -1.0]) b1 = np.array([-epsilon, +1.0]) a2 = np.array([epsilon, -1.0]) b2 = np.array([epsilon, +1.0]) int1 = [a1, b1] int2 = [a2, b2] errSing = np.array([]) for n in rangeN: errSing = np.append(errSing, calculateError(int1, int2, n, order, t, w)) #print "coucou", calculateInt(int1, int2, order, t, w) print(np.log(errSing)) plt.plot(np.log(rangeN), np.log(errSing), label=epsilon) plt.hold(True) plt.legend() plt.title("singular function for different eps") plt.yaxis("error") plt.xaxis("ln(number sub intervalls)")
feed_dict={ x: trainX[start:end], y: trainY[start:end] }) if ((i + 1) % 7 == 0): [mseloss, crossError] = sess.run([loss, crossLoss], feed_dict={ x: trainX[start:end], y: trainY[start:end] }) mseValues.append(mseloss) crossValues.append(crossError) [mseClass, crossClass] = sess.run([mseClassError, crossClassError], feed_dict={ x: trainX[start:end], y: trainY[start:end] }) mseClassValues.append(mseClass) crossClassValues.append(1 - crossClass) plt.title("Accuracy of Linear vs Logistic") plt.xaxis("epochs") plt.yaxis("accuracy") plt.plot(mseClassValues, label="linear") plt.plot(crossClassValues, label="logistic") plt.legend() plt.show()
import numpy as np import matplotlib.pyplot as plt def f(x): return np.where(x < 0, 0.0, 1.0) n = 10000 x = np.linspace(-10, 10, n + 1) plt.plot(x, f(x)) plt.xlabel("x") plt.ylabel("y") plt.yaxis(-0.1, 1.1) plt.title("plot") plt.legend(["heaviside"]) plt.show()
print( i, sqrt(np.abs(np.mean(test_scaled[:, 1, i]**2 - predictions[:, i]**2))) / sqrt(np.mean(test_scaled[:, 1, i]**2))) out = 13 #pyplot.plot(series[out]) #pyplot.show() #pyplot.plot(train_scaled_x,train_scaled[:,0,out]) #pyplot.plot(test_scaled_x,test_scaled[:,0,out]) #pyplot.plot(test_scaled_x,predictions[:,out]) #pyplot.show() pyplot.plot(test_scaled_x, test_scaled[:, 0, out]) pyplot.plot(test_scaled_x, predictions[:, out]) pyplot.xaxis('time (minutes)') pyplot.yaxis('B (nT)') pyplot.show() #pyplot.plot(nrmse) #pyplot.show() # track loss vs records # array output/prediction # null hypothesis # check noise in data. Take diff with stencil? # improve data saving technique
x = data.iloc[:, 1:2].values y = data.iloc[:, 2].values from sklearn.preprocessing import PolynomialFeatures p = PolynomialFeatures(degree=4) x_poly = p.fit_transform(x) from sklearn.linear_model import LinearRegression r = LinearRegression() r.fit(x_poly, y) plt.scatter(x, y, color='red') plt.plot(x, r.predict(p.fit_transform(x)), color='blue') plt.title("Position v/s salaries") plt.xaxis("positions") plt.yaxis("salaries") plt.show() #making the curve more smooother x_grid = np.arange(min(x), max(x), 0.1) x_grid = x_grid.reshape(len(x_grid), 1) plt.scatter(x, y, color='red') plt.plot(x_grid, r.predict(p.fit_transform(x_grid)), color='blue') plt.title("Position v/s salaries") plt.xlabel("positions") plt.ylabel("salaries") plt.show() x_ans = np.array(6.5) x_ans = x_ans.reshape(1, 1)