Пример #1
0
    def getPredictedPriceNormalized(self):
        # get model first
        self.getModelFromFilePath(self, self.file)
        input_features = self.df.iloc[:, [2, 3]].values
        input_data = input_features

        predicted_value = self.model.predict(self.X_test)
        plt.figure(figsize=(100, 40))
        plt.plot(predicted_value, color='red')
        plt.plot(input_data[self.lookback:self.test_size + (2 * self.lookback),
                            1],
                 color='green')
        plt.title("Opening price of stocks sold")
        plt.xlabel("Time (latest-> oldest)")
        plt.ylabel("Stock Opening Price")
        plt.show()

        self.sc.inverse_transform(input_features[self.lookback:self.test_size +
                                                 (2 * self.lookback)])
        return predicted_value
Пример #2
0
import csv

open_file = open("sitka_weather_07-2018_simple.csv", "r")

csv_file = csv.reader(open_file, delimiter=",")

header_row = next(csv_file)
'''
print(header_row)

for index, column_header in enumerate(header_row):
    print(index,column_header)
'''

highs = []

for row in csv_file:
    highs.append(int(row[5]))

print(highs)

import matplotlib.pyploy as plt

plt.plot(highs, c="red")
plt.title("Daily High Temp, July 2018", fontsize=16)
plt.xlabel("")
plt.ylabel("Temperature (F)", fontsize=16)
plt.tick_params(axis="both", which="major", labelsize=16)

plt.show()
Пример #3
0
ret, thresh1 = cv2.threshold(img, 127, 255, cv2.THRESH_BINARY)
ret, thresh2 = cv2.threshold(img, 127, 255, cv2.THRESH_BINARY_INV)
ret, thresh3 = cv2.threshold(img, 127, 255, cv2.THRESH_TRUNC)
ret, thresh4 = cv2.threshold(img, 127, 255, cv2.THRESH_TOZERO)
rec, thresh5 = cv2.threshold(img, 127, 255, cv2.THRESH_TOZERO_INV)

titles = [
    'original image', 'binary', 'binary_inv', 'trunc', 'tozero', 'tozero_inv'
]

images = [img, thresh1, thresh2, thresh3, thresh4, thresh5]

for i in xrange(6):
    plt.subplot(2, 3, i + 1), plt.imshow(image[i], 'gray')
    plt.title(titles[i])
    plt.xticks([]), plt.yticks([])

plt.show()

#adaptive thresh
img = cv2.imread('dave.jpg', 0)
img = cv2.medianBlur(img, 5)

ret, th1 = cv2.threshold(img, 127, 255, cv2.THRESH_BINARY)

th2 = cv2.adaptiveThreshold(img, 255, cv2.ADAPTIVE_THRESH_MEAN_C,
                            cv2.THRESH_BINARY, 11, 2)

th3 = cv2.adaptiveThreshold(img, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C,
                            cv2.THRESH_BINARY, 11, 2)
Пример #4
0
        low = int(row[5])
        current_date= datetime.strptime(row[2],'%Y-%m-%d')
    except ValueError:
        print(f"Missing data for {current_date}")
    else:
        lows.append(int(row[5]))
        highs.append(int(row[4]))
        dates.append(current_date)


import matplotlib.pyploy as plt

fig= plt.figure()

plt.plot(dates, highs, c="red",alpha=0.5)
plt.plot(dates, lows, c="blue", aplha=0.5)

plt.title("Daily high and low temperatures- 2018\nDeath Valley", fontsize=16)
plt.xlabel("", fontsize=12)


plt.fill_between(dates, highs, lows, facecolor= 'blue', alpha=0.1)


fig.autofmt_xdate()

plt.ylabel("Temperature (F)", fontsize=16)
plt.tick_params(axis="both", labelsize=16)

plt.show()
Пример #5
0
import csv
import matplotlib.pyploy as plt
games = []
record = []
wins = 0

f = open('cardinals34.csv')
for row in csv.reader(f):
    if not row[0].isdigit():
        continue
    if row[6].startswith('W') and row[13] == "Dean":
        wins += 1
        games.append(int(row[0]))
        record.append(wins)
plt.title('Dean Brothers progress toward 49 wins')
plt.xlabel('Game number')
plt.ylabel('Win count')
plt.plot(games, record, 'r+')
plt.savefig(games.pdf)
Пример #6
0
print("eigenvectors: \n", eigen_vectors)


for val in eigen_values:
  print(val)
  
variance_explain = [(i/sum(eigen_values))*100 for i in eigen_values]

cumulative_var = np.cumsum(variance_explained)
cumulative_var


sns.lineplot(x = [1,2,3,4]
plt.xlabel("number of components")
plt.ylabel("cumulative variance")
plt.title("explain variance ratio")

plt.show()


#select eigenvectors and compute PCA 
eigen_vectors

projection_matrix = (eigen_vectors.T[:][:])[:2].T
print ("projection_matrix :\n", projection_matrix)

X_pca = X.dot(projection_matrix)

for species in ('Iris-setosa','Iris-versicolor', 'Iris-virginica'):
sns.scatterplot(X_pca[y=species,0],
X_pca[y])