Skip to content

Commit

Permalink
🔥 Delete input validation for HashVectorizer
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshoku committed Jan 29, 2020
1 parent a5d76a7 commit 89dbb26
Showing 1 changed file with 0 additions and 25 deletions.
25 changes: 0 additions & 25 deletions lib/rumale/pipeline/pipeline.rb
Expand Up @@ -40,7 +40,6 @@ def initialize(steps:)
# @param y [Numo::NArray] (shape: [n_samples, n_outputs]) The target values or labels to be used for fitting the model.
# @return [Pipeline] The learned pipeline itself.
def fit(x, y)
x = check_convert_sample_array(x)
trans_x = apply_transforms(x, y, fit: true)
last_estimator&.fit(trans_x, y)
self
Expand All @@ -52,7 +51,6 @@ def fit(x, y)
# @param y [Numo::NArray] (shape: [n_samples, n_outputs], default: nil) The target values or labels to be used for fitting the model.
# @return [Numo::NArray] The predicted results by last estimator.
def fit_predict(x, y = nil)
x = check_convert_sample_array(x)
trans_x = apply_transforms(x, y, fit: true)
last_estimator.fit_predict(trans_x)
end
Expand All @@ -63,7 +61,6 @@ def fit_predict(x, y = nil)
# @param y [Numo::NArray] (shape: [n_samples, n_outputs], default: nil) The target values or labels to be used for fitting the model.
# @return [Numo::NArray] The predicted results by last estimator.
def fit_transform(x, y = nil)
x = check_convert_sample_array(x)
trans_x = apply_transforms(x, y, fit: true)
last_estimator.fit_transform(trans_x, y)
end
Expand All @@ -73,7 +70,6 @@ def fit_transform(x, y = nil)
# @param x [Numo::DFloat] (shape: [n_samples, n_features]) The samples to compute the scores.
# @return [Numo::DFloat] (shape: [n_samples]) Confidence score per sample.
def decision_function(x)
x = check_convert_sample_array(x)
trans_x = apply_transforms(x)
last_estimator.decision_function(trans_x)
end
Expand All @@ -83,7 +79,6 @@ def decision_function(x)
# @param x [Numo::DFloat] (shape: [n_samples, n_features]) The samples to obtain prediction result.
# @return [Numo::NArray] The predicted results by last estimator.
def predict(x)
x = check_convert_sample_array(x)
trans_x = apply_transforms(x)
last_estimator.predict(trans_x)
end
Expand All @@ -93,7 +88,6 @@ def predict(x)
# @param x [Numo::DFloat] (shape: [n_samples, n_features]) The samples to predict the log-probailities.
# @return [Numo::DFloat] (shape: [n_samples, n_classes]) Predicted log-probability of each class per sample.
def predict_log_proba(x)
x = check_convert_sample_array(x)
trans_x = apply_transforms(x)
last_estimator.predict_log_proba(trans_x)
end
Expand All @@ -103,7 +97,6 @@ def predict_log_proba(x)
# @param x [Numo::DFloat] (shape: [n_samples, n_features]) The samples to predict the probailities.
# @return [Numo::DFloat] (shape: [n_samples, n_classes]) Predicted probability of each class per sample.
def predict_proba(x)
x = check_convert_sample_array(x)
trans_x = apply_transforms(x)
last_estimator.predict_proba(trans_x)
end
Expand All @@ -113,7 +106,6 @@ def predict_proba(x)
# @param x [Numo::DFloat] (shape: [n_samples, n_features]) The samples to be transformed.
# @return [Numo::DFloat] (shape: [n_samples, n_components]) The transformed samples.
def transform(x)
x = check_convert_sample_array(x)
trans_x = apply_transforms(x)
last_estimator.nil? ? trans_x : last_estimator.transform(trans_x)
end
Expand All @@ -123,7 +115,6 @@ def transform(x)
# @param z [Numo::DFloat] (shape: [n_samples, n_components]) The transformed samples to be restored into original space.
# @return [Numo::DFloat] (shape: [n_samples, n_featuress]) The restored samples.
def inverse_transform(z)
z = check_convert_sample_array(z)
itrans_z = z
@steps.keys.reverse_each do |name|
transformer = @steps[name]
Expand All @@ -139,26 +130,10 @@ def inverse_transform(z)
# @param y [Numo::NArray] (shape: [n_samples, n_outputs]) True target values or labels for testing data.
# @return [Float] The score of last estimator
def score(x, y)
x = check_convert_sample_array(x)
trans_x = apply_transforms(x)
last_estimator.score(trans_x, y)
end

# Dump marshal data.
# @return [Hash] The marshal data about Pipeline.
def marshal_dump
{ params: @params,
steps: @steps }
end

# Load marshal data.
# @return [nil]
def marshal_load(obj)
@params = obj[:params]
@steps = obj[:steps]
nil
end

private

def validate_steps(steps)
Expand Down

0 comments on commit 89dbb26

Please sign in to comment.