desc = Div(text=""" <h2 style="font-family="Arial"> Select the features to be included in the Ridge Regression Model </h2> <p><a href="http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.Ridge.html#sklearn.linear_model.Ridge" target="_blank">Click here </a>for more information on the parameters </p> """, width=1100) df = pd.read_csv(datasetname) y = df[df.columns[:1]].values.ravel() df1 = df.drop(df.columns[:1], axis=1) target = Paragraph(text='', name='target') target.text = "Target feature is " + str(df.columns[:1].tolist()) features = MultiSelect(title="Features", options=df.columns[1:].tolist()) kfold = Slider(start=2, end=10, value=5, step=1, title="No of folds") fit_intercept = Select(title="Fit_intercept:", value="True", options=["True", "False"]) normalize = Select(title="Normalize:", value="False", options=["True", "False"]) copy_X = Select(title="Copy_X:", value="True", options=["True", "False"]) solver = Select( title="Solver:", value="auto", options=["auto", "svd", "cholesky", "lsqr", "sparse_cg", "sag", "saga"])
max_depth = Slider(start=0, end=50, value=10, step=1, title="Max_Depth") n_estimators = Slider(start=0, end=30, value=10, step=1, title="No of estimators:") bootstrap = Select(title="Bootstrap:", value="True", options=["True", "False"]) oob_score = Select(title="oob_score:", value="False", options=["True", "False"]) warm_start = Select(title="Warm_start:", value="False", options=["True", "False"]) target = Paragraph(text='', name='target') target.text = "Target feature is " + str(df.columns[:1].tolist()) stats = Paragraph(text='', width=1000, name='Selected Features:') y = df[df.columns[:1]].values.ravel() df1 = df.drop(df.columns[:1], axis=1) selector = SelectKBest(chi2, k=5).fit(df1, y) X_new = selector.transform(df1) mask = selector.get_support() #list of booleans new_features = [] # The list of your K best features for bool, feature in zip(mask, df.columns[1:].tolist()): if bool: new_features.append(feature) #print(new_features)
value=str(DEFAULT_AIR_THICKNESS)) air_pressure_input = TextInput(title='air pressure', value=str(DEFAULT_AIR_PRESSURE)) air_temperature_input = TextInput(title='air temperature', value=str(DEFAULT_AIR_TEMPERATURE)) detector_material_input = AutocompleteInput(title='Detector', value=DEFAULT_DETECTOR_MATERIAL) detector_material_input.completions = all_materials detector_thickness_input = TextInput(title='thickness', value=str(DEFAULT_DETECTOR_THICKNESS)) detector_density_input = TextInput(title='density', value=str(DEFAULT_DETECTOR_DENSITY)) p = Paragraph(text="", width=500) p.text = f"Running roentgen version {roentgen.__version__}" columns = [ TableColumn(field="x", title="energy [keV]"), TableColumn(field="y", title="Percent"), ] data_table = DataTable(source=source, columns=columns, width=400, height=700) download_button = Button(label="Download", button_type="success") download_button.js_on_event( ButtonClick, CustomJS(args=dict(source=source), code=open(join(dirname(__file__), "download.js")).read())) def convert_air_pressure(value, current_unit, new_unit):
#df1 = pd.DataFrame(df, columns=columns) #y = df['churn'] y = df[df.columns[:1]].values.ravel() df1 = df.drop(df.columns[:1], axis=1) selector = SelectKBest(chi2, k=5).fit(df1, y) X_new = selector.transform(df1) mask = selector.get_support() #list of booleans new_features = [] # The list of your K best features for bool, feature in zip(mask, df.columns[1:].tolist()): if bool: new_features.append(feature) #print(new_features) stats.text = str(new_features) x_train_original, x_test_original, y_train_original, y_test_original = train_test_split( X_new, y, test_size=0.25) #For standardizing data #clf = svm.LinearSVC(random_state=0) clf = GaussianProcessClassifier() clf.fit(x_train_original, y_train_original) predictions = clf.predict(x_test_original) #print("Accuracy =", accuracy_score(y_test_original,predictions)) #print(np.unique(predictions)) tn, fp, fn, tp = confusion_matrix(y_test_original, predictions).ravel() fruits = ['True Positive', 'False Positive', 'True Negative', 'False Negative'] #fruits = [tp, fp, tn, fn]
+ css, width=1024, height=39) p1 = Div(text="""<font size="+2", color="#154696"><b>Settings</b></font>""", width=600, height=23) p2 = Div(text="""<font size="+2", color="#154696"><b>Results </b></font>""", width=600, height=33) error = Paragraph() calculation_time = Paragraph() total_BED = Paragraph() model_type = Paragraph() num_of_calls = Paragraph() info_data_uploaded = Paragraph() info_data_uploaded.text = default_file_BED + " loaded." rdn_btn_title = Div( text="""<font size="-0.5">Select the type of model: </font>""", width=600, height=15) in_model_rdn_btn = RadioButtonGroup( labels=["Linear", "Heuristic", "Automatic"], active=2) in_model_rdn_btn.callback = CustomJS( args=dict(radioButton=in_model_rdn_btn), code=bgui_js_handlers.in_model_rdn_btn_callback_code) in_model_rdn_btn.on_change("active", selected_model_changed) in_min_time = ColumnDataSource(data=dict(val=[MIN_LP_TIME])) in_time_slider = Slider(start=MIN_LP_TIME, end=MAX_LP_TIME, value=10,
""", width=1100) #obj = client.get_object(Bucket='my-bucket', Key='churn.csv') #df = pd.read_csv(obj['Body']) #df = pd.read_csv('/Users/adilkhan/Documents/CS Fall 16/CS297/Bokeh-Demo/EmbedWebsite/cancer.csv') df = pd.read_csv(datasetname) y = df[df.columns[:1]].values.ravel() df1 = df.drop(df.columns[:1], axis=1) features = MultiSelect(title="Features", options=df.columns[1:].tolist()) target = Paragraph(text='', name='target') target.text = "Target feature is " + str(df.columns[:1].tolist()) stats = Paragraph(text='', width=1000, name='Selected Features:') y = df[df.columns[:1]].values.ravel() df1 = df.drop(df.columns[:1], axis=1) selector = SelectKBest(chi2, k=5).fit(df1, y) X_new = selector.transform(df1) mask = selector.get_support() #list of booleans new_features = [] # The list of your K best features for bool, feature in zip(mask, df.columns[1:].tolist()): if bool: new_features.append(feature) #print(new_features) features.value = new_features
# widget documentation: # http://bokeh.pydata.org/en/latest/docs/user_guide/interaction/widgets.html#select # 0. imports from bokeh.io import curdoc from bokeh.layouts import column from bokeh.models.widgets import TextInput, Button, Paragraph, Select # 1. create some widgets title = Paragraph() title.text = 'Name Selector' button = Button(label="Say HI") #input = TextInput(value="Bokeh") output = Paragraph() select = Select( title='Name:', value='select', options=['Jordan', 'Matthew', 'Rebecca', 'Austin', 'Josh', 'Laura']) # 2. add a callback to a widget def update(): #output.text = "Hello, " + input.value output.text = "Hello, " + select.value button.on_click(update) # 3. create a layout for everything #layout = column(button, input, output) layout = column(button, select, output)
ctl_num_nodes = Slider(title="Num. nodes", value=rml.NUM_NODES, start=1, end=500, step=1) ctl_hidden = Slider(title="Num. hidden layers", value=rml.NUM_HIDDEN_LAYERS, start=1, end=500, step=1) ctl_inputs = widgetbox(ctl_model_title, ctl_model, ctl_title, ctl_feat_reduce, ctl_est, ctl_pct_test, ctl_kernel, ctl_c_val, ctl_neighbors, ctl_num_nodes, ctl_hidden) disp_features = Paragraph(text="") disp_score = Paragraph(text="Score: --") # Data Sources and Initialization d_data = rml.preprocess(rml.read_file("daylio_export.csv")) d_features = rml.extract_features(d_data) if ctl_feat_reduce.active: d_features = rml.feature_select(d_features, d_data["mood"]) x, y = range(len(d_data)), d_data["mood"] disp_features.text = ", ".join([c.title() for c in d_features.keys()]) source_data = ColumnDataSource(data=dict(x=x, y=y, timestamp=d_data["date"] + ", " + d_data["year"].apply(str))) pred_data = ColumnDataSource( data=dict(x=x, y=[0, ] * len(y), timestamp=d_data["date"] + ", " + d_data["year"].apply(str))) plot_mood_scatter.scatter('x', 'y', source=source_data) xrange_data = Range1d(bounds=[None, None], start=0, end=len(y)) yrange_data = Range1d(bounds=[None, None], start=Y_MIN, end=Y_MAX) plot_mood_scatter.x_range = xrange_data plot_mood_scatter.y_range = yrange_data # Set up bar graph source_bars = ColumnDataSource(dict(y=d_data["mood"].value_counts().index, right=d_data["mood"].value_counts())) pred_line = ColumnDataSource(dict(y=d_data["mood"].value_counts().index, x=[0, ] * len(d_data["mood"].value_counts())))
def beliebtheitsermittler(df,actorList, productionList , directorList, writersList, genreList,df_merged, ratingQuantile ): text = "Füllen Sie die Felder aus und drücken auf den Start-Button um den Film zu bewerten." actorList = list(set(actorList)) productionList = list(set(productionList)) directorList = list(set(directorList)) writersList = list(set(writersList)) genreList = list(set(genreList)) output_notebook() # Set up widgets actor1 = AutocompleteInput(completions=actorList, placeholder = 'Required',title='Schauspieler 1') actor2 = AutocompleteInput(completions=actorList, placeholder = 'Required', title='Schauspieler 2') actor3 = AutocompleteInput(completions=actorList, placeholder = 'Required', title='Schauspieler 3') actor4 = AutocompleteInput(completions=actorList, placeholder = 'Required', title='Schauspieler 4') production = AutocompleteInput(completions=productionList, placeholder = 'Required', title='Production') director = AutocompleteInput(completions= directorList, placeholder = 'Required', title='Regie') autor = AutocompleteInput(completions= writersList, placeholder = 'Required', title='Autor') genre = Select(title = 'Auswahl des Hauptgenre',height = 50,value = 'Comedy', options = genreList) select = Select(title = 'Auswahl der Metric',height = 50,value = 'Metascore', options = ['Metascore', 'imdbRating', 'TomatoRating']) answer = Button(height = 100, width = 600,disabled = True,margin = [10,10,10,10],background = 'white', label = text) button = Button(margin = [23,0,0,200], width = 100, button_type = 'primary', label = 'Start') paragraph2 = Paragraph(margin = [40,0,0,10]) paragraph2.text = "Ergebnis:" def doOnClick(): metric = select.value columns = df_merged.columns.tolist() columns.remove('Category') if (actor1.value in actorList) and (actor2.value in actorList) and (actor3.value in actorList) and (actor4.value in actorList) and (production.value in productionList) and (director.value in directorList) and (autor.value in writersList): filename = 'models/'+ metric + '_model.sav' model = pickle.load(open(filename, 'rb')) d = pd.DataFrame(0,index=np.arange(1), columns=columns) d['Actors_' + actor1.value] = 1 d['Actors_' + actor2.value] = 1 d['Actors_' + actor3.value] = 1 d['Actors_' + actor4.value] = 1 d['Genre_' + genre.value] = 1 d['Director_' + director.value] = 1 d['Writer_' + autor.value] = 1 d['Production__'+ production.value] = 1 result = model.predict(d)[0] if ('Gut' in result): answer.background = 'green' elif('Schlecht' in result): answer.background = 'red' else: answer.background = 'yellow' answer.label = result else: answer.label = text answer.background = 'white' button.on_click(doOnClick) layout = [row(widgetbox(actor1 , actor2, actor3, actor4, genre), widgetbox( production, director,autor, select, button ))] def modify_doc(doc): doc.add_root(row(layout)) doc.add_root(column(widgetbox(paragraph2,answer))) handler = FunctionHandler(modify_doc) app = Application(handler) show(app)