@author: lhe39759 """ # -*- coding: utf-8 -*- """ Created on Wed Jul 11 10:21:16 2018 @author: lhe39759 """ import numpy as np from tempfile import TemporaryFile from astroML.datasets import fetch_rrlyrae_combined from astroML.utils import split_samples from astroML.utils import completeness_contamination #---------------------------------------------------------------------- from astroML.plotting import setup_text_plots setup_text_plots(fontsize=8, usetex=False) ############################################################# #############Data Loading & Conversion###################### X, y = fetch_rrlyrae_combined() np.savetxt('AstroML_Data.txt', X) np.savetxt('AstroML_Labels.txt', y) print("Done")
from astroML.datasets import fetch_rrlyrae_combined import numpy as np # get data and save data, labels = fetch_rrlyrae_combined() np.savez('rrlyrae', data=data, labels=labels)
# Author: Jake VanderPlas <*****@*****.**> # License: BSD # The figure produced by this code is published in the textbook # "Statistics, Data Mining, and Machine Learning in Astronomy" (2013) # For more information, see http://astroML.github.com import numpy as np from matplotlib import pyplot as plt from sklearn.naive_bayes import GaussianNB from astroML.datasets import fetch_rrlyrae_combined from astroML.utils import split_samples from astroML.utils import completeness_contamination #---------------------------------------------------------------------- # get data and split into training & testing sets X, y = fetch_rrlyrae_combined() X = X[:, [1, 0, 2, 3]] # rearrange columns for better 1-color results (X_train, X_test), (y_train, y_test) = split_samples(X, y, [0.75, 0.25], random_state=0) N_tot = len(y) N_st = np.sum(y == 0) N_rr = N_tot - N_st N_train = len(y_train) N_test = len(y_test) N_plot = 5000 + N_rr #---------------------------------------------------------------------- # perform Naive Bayes classifiers = [] predictions = []
# see http://astroML.github.com from __future__ import * import numpy as np from matplotlib import pyplot as plt from sklearn.ensemble import RandomForestClassifier from astroML.datasets import fetch_rrlyrae_combined from astroML.utils import completeness_contamination from astroML.utils import split_samples #---------------------------------------------------------------------- from astroML.plotting import setup_text_plots setup_text_plots(fontsize=8, usetex=True) #---------------------------------------------------------------------- # get data and split into training & testing sets X, y = fetch_rrlyrae_combined() # ug, gr, ri, iz X = X[:, [1, 0, 2, 3]] #rearrange columns for better 1-color results (X_train, X_test), (y_train, y_test) = split_samples(X, y, [0.75, 0.25], random_state=0) N_tot = len(y) N_st = np.sum(y == 0) #stars have y = 0 N_rr = N_tot - N_st N_train = len(y_train) N_test = len(y_test) N_plot = 5000 + N_rr #---------------------------------------------------------------------- # Fit RandomForestClassifier Ncolors = np.arange(1, X.shape[1] + 1)