def score(X: str, y: str) -> float: """ Return the coefficient of determination R^2 of the prediction. :param X: Test samples. For some estimators this may be a precomputed kernel matrix or a list of generic objects instead, shape = (n_samples, n_samples_fitted), where n_samples_fitted is the number of samples used in the fitting for the estimator. :type X: array :param y: True values for X. :type y: array :param sample_weight: Sample weights. :type sample_weight: array :param return: R^2 of self.predict(X) wrt. y. :type return: float """ X_input = "~/.cloudmesh/upload-file/" + f"{X}" + ".csv" y_input = "~/.cloudmesh/upload-file/" + f"{y}" + ".csv" X = pd.read_csv(X_input) y = pd.read_csv(y_input) model = ResultCache().load("Linregnew") float = model.score(X, y) return float
def predict(X: array) -> array: """ Predict class labels for samples in X. :param X: Samples. :type X: array :param return: Predicted class label per sample. :type return: array """ model = ResultCache().load("RidgeClassifier") array = model.predict(X) return array
def predict(X: array) -> array: """ Predict using the linear model. :param X: Samples. :type X: array :param return: Returns predicted values. :type return: array """ model = ResultCache().load("RidgeCV") array = model.predict(X) return array
def fit(X: str, y: str): """ Fit linear model. :param X: Training data :type X: array :param y: Target values. Will be cast to X's dtype if necessary :type y: array :param sample_weight: Individual weights for each sample .. versionadded:: 0.17 parameter *sample_weight* support to LinearRegression. :type sample_weight: array :param return: :type return: self """ X_input = "~/.cloudmesh/upload-file/" + f"{X}" + ".csv" y_input = "~/.cloudmesh/upload-file/" + f"{y}" + ".csv" X = pd.read_csv(X_input) y = pd.read_csv(y_input) fit = LinearRegression().fit(X, y) ResultCache().save("Linregnew", "pickle", fit) return
def fit(X: str, y: array, sample_weight: array): """ Fit the model according to the given training data. :param X: Training vector, where n_samples is the number of samples and n_features is the number of features. :type X: str :param y: Target vector relative to X. :type y: array :param sample_weight: Array of weights that are assigned to individual samples. If not provided, then each sample is given unit weight. .. versionadded:: 0.17 *sample_weight* support to LogisticRegression. :type sample_weight: array :param return: Fitted estimator. :type return: self """ fit = LogisticRegression().fit(X, y, sample_weight) ResultCache().save("LogisticRegression", "pickle", fit) return LogisticRegression
def get_params(deep: bool) -> str: """ Get parameters for this estimator. :param deep: If True, will return the parameters for this estimator and contained subobjects that are estimators. :type deep: bool :param return: Parameter names mapped to their values. :type return: str """ model = ResultCache().load("RidgeClassifier") str = model.get_params(deep) return str
def decision_function(X: array) -> array: """ Predict confidence scores for samples. :param X: Samples. :type X: array :param return: Confidence scores per (sample, class) combination. In the binary case, confidence score for self.classes_[1] where >0 means this class would be predicted. :type return: array """ model = ResultCache().load("RidgeClassifier") array = model.decision_function(X) return array
def predict_proba(X: array) -> array: """ Probability estimates. :param X: Vector to be scored, where `n_samples` is the number of samples and `n_features` is the number of features. :type X: array :param return: Returns the probability of the sample for each class in the model, where classes are ordered as they are in ``self.classes_``. :type return: array """ model = ResultCache().load("LogisticRegression") array = model.predict_proba(X) return array
def predict(X: str) -> list: """ Predict using the linear model. :param X: Samples. :type X: array :param return: Returns predicted values. :type return: array """ X_input = "~/.cloudmesh/upload-file/" + f"{X}" + ".csv" X = pd.read_csv(X_input) model = ResultCache().load("Linregnew") list = model.predict(X) list = list.tolist() return list
def score(X: array, y: array, sample_weight: array) -> float: """ Return the mean accuracy on the given test data and labels. :param X: Test samples. :type X: array :param y: True labels for X. :type y: array :param sample_weight: Sample weights. :type sample_weight: array :param return: Mean accuracy of self.predict(X) wrt. y. :type return: float """ model = ResultCache().load("RidgeClassifier") float = model.score(X, y, sample_weight) return float
def score(X: array, y: array, sample_weight: array) -> float: """ Return the coefficient of determination R^2 of the prediction. :param X: Test samples. For some estimators this may be a precomputed kernel matrix or a list of generic objects instead, shape = (n_samples, n_samples_fitted), where n_samples_fitted is the number of samples used in the fitting for the estimator. :type X: array :param y: True values for X. :type y: array :param sample_weight: Sample weights. :type sample_weight: array :param return: R^2 of self.predict(X) wrt. y. :type return: float """ model = ResultCache().load("RidgeCV") float = model.score(X, y, sample_weight) return float
def set_params(**params: dict): """ Set the parameters of this estimator. :param **params: Estimator parameters. :type **params: dict :param return: Estimator instance. :type return: self """ set_params = RidgeClassifier().set_params(**params) ResultCache().save("RidgeClassifier", "pickle", set_params) return RidgeClassifier
def set_params(**params: dict): """ Set the parameters of this estimator. :param **params: Estimator parameters. :type **params: dict :param return: Estimator instance. :type return: self """ set_params = LinearRegression().set_params(**params) ResultCache().save("Linregnew", "pickle", set_params) return
def fit(X: array, y: array, sample_weight: array): """ Fit Ridge regression model with cv. :param X: Training data. If using GCV, will be cast to float64 if necessary. :type X: array :param y: Target values. Will be cast to X's dtype if necessary. :type y: array :param sample_weight: Individual weights for each sample. If given a float, every sample will have the same weight. :type sample_weight: array :param return: :type return: self """ fit = RidgeCV().fit(X, y, sample_weight) ResultCache().save("RidgeCV", "pickle", fit) return RidgeCV
def fit(X: array, y: array, sample_weight: array): """ Fit Ridge classifier model. :param X: Training data. :type X: array :param y: Target values. :type y: array :param sample_weight: Individual weights for each sample. If given a float, every sample will have the same weight. .. versionadded:: 0.17 *sample_weight* support to Classifier. :type sample_weight: array :param return: Instance of the estimator. :type return: self """ fit = RidgeClassifier().fit(X, y, sample_weight) ResultCache().save("RidgeClassifier", "pickle", fit) return RidgeClassifier