def describe_image(image_path): try: description = describe(image_path) translation = translate(description[0]) return (translation, description[1]) except: return "Não consegui decifrar"
def cmd(file, pop_variance: float, confidence: float): with open(file) as f: reader = csv.reader(f) # 2-dimensional array, but each row can be different number of elements. contents = [[float(v) for v in row] for row in reader] for i, row in enumerate(contents): n, sample_mean, sample_var, _ = describe(row) result = estimate_all(n, sample_mean, sample_var, pop_variance, confidence) print("系列{}".format(i + 1)) print(result)
def main(): parser = argparse.ArgumentParser(description='j\'suis un choixpeau magic') parser.add_argument( '-s', '--scrypt', type=str, dest="scrypt", choices=['describe', 'histogram', 'scatter_plot', 'pair_plot'], help="function scrypt") parser.add_argument(type=str, dest="dataset", help="describe dataset") opt = parser.parse_args() if (opt.scrypt == 'describe'): descr.describe(opt.dataset) elif (opt.scrypt == 'histogram'): histo.histogram(opt.dataset) elif (opt.scrypt == 'scatter_plot'): scatter.scatter(opt.dataset) elif (opt.scrypt == 'pair_plot'): pair.pair_plot(opt.dataset)
def caller(path): start_time = time.time() df = pd.read_csv(path) bdf = bpd.read_csv(path) parent_dict = describe(df, bdf) end_time = time.time() seconds = end_time - start_time return parent_dict, seconds
def _valueString(value, verbose=0): """Returns name and, for some types, value of the variable as a string.""" t = type(value) vstr = t.__name__ if issubclass(t, str): if len(value) > 42: vstr = vstr + ", value = " + ` value[:39] ` + '...' else: vstr = vstr + ", value = " + ` value ` elif issubclass(t, _listTypes): return "%s [%d entries]" % (vstr, len(value)) elif (PY3K and issubclass(t, io.IOBase)) or \ (not PY3K and issubclass(t, file)): vstr = vstr + ", " + ` value ` elif issubclass(t, _numericTypes): vstr = vstr + ", value = " + ` value ` elif _isinstancetype(value): cls = value.__class__ if cls.__module__ == '__main__': vstr = 'instance of class ' + cls.__name__ else: vstr = 'instance of class ' + cls.__module__ + '.' + cls.__name__ elif issubclass(t, _functionTypes + _methodTypes): # try using Fredrik Lundh's describe on functions try: vstr = vstr + ' ' + describe.describe(value) try: if verbose and value.__doc__: vstr = vstr + "\n" + value.__doc__ except AttributeError: pass except (AttributeError, TypeError): # oh well, just have to live with type string alone pass elif issubclass(t, _numpyArrayType): vstr = vstr + " " + str(value.dtype) + "[" for k in range(len(value.shape)): if k: vstr = vstr + "," + ` value.shape[k] ` else: vstr = vstr + ` value.shape[k] ` vstr = vstr + "]" else: # default -- just return the type pass return vstr
def test_estimation(self): data = [100, 70, 30, 60, 50] length, mean, variance, _ = describe.describe(data) pop_variance = 625 confidence = 0.95 bottom, top = estimation.interval_estimate_mean_with_pop_variance( mean, pop_variance, length, confidence) self.assertAlmostEqual(bottom, 40.1, places=1) self.assertAlmostEqual(top, 83.9, places=1) bottom, top = estimation.interval_estimate_mean_without_pop_variance( mean, variance, length, confidence) self.assertAlmostEqual(bottom, 29.9, places=1) self.assertAlmostEqual(top, 94.1, places=1) bottom, top = estimation.interval_estimate_variance( variance, length, confidence) self.assertAlmostEqual(bottom, 241, places=0) self.assertAlmostEqual(top, 5532, places=0)
family="Courier New, monospace", size=8, color="#7f7f7f" ) ) fig.update_xaxes(title_text="Scores", row=row, col=column) fig.update_yaxes(title_text="Frequency", row=row, col=column) # Overlay both histograms fig.update_layout(barmode='overlay') # Reduce opacity to see both histograms fig.update_traces(opacity=0.75) if __name__ == "__main__": df = readData(sys.argv) df_numerical = describe(df) titles = tuple(df_numerical.columns) fig = make_subplots( rows=ROWS, cols=COLUMNS, subplot_titles=titles, specs=[ # row 1 [{"secondary_y": True}, {"secondary_y": True}, {"secondary_y": True}, {"secondary_y": True},{"secondary_y": True} ], # row 2 [{"secondary_y": True}, {"secondary_y": True}, {"secondary_y": True}, {"secondary_y": True},{"secondary_y": True} ], # row 3 [{"secondary_y": True}, {"secondary_y": True}, {"secondary_y": True}, {"secondary_y": True},{"secondary_y": True} ] ]) r = 1 index = 0 _len = len(titles)
import sys houses = {"Ravenclaw": 1, "Slytherin": 2, "Gryffindor": 3, "Hufflepuff": 4} def plot_hist(data, col): plt.figure() plt.title(data.columns[col]) data = data.to_numpy() for i in range(1, 5): curr_house = [] for row in data: if row[1] == i and not np.isnan(row[col]): curr_house.append(row[col]) plt.hist(curr_house, alpha=0.5) plt.show() if __name__ == "__main__": np.set_printoptions(suppress=True) try: data = pd.read_csv("resources/dataset_train.csv") except: sys.exit("Error") data["Hogwarts House"].replace(houses, inplace=True) data = data.select_dtypes('number') metrics = describe.describe(data.to_numpy()) metrics = metrics.tolist() col = metrics[5].index(min(metrics[5])) plot_hist(data, col)
def describe(self): describe.describe(self.df)
import torch import numpy as np from describe import describe # Torch randoms describe(torch.rand(2,3)) # uniform random describe(torch.randn(2,3)) # random normal # Torch creating tensors describe(torch.zeros(2,3)) x = torch.ones(2,3) describe(x) x.fill_(5) # All _ methods refer to in-place operations describe(x) x = torch.Tensor([[1,2,3], [4,5,6]]) describe(x) npy = np.random.rand(2,3) describe(torch.from_numpy(npy)) # Torch tensor operations describe(torch.add(x,x)) describe(x + x) x = torch.arange(6) describe(x) x = x.view(2,3) describe(x)